model

package
v0.38.2 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: Apache-2.0 Imports: 17 Imported by: 11

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

type ConditionalVolume struct {
	Condition string
	Volume    corev1.Volume
}

type ConditionalVolumeMount added in v0.34.9

type ConditionalVolumeMount struct {
	Condition   string
	VolumeMount corev1.VolumeMount
}

type Container added in v0.18.0

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

	Image           Image
	Env             []corev1.EnvVar
	Resources       *corev1.ResourceRequirements
	SecurityContext *corev1.SecurityContext
	ContainerPorts  []ContainerPort

	// TemplateEnvVars renders environment variables that can use templated Helm values.
	// At least 1 environment variable must be set via Env to use this.
	TemplateEnvVars []TemplateEnvVar
}

values for a container

type ContainerPort added in v0.34.1

type ContainerPort struct {
	Name string
	Port string
}

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
	Strategy                    *appsv1.DeploymentStrategy
	Sidecars                    []Sidecar
	PodSecurityContext          *corev1.PodSecurityContext
	Volumes                     []corev1.Volume
	ConditionalVolumes          []ConditionalVolume
	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"`

	// Set to true to skip rendering of conditional loading logic
	// for CRDs containing alpha-versioned resources.
	// Used by codegen/templates/manifests/crd.yamltmpl
	SkipConditionalCRDLoading bool

	// Skip generation of crd manifests that live in crd/ directory of a chart
	SkipCRDManifest bool

	// Skip generation of templated crd manifests that live in templates/ dir of a chart
	SkipTemplatedCRDManifest bool
}

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

	// Options for generating validation schemas
	SchemaValidationOpts schemagen.ValidationSchemaOptions

	SchemaGenerator schemagen.GeneratorKind
}

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
	ClusterRbac []rbacv1.PolicyRule

	// these populate the generated Role for the operator
	// key should be the k8s resource name (lower-case, plural version)
	NamespaceRbac map[string][]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 should be applied to a namespace
	// specified in a common value (e.g. "$Values.common.addonNamespace") specify the full value path here
	NamespaceFromValuePath string

	// Optional: if specified, the operator resources will be abled based on the
	// condition specified in the enable statement.
	//
	// E.g: `and (.Values.operator.customValueA) (.Values.operator.customValueB)`
	CustomEnableCondition 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 ReadinessProbe added in v0.34.0

type ReadinessProbe struct {
	Exec                []string // optional: if specified, the readiness probe will be an exec probe with the specified commands
	Path                string   // Path to access on the HTTP server. Either specify Path and Port for httpGet probes, or specify Exec
	Port                string
	Scheme              string // optional scheme: HTTP or HTTPS ((kasunt): imo better to keep it as a non-enum field)
	PeriodSeconds       int
	InitialDelaySeconds int
}

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 and RBAC policies.
	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

	// Corresponds to CRD's versions.storage field
	// Only one version of a resource can be marked as "stored"
	// Set to false by default
	// See https://kubernetes.io/docs/reference/kubernetes-api/extend-resources/custom-resource-definition-v1/#CustomResourceDefinitionSpec
	Stored bool

	// Corresponds to CRD's versions.deprecated field
	// Set to false by default
	// See https://kubernetes.io/docs/reference/kubernetes-api/extend-resources/custom-resource-definition-v1/#CustomResourceDefinitionSpec
	Deprecated bool

	// Optional: if specified, this crd resource definition will be wrapped in the given conditional
	//
	// E.g: `and (.Values.customValueA) (.Values.customValueB)`
	CustomEnableCondition string

	// If the resouce is designated as codegen-only, it will not be rendered in the CRD manifest or included in snapshot generation.
	CodegenOnly bool
}

type Service

type Service struct {
	Type              corev1.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
	Service
	ClusterRbac     []rbacv1.PolicyRule
	NamespaceRbac   map[string][]rbacv1.PolicyRule
	Volumes         []corev1.Volume
	Name            string
	EnableStatement string `json:"enableStatement,omitempty" yaml:"enableStatement,omitempty"` // Optional: if specified, the operator resources will be abled based on the condition specified in the enable statement.
	ValuesPath      string `json:"valuesPath,omitempty" yaml:"valuesPath,omitempty"`           // Override for values path in generated yaml.
}

sidecars require a container config and a unique name

type TemplateEnvVar added in v0.34.8

type TemplateEnvVar struct {
	// Condition for this environment variable to be rendered
	// E.g. `and (.Values.operator.customValueA) (.Values.operator.customValueB)`
	Condition string

	// Name of the environment variable
	// E.g. FOO_BAR
	Name string

	// Helm value
	// E.g. {{ .Values.foo.bar }}
	Value string
}

TemplateEnvVar corresponds to an environment variable that can use templated Helm values

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