v1

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2022 License: MIT Imports: 21 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.

View Source
const PluginConfigKey = "operatorBuilder"

Variables

View Source
var (
	ErrNamesMustBeUnique   = errors.New("each workload name must be unique")
	ErrConfigMustExist     = errors.New("no workload config provided - workload config required")
	ErrMultipleConfigs     = errors.New("multiple configs found - please provide only one standalone or collection workload")
	ErrCollectionRequired  = errors.New("a WorkloadCollection is required when using WorkloadComponents")
	ErrMissingWorkload     = errors.New("could not find either standalone or collection workload, please provide one")
	ErrMissingDependencies = errors.New("missing dependencies - no workload config provided")
)
View Source
var (
	ErrFileExists  = errors.New("force was not requested and file exists")
	ErrWriteFile   = errors.New("unable to write to file")
	ErrWriteStdout = errors.New("unable to write to stdout")
)
View Source
var (
	ErrReservedFieldMarker     = errors.New("field marker cannot be used and is reserved for internal purposes")
	ErrNumberResourceMarkers   = errors.New("expected only 1 resource marker")
	ErrAssociateResourceMarker = errors.New("unable to associate resource marker with field marker")
)
View Source
var (
	ErrMismatchedMarkerTypes            = errors.New("resource marker and field marker have mismatched types")
	ErrResourceMarkerUnknownValueType   = errors.New("resource marker 'value' is of unknown type")
	ErrResourceMarkerMissingFieldValue  = errors.New("resource marker missing 'collectionField', 'field' or 'value'")
	ErrResourceMarkerMissingInclude     = errors.New("resource marker missing 'include' value")
	ErrResourceMarkerMissingFieldMarker = errors.New("resource marker has no associated 'field' or 'collectionField' marker")
	ErrFieldMarkerInvalidType           = errors.New("field marker type is invalid")
)
View Source
var (
	ErrConvertArrayInterface     = errors.New("unable to convert to []interface{}")
	ErrConvertArrayString        = errors.New("unable to convert to []string")
	ErrConvertMapStringInterface = errors.New("unable to convert to map[string]interface{}")
	ErrConvertString             = errors.New("unable to convert to string")
)
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")
View Source
var ErrUnableToParseFieldType = errors.New("unable to parse field")

Functions

func CloseFile

func CloseFile(file io.ReadCloser)

CloseFile safely closes a file handle.

func Glob added in v0.5.0

func Glob(pattern string) ([]string, error)

Glob adds double-star support to the core path/filepath Glob function. It's useful when your globs might have double-stars, but you're not sure.

func InitializeMarkerInspector

func InitializeMarkerInspector(markerTypes ...MarkerType) (*inspect.Inspector, error)

func ReadStream

func ReadStream(fileName string) (io.ReadCloser, error)

func TransformYAML

func TransformYAML(results ...*inspect.YAMLResult) error

func WriteConfig added in v0.6.0

func WriteConfig(options *InitConfigOptions) error

Types

type APIFields added in v0.4.0

type APIFields struct {
	Name       string
	StructName string

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

func (*APIFields) AddField added in v0.4.0

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

func (*APIFields) GenerateAPISpec added in v0.4.0

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

func (*APIFields) GenerateSampleSpec added in v0.4.0

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

type ChildResource

type ChildResource struct {
	Name          string
	UniqueName    string
	Group         string
	Version       string
	Kind          string
	StaticContent string
	SourceCode    string
	IncludeCode   string
}

ChildResource contains attributes for resources created by the custom resource. These definitions are inferred from the resource manifests.

type CliCommand

type CliCommand struct {
	Name          string
	Description   string
	VarName       string `json:"-" yaml:"-" validate:"omitempty"`
	FileName      string `json:"-" yaml:"-" validate:"omitempty"`
	IsSubcommand  bool   `json:"-" yaml:"-" validate:"omitempty"`
	IsRootcommand bool   `json:"-" yaml:"-" validate:"omitempty"`
}

CliCommand defines the command name and description for the root command or subcommand of a companion CLI.

func (*CliCommand) GetSubCmdRelativeFileName added in v0.5.0

func (cli *CliCommand) GetSubCmdRelativeFileName(
	rootCmdName string,
	subCommandFolder string,
	group string,
	fileName string,
) string

GetSubCmdRelativeFileName will generate a path for a subcommand CLI file that is relative to the root of the repository.

func (*CliCommand) SetDefaults added in v0.6.0

func (cli *CliCommand) SetDefaults(workload WorkloadAPIBuilder, isSubcommand bool)

type CollectionFieldMarker

type CollectionFieldMarker FieldMarker

func (CollectionFieldMarker) String added in v0.4.0

func (cfm CollectionFieldMarker) String() 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 added in v0.6.0

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

func (*ComponentWorkload) GetAPIGroup

func (c *ComponentWorkload) GetAPIGroup() string

func (*ComponentWorkload) GetAPIKind

func (c *ComponentWorkload) GetAPIKind() string

func (*ComponentWorkload) GetAPISpec added in v0.6.0

func (c *ComponentWorkload) GetAPISpec() WorkloadAPISpec

func (*ComponentWorkload) GetAPISpecFields

func (c *ComponentWorkload) GetAPISpecFields() *APIFields

func (*ComponentWorkload) GetAPIVersion

func (c *ComponentWorkload) GetAPIVersion() string

func (*ComponentWorkload) GetCollection added in v0.5.0

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 added in v0.3.0

func (c *ComponentWorkload) GetDomain() string

methods that implement WorkloadAPIBuilder.

func (*ComponentWorkload) GetFuncNames

func (c *ComponentWorkload) GetFuncNames() (createFuncNames, initFuncNames []string)

func (*ComponentWorkload) GetName

func (c *ComponentWorkload) GetName() string

func (*ComponentWorkload) GetPackageName

func (c *ComponentWorkload) GetPackageName() string

func (*ComponentWorkload) GetRBACRules

func (c *ComponentWorkload) GetRBACRules() *[]RBACRule

func (*ComponentWorkload) GetRootCommand added in v0.5.0

func (c *ComponentWorkload) GetRootCommand() *CliCommand

func (*ComponentWorkload) GetSourceFiles

func (c *ComponentWorkload) GetSourceFiles() *[]SourceFile

func (*ComponentWorkload) GetSubCommand added in v0.5.0

func (c *ComponentWorkload) GetSubCommand() *CliCommand

func (*ComponentWorkload) GetWorkloadKind

func (c *ComponentWorkload) GetWorkloadKind() WorkloadKind

func (*ComponentWorkload) HasChildResources

func (c *ComponentWorkload) HasChildResources() bool

func (*ComponentWorkload) HasRootCmdName added in v0.6.0

func (c *ComponentWorkload) HasRootCmdName() bool

func (*ComponentWorkload) HasSubCmdDescription added in v0.3.0

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 added in v0.4.0

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 added in v0.6.0

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    CliCommand           `json:"companionCliSubcmd" yaml:"companionCliSubcmd" validate:"omitempty"`
	CompanionCliRootcmd   CliCommand           `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 FieldMarker

type FieldMarker struct {
	Name        string
	Type        FieldType
	Description *string
	Default     interface{} `marker:",optional"`
	Replace     *string
	// contains filtered or unexported fields
}

func (FieldMarker) String

func (fm FieldMarker) String() string

type FieldType

type FieldType int
const (
	FieldUnknownType FieldType = iota
	FieldString
	FieldInt
	FieldBool
	FieldStruct
)

func (FieldType) String

func (f FieldType) String() string

func (*FieldType) UnmarshalMarkerArg

func (f *FieldType) UnmarshalMarkerArg(in string) error

type InitConfigOptions added in v0.6.0

type InitConfigOptions struct {
	Path           string
	Force          bool
	WorkloadConfig WorkloadInitializer
}

type MarkerType added in v0.4.0

type MarkerType int
const (
	FieldMarkerType MarkerType = iota
	CollectionMarkerType
	ResourceMarkerType
)

type PluginConfig

type PluginConfig struct {
	WorkloadConfigPath string `json:"workloadConfigPath" yaml:"workloadConfigPath"`
	CliRootCommandName string `json:"cliRootCommandName" yaml:"cliRootCommandName"`
}

PluginConfig contains the project config values which are stored in the PROJECT file under plugins.operatorBuilder.

type RBACRoleRule added in v0.6.0

type RBACRoleRule struct {
	Groups    RBACRoleRuleField
	Resources RBACRoleRuleField
	Verbs     RBACRoleRuleField
	URLs      RBACRoleRuleField
}

RBACRoleRule contains the info needed to create the kubebuilder:rbac markers in the controller when a resource that is of a role or clusterrole type is found. This is because the underlying controller needs the same permissions for the role or clusterrole that it is attempting to manage.

type RBACRoleRuleField added in v0.6.0

type RBACRoleRuleField []string

type RBACRule

type RBACRule struct {
	Group    string
	Resource string
	Verbs    []string
	URLs     []string
}

RBACRule contains the info needed to create the kubebuilder:rbac markers in the controller.

func (*RBACRule) ToMarker added in v0.6.0

func (r *RBACRule) ToMarker() string

type RBACRules added in v0.4.0

type RBACRules []RBACRule

func (*RBACRules) AddOrUpdateRoleRules added in v0.6.0

func (rs *RBACRules) AddOrUpdateRoleRules(newRule *RBACRoleRule)

func (*RBACRules) AddOrUpdateRules added in v0.4.0

func (rs *RBACRules) AddOrUpdateRules(newRules ...*RBACRule)

type Resource added in v0.4.0

type Resource struct {
	FileName string `json:",omitempty" yaml:",omitempty" validate:"omitempty"`
	Content  []byte `json:",omitempty" yaml:",omitempty" validate:"omitempty"`
	// contains filtered or unexported fields
}

Resource represents a single input manifest for a given config.

func ResourcesFromFiles added in v0.6.0

func ResourcesFromFiles(resourceFiles []string) []*Resource

func (*Resource) UnmarshalYAML added in v0.4.0

func (r *Resource) UnmarshalYAML(node *yaml.Node) error

type ResourceMarker added in v0.6.0

type ResourceMarker struct {
	Field           *string
	CollectionField *string
	Value           interface{}
	Include         *bool
	// contains filtered or unexported fields
}

func (ResourceMarker) String added in v0.6.0

func (rm ResourceMarker) String() string

type SourceFile

type SourceFile struct {
	Filename  string
	Children  []ChildResource
	HasStatic bool
}

SourceFile represents a golang source code file that contains one or more child resource objects.

type StandaloneWorkload

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

StandaloneWorkload defines a standalone workload.

func NewStandaloneWorkload added in v0.6.0

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

func (*StandaloneWorkload) GetAPIGroup

func (s *StandaloneWorkload) GetAPIGroup() string

func (*StandaloneWorkload) GetAPIKind

func (s *StandaloneWorkload) GetAPIKind() string

func (*StandaloneWorkload) GetAPISpec added in v0.6.0

func (s *StandaloneWorkload) GetAPISpec() WorkloadAPISpec

func (*StandaloneWorkload) GetAPISpecFields

func (s *StandaloneWorkload) GetAPISpecFields() *APIFields

func (*StandaloneWorkload) GetAPIVersion

func (s *StandaloneWorkload) GetAPIVersion() string

func (*StandaloneWorkload) GetCollection added in v0.5.0

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) GetFuncNames

func (s *StandaloneWorkload) GetFuncNames() (createFuncNames, initFuncNames []string)

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() *[]RBACRule

func (*StandaloneWorkload) GetRootCommand added in v0.5.0

func (s *StandaloneWorkload) GetRootCommand() *CliCommand

func (*StandaloneWorkload) GetSourceFiles

func (s *StandaloneWorkload) GetSourceFiles() *[]SourceFile

func (*StandaloneWorkload) GetSubCommand added in v0.5.0

func (s *StandaloneWorkload) GetSubCommand() *CliCommand

func (*StandaloneWorkload) GetWorkloadKind

func (s *StandaloneWorkload) GetWorkloadKind() WorkloadKind

func (*StandaloneWorkload) HasChildResources

func (s *StandaloneWorkload) HasChildResources() bool

func (*StandaloneWorkload) HasRootCmdDescription added in v0.3.0

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 added in v0.4.0

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 added in v0.6.0

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 CliCommand      `json:"companionCliRootcmd" yaml:"companionCliRootcmd" validate:"omitempty"`
	WorkloadSpec        `yaml:",inline"`
}

StandaloneWorkloadSpec defines the attributes for a standalone workload.

type WorkloadAPIBuilder

type WorkloadAPIBuilder interface {
	Validate() error

	IsClusterScoped() bool
	IsStandalone() bool
	IsComponent() bool
	IsCollection() bool

	HasSubCmdName() bool
	HasChildResources() bool

	GetName() string
	GetPackageName() string
	GetDomain() string
	GetAPIGroup() string
	GetAPIVersion() string
	GetAPIKind() string
	GetDependencies() []*ComponentWorkload
	GetCollection() *WorkloadCollection
	GetComponents() []*ComponentWorkload
	GetSourceFiles() *[]SourceFile
	GetAPISpecFields() *APIFields
	GetRBACRules() *[]RBACRule
	GetComponentResource(domain, repo string, clusterScoped bool) *resource.Resource
	GetFuncNames() (createFuncNames, initFuncNames []string)
	GetRootCommand() *CliCommand
	GetSubCommand() *CliCommand

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

	LoadManifests(workloadPath string) error
}

WorkloadAPIBuilder defines the interface that must be implemented by a workload being used to configure API and controller creation.

func ProcessAPIConfig

func ProcessAPIConfig(workloadConfig string) (WorkloadAPIBuilder, error)

type WorkloadAPISpec added in v0.4.0

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 added in v0.6.0

func NewSampleAPISpec() *WorkloadAPISpec

type WorkloadCollection

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

WorkloadCollection defines a workload collection.

func NewWorkloadCollection added in v0.6.0

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

func (*WorkloadCollection) GetAPIGroup

func (c *WorkloadCollection) GetAPIGroup() string

func (*WorkloadCollection) GetAPIKind

func (c *WorkloadCollection) GetAPIKind() string

func (*WorkloadCollection) GetAPISpec added in v0.6.0

func (c *WorkloadCollection) GetAPISpec() WorkloadAPISpec

func (*WorkloadCollection) GetAPISpecFields

func (c *WorkloadCollection) GetAPISpecFields() *APIFields

func (*WorkloadCollection) GetAPIVersion

func (c *WorkloadCollection) GetAPIVersion() string

func (*WorkloadCollection) GetCollection added in v0.5.0

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) GetFuncNames

func (c *WorkloadCollection) GetFuncNames() (createFuncNames, initFuncNames []string)

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() *[]RBACRule

func (*WorkloadCollection) GetRootCommand added in v0.5.0

func (c *WorkloadCollection) GetRootCommand() *CliCommand

func (*WorkloadCollection) GetSourceFiles

func (c *WorkloadCollection) GetSourceFiles() *[]SourceFile

func (*WorkloadCollection) GetSubCommand added in v0.5.0

func (c *WorkloadCollection) GetSubCommand() *CliCommand

func (*WorkloadCollection) GetWorkloadKind

func (c *WorkloadCollection) GetWorkloadKind() WorkloadKind

func (*WorkloadCollection) HasChildResources

func (c *WorkloadCollection) HasChildResources() bool

func (*WorkloadCollection) HasRootCmdDescription added in v0.3.0

func (c *WorkloadCollection) HasRootCmdDescription() bool

func (*WorkloadCollection) HasRootCmdName

func (c *WorkloadCollection) HasRootCmdName() bool

func (*WorkloadCollection) HasSubCmdDescription added in v0.3.0

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 added in v0.4.0

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 added in v0.6.0

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 CliCommand           `json:"companionCliRootcmd,omitempty" yaml:"companionCliRootcmd,omitempty" validate:"omitempty"`
	CompanionCliSubcmd  CliCommand           `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 WorkloadIdentifier

type WorkloadIdentifier interface {
	GetName() string
	GetWorkloadKind() WorkloadKind
}

WorkloadIdentifier defines an interface for identifying any workload.

type WorkloadInitializer

type WorkloadInitializer interface {
	Validate() error

	HasRootCmdName() bool

	GetDomain() string
	GetRootCommand() *CliCommand
	GetWorkloadKind() WorkloadKind

	SetNames()

	IsCollection() bool
}

WorkloadInitializer defines the interface that must be implemented by a workload being used to configure project initialization.

func ProcessInitConfig

func ProcessInitConfig(workloadConfig string) (WorkloadInitializer, error)

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 added in v0.4.0

func (wk WorkloadKind) String() string

func (*WorkloadKind) UnmarshalJSON added in v0.4.0

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

func (*WorkloadKind) UnmarshalYAML added in v0.4.0

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 added in v0.4.0

type WorkloadSpec struct {
	Resources              []*Resource              `json:"resources" yaml:"resources"`
	FieldMarkers           []*FieldMarker           `json:",omitempty" yaml:",omitempty" validate:"omitempty"`
	CollectionFieldMarkers []*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"`
	SourceFiles            *[]SourceFile            `json:",omitempty" yaml:",omitempty" validate:"omitempty"`
	RBACRules              *RBACRules               `json:",omitempty" yaml:",omitempty" validate:"omitempty"`
}

WorkloadSpec contains information required to generate source code.

Jump to

Keyboard shortcuts

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