kinds

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SampleWorkloadAPIDomain  = "acme.com"
	SampleWorkloadAPIGroup   = "apps"
	SampleWorkloadAPIKind    = "MyApp"
	SampleWorkloadAPIVersion = "v1alpha1"
)

WorkloadAPISpec sample fields which may be used in things like testing or generation of sample files.

Variables

View Source
var (
	ErrLoadManifests   = errors.New("error loading manifests")
	ErrProcessManifest = errors.New("error processing manifest file")
	ErrUniqueName      = errors.New("child resource unique name error")
)
View Source
var ErrInvalidKind = errors.New("unrecognized workload kind in workload config")
View Source
var ErrMissingRequiredFields = errors.New("missing required fields")
View Source
var ErrNoComponentsOnComponent = errors.New("cannot set component workloads on a component workload - only on collections")
View Source
var ErrNoComponentsOnStandalone = errors.New("cannot set component workloads on a component workload - only on collections")
View Source
var ErrOverwriteExistingValue = errors.New("an attempt to overwrite existing value was made")

Functions

func GetWorkloadChildren

func GetWorkloadChildren(workload WorkloadBuilder) []manifests.ChildResource

GetWorkloadChildren returns all child resources relevant to a particular workload.

Types

type APIFields

type APIFields struct {
	Name       string
	StructName string

	Type     markers.FieldType
	Tags     string
	Comments []string
	Markers  []string
	Children []*APIFields
	Default  string
	Sample   string
	// contains filtered or unexported fields
}

func (*APIFields) AddField

func (api *APIFields) AddField(path string, fieldType markers.FieldType, comments []string, sample interface{}, hasDefault bool) error

func (*APIFields) GenerateAPISpec

func (api *APIFields) GenerateAPISpec(kind string) string

func (*APIFields) GenerateSampleSpec

func (api *APIFields) GenerateSampleSpec(requiredOnly bool) string

type ComponentWorkload

type ComponentWorkload struct {
	WorkloadShared `yaml:",inline"`
	Spec           ComponentWorkloadSpec `json:"spec" yaml:"spec" validate:"required"`
}

ComponentWorkload defines a workload that is a component of a collection.

func NewComponentWorkload

func NewComponentWorkload(
	name string,
	spec WorkloadAPISpec,
	manifestFiles, dependencies []string,
) *ComponentWorkload

NewComponentWorkload returns a new component workload object.

func (*ComponentWorkload) GetAPIGroup

func (c *ComponentWorkload) GetAPIGroup() string

func (*ComponentWorkload) GetAPIKind

func (c *ComponentWorkload) GetAPIKind() string

func (*ComponentWorkload) GetAPISpec

func (c *ComponentWorkload) GetAPISpec() WorkloadAPISpec

func (*ComponentWorkload) GetAPISpecFields

func (c *ComponentWorkload) GetAPISpecFields() *APIFields

func (*ComponentWorkload) GetAPIVersion

func (c *ComponentWorkload) GetAPIVersion() string

func (*ComponentWorkload) GetCollection

func (c *ComponentWorkload) GetCollection() *WorkloadCollection

func (*ComponentWorkload) GetComponentResource

func (c *ComponentWorkload) GetComponentResource(domain, repo string, clusterScoped bool) *resource.Resource

func (*ComponentWorkload) GetComponents

func (*ComponentWorkload) GetComponents() []*ComponentWorkload

func (*ComponentWorkload) GetDependencies

func (c *ComponentWorkload) GetDependencies() []*ComponentWorkload

func (*ComponentWorkload) GetDomain

func (c *ComponentWorkload) GetDomain() string

methods that implement WorkloadAPIBuilder.

func (*ComponentWorkload) GetManifests

func (c *ComponentWorkload) GetManifests() *manifests.Manifests

func (*ComponentWorkload) GetName

func (c *ComponentWorkload) GetName() string

func (*ComponentWorkload) GetPackageName

func (c *ComponentWorkload) GetPackageName() string

func (*ComponentWorkload) GetRBACRules

func (c *ComponentWorkload) GetRBACRules() *[]rbac.Rule

func (*ComponentWorkload) GetRootCommand

func (c *ComponentWorkload) GetRootCommand() *companion.CLI

func (*ComponentWorkload) GetSubCommand

func (c *ComponentWorkload) GetSubCommand() *companion.CLI

func (*ComponentWorkload) GetWorkloadKind

func (c *ComponentWorkload) GetWorkloadKind() WorkloadKind

func (*ComponentWorkload) HasChildResources

func (c *ComponentWorkload) HasChildResources() bool

func (*ComponentWorkload) HasRootCmdName

func (c *ComponentWorkload) HasRootCmdName() bool

func (*ComponentWorkload) HasSubCmdDescription

func (c *ComponentWorkload) HasSubCmdDescription() bool

func (*ComponentWorkload) HasSubCmdName

func (c *ComponentWorkload) HasSubCmdName() bool

func (*ComponentWorkload) IsClusterScoped

func (c *ComponentWorkload) IsClusterScoped() bool

func (*ComponentWorkload) IsCollection

func (*ComponentWorkload) IsCollection() bool

func (*ComponentWorkload) IsComponent

func (*ComponentWorkload) IsComponent() bool

func (*ComponentWorkload) IsStandalone

func (*ComponentWorkload) IsStandalone() bool

func (*ComponentWorkload) LoadManifests

func (c *ComponentWorkload) LoadManifests(workloadPath string) error

func (*ComponentWorkload) SetComponents

func (*ComponentWorkload) SetComponents(components []*ComponentWorkload) error

func (*ComponentWorkload) SetNames

func (c *ComponentWorkload) SetNames()

func (*ComponentWorkload) SetRBAC

func (c *ComponentWorkload) SetRBAC()

func (*ComponentWorkload) SetResources

func (c *ComponentWorkload) SetResources(workloadPath string) error

func (*ComponentWorkload) Validate

func (c *ComponentWorkload) Validate() error

type ComponentWorkloadSpec

type ComponentWorkloadSpec struct {
	API                   WorkloadAPISpec      `json:"api" yaml:"api"`
	CompanionCliSubcmd    companion.CLI        `json:"companionCliSubcmd" yaml:"companionCliSubcmd" validate:"omitempty"`
	CompanionCliRootcmd   companion.CLI        `json:"-" yaml:"-" validate:"omitempty"`
	Dependencies          []string             `json:"dependencies" yaml:"dependencies"`
	ConfigPath            string               `json:"-" yaml:"-" validate:"omitempty"`
	ComponentDependencies []*ComponentWorkload `json:"-" yaml:"-" validate:"omitempty"`
	WorkloadSpec          `yaml:",inline"`
}

ComponentWorkloadSpec defines the attributes for a workload that is a component of a collection.

type StandaloneWorkload

type StandaloneWorkload struct {
	WorkloadShared `yaml:",inline"`
	Spec           StandaloneWorkloadSpec `json:"spec" yaml:"spec" validate:"required"`
}

StandaloneWorkload defines a standalone workload.

func NewStandaloneWorkload

func NewStandaloneWorkload(
	name string,
	spec WorkloadAPISpec,
	manifestFiles []string,
) *StandaloneWorkload

NewStandaloneWorkload returns a new standalone workload object.

func (*StandaloneWorkload) GetAPIGroup

func (s *StandaloneWorkload) GetAPIGroup() string

func (*StandaloneWorkload) GetAPIKind

func (s *StandaloneWorkload) GetAPIKind() string

func (*StandaloneWorkload) GetAPISpec

func (s *StandaloneWorkload) GetAPISpec() WorkloadAPISpec

func (*StandaloneWorkload) GetAPISpecFields

func (s *StandaloneWorkload) GetAPISpecFields() *APIFields

func (*StandaloneWorkload) GetAPIVersion

func (s *StandaloneWorkload) GetAPIVersion() string

func (*StandaloneWorkload) GetCollection

func (s *StandaloneWorkload) GetCollection() *WorkloadCollection

func (*StandaloneWorkload) GetComponentResource

func (*StandaloneWorkload) GetComponentResource(domain, repo string, clusterScoped bool) *resource.Resource

func (*StandaloneWorkload) GetComponents

func (s *StandaloneWorkload) GetComponents() []*ComponentWorkload

func (*StandaloneWorkload) GetDependencies

func (*StandaloneWorkload) GetDependencies() []*ComponentWorkload

func (*StandaloneWorkload) GetDomain

func (s *StandaloneWorkload) GetDomain() string

methods that implement WorkloadInitializer.

func (*StandaloneWorkload) GetManifests

func (s *StandaloneWorkload) GetManifests() *manifests.Manifests

func (*StandaloneWorkload) GetName

func (s *StandaloneWorkload) GetName() string

methods that implement WorkloadAPIBuilder.

func (*StandaloneWorkload) GetPackageName

func (s *StandaloneWorkload) GetPackageName() string

func (*StandaloneWorkload) GetRBACRules

func (s *StandaloneWorkload) GetRBACRules() *[]rbac.Rule

func (*StandaloneWorkload) GetRootCommand

func (s *StandaloneWorkload) GetRootCommand() *companion.CLI

func (*StandaloneWorkload) GetSubCommand

func (s *StandaloneWorkload) GetSubCommand() *companion.CLI

func (*StandaloneWorkload) GetWorkloadKind

func (s *StandaloneWorkload) GetWorkloadKind() WorkloadKind

func (*StandaloneWorkload) HasChildResources

func (s *StandaloneWorkload) HasChildResources() bool

func (*StandaloneWorkload) HasRootCmdDescription

func (s *StandaloneWorkload) HasRootCmdDescription() bool

func (*StandaloneWorkload) HasRootCmdName

func (s *StandaloneWorkload) HasRootCmdName() bool

func (*StandaloneWorkload) HasSubCmdName

func (*StandaloneWorkload) HasSubCmdName() bool

func (*StandaloneWorkload) IsClusterScoped

func (s *StandaloneWorkload) IsClusterScoped() bool

func (*StandaloneWorkload) IsCollection

func (*StandaloneWorkload) IsCollection() bool

func (*StandaloneWorkload) IsComponent

func (*StandaloneWorkload) IsComponent() bool

func (*StandaloneWorkload) IsStandalone

func (*StandaloneWorkload) IsStandalone() bool

func (*StandaloneWorkload) LoadManifests

func (s *StandaloneWorkload) LoadManifests(workloadPath string) error

func (*StandaloneWorkload) SetComponents

func (*StandaloneWorkload) SetComponents(components []*ComponentWorkload) error

func (*StandaloneWorkload) SetNames

func (s *StandaloneWorkload) SetNames()

func (*StandaloneWorkload) SetRBAC

func (s *StandaloneWorkload) SetRBAC()

func (*StandaloneWorkload) SetResources

func (s *StandaloneWorkload) SetResources(workloadPath string) error

func (*StandaloneWorkload) Validate

func (s *StandaloneWorkload) Validate() error

type StandaloneWorkloadSpec

type StandaloneWorkloadSpec struct {
	API                 WorkloadAPISpec `json:"api" yaml:"api"`
	CompanionCliRootcmd companion.CLI   `json:"companionCliRootcmd" yaml:"companionCliRootcmd" validate:"omitempty"`
	WorkloadSpec        `yaml:",inline"`
}

StandaloneWorkloadSpec defines the attributes for a standalone workload.

type WorkloadAPISpec

type WorkloadAPISpec struct {
	Domain        string `json:"domain" yaml:"domain"`
	Group         string `json:"group" yaml:"group"`
	Version       string `json:"version" yaml:"version"`
	Kind          string `json:"kind" yaml:"kind"`
	ClusterScoped bool   `json:"clusterScoped" yaml:"clusterScoped"`
}

WorkloadAPISpec contains fields shared by all workload specs.

func NewSampleAPISpec

func NewSampleAPISpec() *WorkloadAPISpec

NewSampleAPISpec returns a new instance of a sample api specification.

type WorkloadBuilder

type WorkloadBuilder interface {
	IsClusterScoped() bool
	IsStandalone() bool
	IsCollection() bool
	IsComponent() bool

	HasRootCmdName() bool
	HasSubCmdName() bool
	HasChildResources() bool

	GetWorkloadKind() WorkloadKind
	GetName() string
	GetPackageName() string
	GetDomain() string
	GetAPIGroup() string
	GetAPIVersion() string
	GetAPIKind() string
	GetDependencies() []*ComponentWorkload
	GetCollection() *WorkloadCollection
	GetComponents() []*ComponentWorkload
	GetAPISpecFields() *APIFields
	GetRBACRules() *[]rbac.Rule
	GetComponentResource(domain, repo string, clusterScoped bool) *resource.Resource
	GetRootCommand() *companion.CLI
	GetSubCommand() *companion.CLI
	GetManifests() *manifests.Manifests

	SetNames()
	SetRBAC()
	SetResources(workloadPath string) error
	SetComponents(components []*ComponentWorkload) error

	LoadManifests(workloadPath string) error
	Validate() error
}

WorkloadBuilder defines an interface for identifying any workload.

func Decode

func Decode(wk WorkloadKind, dc *yaml.Decoder) (WorkloadBuilder, error)

type WorkloadCollection

type WorkloadCollection struct {
	WorkloadShared `yaml:",inline"`
	Spec           WorkloadCollectionSpec `json:"spec" yaml:"spec" validate:"required"`
}

WorkloadCollection defines a workload collection.

func NewWorkloadCollection

func NewWorkloadCollection(
	name string,
	spec WorkloadAPISpec,
	componentFiles []string,
) *WorkloadCollection

NewWorkloadCollection returns a new workload collection object.

func (*WorkloadCollection) GetAPIGroup

func (c *WorkloadCollection) GetAPIGroup() string

func (*WorkloadCollection) GetAPIKind

func (c *WorkloadCollection) GetAPIKind() string

func (*WorkloadCollection) GetAPISpec

func (c *WorkloadCollection) GetAPISpec() WorkloadAPISpec

func (*WorkloadCollection) GetAPISpecFields

func (c *WorkloadCollection) GetAPISpecFields() *APIFields

func (*WorkloadCollection) GetAPIVersion

func (c *WorkloadCollection) GetAPIVersion() string

func (*WorkloadCollection) GetCollection

func (c *WorkloadCollection) GetCollection() *WorkloadCollection

func (*WorkloadCollection) GetComponentResource

func (c *WorkloadCollection) GetComponentResource(domain, repo string, clusterScoped bool) *resource.Resource

func (*WorkloadCollection) GetComponents

func (c *WorkloadCollection) GetComponents() []*ComponentWorkload

func (*WorkloadCollection) GetDependencies

func (c *WorkloadCollection) GetDependencies() []*ComponentWorkload

func (*WorkloadCollection) GetDomain

func (c *WorkloadCollection) GetDomain() string

methods that implement WorkloadInitializer.

func (*WorkloadCollection) GetManifests

func (c *WorkloadCollection) GetManifests() *manifests.Manifests

func (*WorkloadCollection) GetName

func (c *WorkloadCollection) GetName() string

methods that implement WorkloadAPIBuilder.

func (*WorkloadCollection) GetPackageName

func (c *WorkloadCollection) GetPackageName() string

func (*WorkloadCollection) GetRBACRules

func (c *WorkloadCollection) GetRBACRules() *[]rbac.Rule

func (*WorkloadCollection) GetRootCommand

func (c *WorkloadCollection) GetRootCommand() *companion.CLI

func (*WorkloadCollection) GetSubCommand

func (c *WorkloadCollection) GetSubCommand() *companion.CLI

func (*WorkloadCollection) GetWorkloadKind

func (c *WorkloadCollection) GetWorkloadKind() WorkloadKind

func (*WorkloadCollection) HasChildResources

func (c *WorkloadCollection) HasChildResources() bool

func (*WorkloadCollection) HasRootCmdDescription

func (c *WorkloadCollection) HasRootCmdDescription() bool

func (*WorkloadCollection) HasRootCmdName

func (c *WorkloadCollection) HasRootCmdName() bool

func (*WorkloadCollection) HasSubCmdDescription

func (c *WorkloadCollection) HasSubCmdDescription() bool

func (*WorkloadCollection) HasSubCmdName

func (c *WorkloadCollection) HasSubCmdName() bool

func (*WorkloadCollection) IsClusterScoped

func (c *WorkloadCollection) IsClusterScoped() bool

func (*WorkloadCollection) IsCollection

func (c *WorkloadCollection) IsCollection() bool

func (*WorkloadCollection) IsComponent

func (c *WorkloadCollection) IsComponent() bool

func (*WorkloadCollection) IsStandalone

func (c *WorkloadCollection) IsStandalone() bool

func (*WorkloadCollection) LoadManifests

func (c *WorkloadCollection) LoadManifests(workloadPath string) error

func (*WorkloadCollection) SetComponents

func (c *WorkloadCollection) SetComponents(components []*ComponentWorkload) error

func (*WorkloadCollection) SetNames

func (c *WorkloadCollection) SetNames()

func (*WorkloadCollection) SetRBAC

func (c *WorkloadCollection) SetRBAC()

func (*WorkloadCollection) SetResources

func (c *WorkloadCollection) SetResources(workloadPath string) error

func (*WorkloadCollection) Validate

func (c *WorkloadCollection) Validate() error

type WorkloadCollectionSpec

type WorkloadCollectionSpec struct {
	API                 WorkloadAPISpec      `json:"api" yaml:"api"`
	CompanionCliRootcmd companion.CLI        `json:"companionCliRootcmd,omitempty" yaml:"companionCliRootcmd,omitempty" validate:"omitempty"`
	CompanionCliSubcmd  companion.CLI        `json:"companionCliSubcmd,omitempty" yaml:"companionCliSubcmd,omitempty" validate:"omitempty"`
	ComponentFiles      []string             `json:"componentFiles" yaml:"componentFiles"`
	Components          []*ComponentWorkload `json:",omitempty" yaml:",omitempty" validate:"omitempty"`
	WorkloadSpec        `yaml:",inline"`
}

WorkloadCollectionSpec defines the attributes for a workload collection.

type WorkloadKind

type WorkloadKind int32

WorkloadKind indicates which of the supported workload kinds are being used.

const (
	WorkloadKindUnknown WorkloadKind = iota
	WorkloadKindStandalone
	WorkloadKindCollection
	WorkloadKindComponent
)

func (WorkloadKind) String

func (wk WorkloadKind) String() string

func (*WorkloadKind) UnmarshalJSON

func (wk *WorkloadKind) UnmarshalJSON(data []byte) error

func (*WorkloadKind) UnmarshalYAML

func (wk *WorkloadKind) UnmarshalYAML(node *yaml.Node) error

type WorkloadShared

type WorkloadShared struct {
	Name        string       `json:"name"  yaml:"name" validate:"required"`
	Kind        WorkloadKind `json:"kind"  yaml:"kind" validate:"required"`
	PackageName string       `json:",omitempty" yaml:",omitempty" validate:"omitempty"`
}

WorkloadShared contains fields shared by all workloads.

type WorkloadSpec

type WorkloadSpec struct {
	Resources []string `json:"resources" yaml:"resources"`

	Manifests              *manifests.Manifests             `json:",omitempty" yaml:",omitempty" validate:"omitempty"`
	FieldMarkers           []*markers.FieldMarker           `json:",omitempty" yaml:",omitempty" validate:"omitempty"`
	CollectionFieldMarkers []*markers.CollectionFieldMarker `json:",omitempty" yaml:",omitempty" validate:"omitempty"`
	ForCollection          bool                             `json:",omitempty" yaml:",omitempty" validate:"omitempty"`
	Collection             *WorkloadCollection              `json:",omitempty" yaml:",omitempty" validate:"omitempty"`
	APISpecFields          *APIFields                       `json:",omitempty" yaml:",omitempty" validate:"omitempty"`
	RBACRules              *rbac.Rules                      `json:",omitempty" yaml:",omitempty" validate:"omitempty"`
}

WorkloadSpec contains information required to generate source code.

func (*WorkloadSpec) ProcessResourceMarkers

func (ws *WorkloadSpec) ProcessResourceMarkers(markerCollection *markers.MarkerCollection) error

ProcessResourceMarkers processes a collection of field markers, associates them with their respective resource markers, and generates the source code needed for that particular resource marker.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL