github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/caas/specs/v2.go (about)

     1  // Copyright 2019 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package specs
     5  
     6  import (
     7  	"github.com/juju/errors"
     8  )
     9  
    10  // PodSpecV2 defines the data values used to configure
    11  // a pod on the CAAS substrate for version 2.
    12  type PodSpecV2 struct {
    13  	podSpecBaseV2  `json:",inline" yaml:",inline"`
    14  	ServiceAccount *ServiceAccountSpecV2 `json:"serviceAccount,omitempty" yaml:"serviceAccount,omitempty"`
    15  }
    16  
    17  // Version2 defines the version number for pod spec version 2.
    18  const Version2 Version = 2
    19  
    20  // Validate returns an error if the spec is not valid.
    21  func (spec *PodSpecV2) Validate() error {
    22  	if err := spec.podSpecBaseV2.Validate(Version2); err != nil {
    23  		return errors.Trace(err)
    24  	}
    25  	if spec.ServiceAccount != nil {
    26  		return errors.Trace(spec.ServiceAccount.Validate())
    27  	}
    28  	return nil
    29  }