model

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2023 License: Apache-2.0 Imports: 15 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// function for determining the relative path of generated api types package
	TypesRelativePath = func(kind, version string) string {
		return fmt.Sprintf("pkg/apis/%v/%v", strings.ToLower(stringutils.Pluralize(kind)), version)
	}

	// function for determining the relative path of generated schduler package
	SchedulerRelativePath = "pkg/scheduler"

	// function for determining the relative path of generated finalizer package
	FinalizerRelativePath = "pkg/finalizer"

	// function for determining the relative path of generated parameters package
	ParametersRelativePath = "pkg/parameters"

	// function for determining the relative path of generated metrics package
	MetricsRelativePath = "pkg/metrics"
)

Functions

This section is empty.

Types

type Build

type Build struct {
	// path to the main.go file
	MainFile string

	// push image after  build
	Push bool

	Image
}

type Chart

type Chart struct {
	Operators []Operator

	// filter out the template based on its output name
	FilterTemplate func(outPath string) bool

	// outPath: content template map
	CustomTemplates CustomTemplates

	Values interface{}

	// goes into the chart.yaml
	Data Data

	// inline string of custom _helpers.tpl which can be provided for the generated chart
	HelpersTpl string

	// Only generate the chart
	ChartOnly bool

	// if specified, generate reference docs for the chart values to the provided filename
	ValuesReferenceDocs ValuesReferenceDocs

	// if specificed, generate inline documentation for the values in chart's values.yaml files
	ValuesInlineDocs *ValuesInlineDocs

	// if specificed, values.schema.json will be generated with a JSON Schema that
	// imposes structure on the values.yaml file
	JsonSchema *JsonSchema
}

func (Chart) BuildChartValues added in v0.7.17

func (c Chart) BuildChartValues() values.UserHelmValues

func (Chart) GenerateHelmDoc added in v0.7.17

func (c Chart) GenerateHelmDoc() string

type Container added in v0.18.0

type Container struct {
	// not configurable via helm values
	Args           []string
	VolumeMounts   []v1.VolumeMount
	ReadinessProbe *v1.Probe
	LivenessProbe  *v1.Probe

	Image           Image
	Env             []v1.EnvVar
	Resources       *v1.ResourceRequirements
	SecurityContext *v1.SecurityContext
}

values for a container

type CustomTemplates

type CustomTemplates struct {
	// the custom templates to run generation on.
	// maps output filename to template text
	Templates map[string]string

	// Enable to add //go:generate mockgen directive to the top of generated Go files.
	MockgenDirective bool

	// custom template funcs which will be inserted into the
	// default template funcmap at rendering time
	Funcs template.FuncMap
}

type Data

type Data struct {
	ApiVersion   string       `json:"apiVersion,omitempty"`
	Description  string       `json:"description,omitempty"`
	Name         string       `json:"name,omitempty"`
	Version      string       `json:"version,omitempty"`
	Home         string       `json:"home,omitempty"`
	Icon         string       `json:"icon,omitempty"`
	Sources      []string     `json:"sources,omitempty"`
	Dependencies []Dependency `json:"dependencies,omitempty"`
}

type Dependency

type Dependency struct {
	Name       string `json:"name,omitempty"`
	Version    string `json:"version,omitempty"`
	Repository string `json:"repository,omitempty"`
	Condition  string `json:"condition,omitempty"`
	Alias      string `json:"alias,omitempty"`
}

Helm chart dependency

type Deployment

type Deployment struct {
	// TODO support use of a DaemonSet instead of a Deployment
	UseDaemonSet bool
	Container
	Sidecars                    []Sidecar
	Volumes                     []v1.Volume
	CustomPodLabels             map[string]string
	CustomPodAnnotations        map[string]string
	CustomDeploymentLabels      map[string]string
	CustomDeploymentAnnotations map[string]string
}

values for Deployment template

type Field

type Field struct {
	Type Type
}

type GeneratorType

type GeneratorType string
const (
	GeneratorType_Deepcopy  GeneratorType = "deepcopy"
	GeneratorType_Defaulter GeneratorType = "defaulter"
	GeneratorType_Client    GeneratorType = "client"
	GeneratorType_Lister    GeneratorType = "lister"
	GeneratorType_Informer  GeneratorType = "informer"
	GeneratorType_All       GeneratorType = "all"
)

type GeneratorTypes

type GeneratorTypes []GeneratorType

func (GeneratorTypes) HasDeepcopy

func (g GeneratorTypes) HasDeepcopy() bool

returns true if the 'deepcopy' or 'all' generator is present

func (GeneratorTypes) Strings

func (g GeneratorTypes) Strings() []string

type Group

type Group struct {
	// the group version of the group
	schema.GroupVersion

	// the go  module this group belongs to
	Module string

	// the root directory for generated API code
	ApiRoot string

	// the kinds in the group
	Resources []Resource

	// Should we generate kubernetes manifests?
	RenderManifests bool

	// Should we add the chart version to the generated manifests?
	AddChartVersion string

	// Should we not add the spec hash to the annotation of the generated manifests?
	SkipSpecHash bool

	// Should we generate validating schemas for CRDs?
	RenderValidationSchemas bool

	// Should we exclude descriptions in the validation schemas?
	// Set this to true to make the CRD size smaller.
	SkipSchemaDescriptions bool

	// Should we generate deepcopy functions for non-proto Spec/Status fields?
	RenderFieldJsonDeepcopy bool

	// Should we generate kubernetes Go structs?
	RenderTypes bool

	// Should we generate kubernetes Go clients?
	RenderClients bool

	// Deprecated: use generated deepcopy methods instead
	// Should we run kubernetes code generators? (see https://github.com/kubernetes/code-generator/blob/master/generate-groups.sh)
	// Note: if this field is nil and RenderTypes is true,
	// skv2 will run the 'deepcopy' generator by default.
	Generators GeneratorTypes

	// Should we generate kubernetes Go controllers?
	RenderController bool

	// Enable to add //go:generate mockgen directive to the top of generated Go files.
	MockgenDirective bool

	// custom import path to the package
	// containing the Go types
	// use this if you are generating controllers
	// for types in an external project
	CustomTypesImportPath string

	// proto descriptors will be available to the templates if the group was compiled with them.
	Descriptors []*collector.DescriptorWithPath

	// data for providing custom templates to generate custom code for groups
	CustomTemplates []CustomTemplates

	// Mapping from protobuf message name to generated open api structural schema
	// This is populated during skv2 generation by the manifests renderer.
	OpenApiSchemas OpenApiSchemas

	// Custom properties used for custom templates
	Properties

	// Some resources use pointer slices for the Items field.
	PointerSlices bool `default:"false"`
}

func (Group) HasProtos

func (g Group) HasProtos() bool

func (*Group) Init

func (g *Group) Init()

ensures the resources point to this group

func (*Group) InitDescriptors added in v0.22.1

func (g *Group) InitDescriptors(descriptors []*collector.DescriptorWithPath)

type GroupOptions added in v0.28.0

type GroupOptions struct {
	// Required when using crds in the templates directory
	EscapeGoTemplateOperators bool
}

type Image

type Image = values.Image

type JsonSchema added in v0.28.0

type JsonSchema struct {
	// (Optional) will be called to override the default json schema mapping
	// for the type. This is useful for types that also override default json/yaml
	// serialization behaviour. It accepts the json schema as a map and is
	// expected to return a value that can serialize to the json schema or null if
	// there is no custom mapping for this type
	CustomTypeMapper func(reflect.Type, map[string]interface{}) interface{}
}

type OpenApiSchemas added in v0.7.17

type OpenApiSchemas map[string]*apiextv1.JSONSchemaProps

Mapping from protobuf message name to OpenApi schema

type Operator

type Operator struct {
	Name string

	// (Optional) To change the name referenced in the values file. If not specified a camelcase version of name is used
	ValuesFileNameOverride string

	// (Optional) For nesting operators in values API (e.g. a value of "agent" would place an operator at "agent.<operatorName>" )
	ValuePath string

	// deployment config
	Deployment Deployment

	// these populate the generated ClusterRole for the operator
	Rbac []rbacv1.PolicyRule

	// if at least one port is defined, create a Service for it
	Service Service

	// Custom values to include at operator level
	Values interface{}

	// (Optional) If this operator depends on another operator being enabled,
	// the name of the other operator can be included in this list. This operator
	// will not be provisioned unless both are enabled (by having values.enabled = true)
	EnabledDependsOn []string
}

func (Operator) FormattedName added in v0.29.2

func (o Operator) FormattedName() string

type Properties added in v0.22.1

type Properties map[string]string

Properties is an arbitrary set of KV properties which can be associated to an skv2 resource. Can be used in conjunction with custom templates

func (Properties) Property added in v0.22.1

func (p Properties) Property(key string) string

type Resource

type Resource struct {
	*Group // the group I belong to
	Kind   string
	Spec   Field
	Status *Field

	// Whether or not the resource is cluster-scoped.
	// This is important when rendering the CustomResourceDefinition manifest.
	ClusterScoped bool

	// Set the short name of the resource
	ShortNames []string

	// Set the categories of the resource
	Categories []string

	// The set of additional printer columns to apply to the CustomResourceDefinition
	AdditionalPrinterColumns []apiextv1.CustomResourceColumnDefinition

	// If enabled, the unmarshal will NOT allow unknown fields.
	StrictUnmarshal bool
}

type Service

type Service struct {
	Type              v1.ServiceType
	Ports             []ServicePort
	CustomLabels      map[string]string
	CustomAnnotations map[string]string
}

values for struct template

type ServicePort

type ServicePort struct {
	// The name of this port within the service.
	Name string `json:"name,omitempty" protobuf:"bytes,1,opt,name=name" desc:"The name of this port within the service."`

	// The default port that will be exposed by this service.
	DefaultPort int32 `json:"port" protobuf:"varint,3,opt,name=port" desc:"The default port that will be exposed by this service."`
}

type Sidecar added in v0.18.0

type Sidecar struct {
	Container
	Name string
}

sidecars require a container config and a unique name

type Type

type Type struct {
	// name of the type.
	Name string

	// proto message for the type, if the proto message is compiled with skv2
	Message proto.Message

	/*

		The go package containing the type, if different than group root api directory (where the resource itself lives).
		Will be set automatically for proto-based types.

		If unset, SKv2 uses the default types package for the type.
	*/
	GoPackage string

	/*
		The proto package containing the type, if different than the Group name of the Resource.
		If unset, SKv2 uses the Group name of the Resource that specifies this Type.
	*/
	ProtoPackage string
}

type ValuesInlineDocs added in v0.28.0

type ValuesInlineDocs struct {
	// if specified, inline field documentation comments will be wrapped at many characters
	LineLengthLimit int
}

type ValuesReferenceDocs added in v0.22.1

type ValuesReferenceDocs struct {
	Title    string
	Filename string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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