v1alpha1

package
v0.99.3 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package v1alpha1 defines the api boundary between CUE and Holos.

Index

Constants

View Source
const (
	APIVersion    = "holos.run/v1alpha1"
	BuildPlanKind = "BuildPlan"
	HelmChartKind = "HelmChart"
	// ChartDir is the directory name created in the holos component directory to cache a chart.
	ChartDir = "vendor"
	// ResourcesFile is the file name used to store component output when post-processing with kustomize.
	ResourcesFile = "resources.yaml"
)
View Source
const KubernetesObjectsKind = "KubernetesObjects"
View Source
const KustomizeBuildKind = "KustomizeBuild"

Variables

This section is empty.

Functions

This section is empty.

Types

type APIObjectMap

type APIObjectMap map[Kind]map[Label]string

APIObjectMap is the shape of marshalled api objects returned from cue to the holos cli. A map is used to improve the clarity of error messages from cue.

type BuildPlan

type BuildPlan struct {
	TypeMeta `json:",inline" yaml:",inline"`
	// Metadata represents the holos component name
	Metadata ObjectMeta    `json:"metadata,omitempty" yaml:"metadata,omitempty"`
	Spec     BuildPlanSpec `json:"spec,omitempty" yaml:"spec,omitempty"`
}

BuildPlan is the primary interface between CUE and the Holos cli.

func (*BuildPlan) ResultCapacity

func (bp *BuildPlan) ResultCapacity() (count int)

func (*BuildPlan) Validate

func (bp *BuildPlan) Validate() error

type BuildPlanComponents

type BuildPlanComponents struct {
	HelmChartList         []HelmChart                  `json:"helmChartList,omitempty" yaml:"helmChartList,omitempty"`
	KubernetesObjectsList []KubernetesObjects          `json:"kubernetesObjectsList,omitempty" yaml:"kubernetesObjectsList,omitempty"`
	KustomizeBuildList    []KustomizeBuild             `json:"kustomizeBuildList,omitempty" yaml:"kustomizeBuildList,omitempty"`
	Resources             map[string]KubernetesObjects `json:"resources,omitempty" yaml:"resources,omitempty"`
}

type BuildPlanSpec

type BuildPlanSpec struct {
	Disabled   bool                `json:"disabled,omitempty" yaml:"disabled,omitempty"`
	Components BuildPlanComponents `json:"components,omitempty" yaml:"components,omitempty"`
	// DeployFiles keys represent file paths relative to the cluster deploy
	// directory.  Map values represent the string encoded file contents.  Used to
	// write the argocd Application, but may be used to render any file from CUE.
	DeployFiles FileContentMap `json:"deployFiles,omitempty" yaml:"deployFiles,omitempty"`
}

type Chart

type Chart struct {
	Name       string     `json:"name"`
	Version    string     `json:"version"`
	Release    string     `json:"release"`
	Repository Repository `json:"repository,omitempty"`
}

type Discriminator

type Discriminator interface {
	GetKind() string
	GetAPIVersion() string
}

Discriminator is an interface to discriminate the kind api object.

type FileContentMap

type FileContentMap map[string]string

FileContentMap is a map of file names to file contents.

type Form

type Form struct {
	TypeMeta `json:",inline" yaml:",inline"`
	Spec     FormSpec `json:"spec" yaml:"spec"`
}

Form represents a collection of Formly json powered form.

type FormSpec

type FormSpec struct {
	Form object.Form `json:"form" yaml:"form"`
}

type HelmChart

type HelmChart struct {
	HolosComponent `json:",inline" yaml:",inline"`
	// Namespace is the namespace to install into.  TODO: Use metadata.namespace instead.
	Namespace     string `json:"namespace"`
	Chart         Chart  `json:"chart"`
	ValuesContent string `json:"valuesContent"`
	EnableHooks   bool   `json:"enableHooks"`
}

A HelmChart represents a helm command to provide chart values in order to render kubernetes api objects.

func (*HelmChart) Render

func (hc *HelmChart) Render(ctx context.Context, path holos.InstancePath) (*Result, error)

type HolosComponent

type HolosComponent struct {
	TypeMeta `json:",inline" yaml:",inline"`
	// Metadata represents the holos component name
	Metadata ObjectMeta `json:"metadata,omitempty" yaml:"metadata,omitempty"`
	// APIObjectMap holds the marshalled representation of api objects. Think of
	// these as resources overlaid at the back of the render pipeline.
	APIObjectMap APIObjectMap `json:"apiObjectMap,omitempty" yaml:"apiObjectMap,omitempty"`
	// Kustomization holds the marshalled representation of the flux kustomization
	// which reconciles resources in git with the api server.
	Kustomization `json:",inline" yaml:",inline"`
	// Kustomize represents a kubectl kustomize build post-processing step.
	Kustomize `json:",inline" yaml:",inline"`
	// Skip causes holos to take no action regarding the component.
	Skip bool
}

HolosComponent defines the fields common to all holos component kinds including the Render Result.

func (*HolosComponent) GetAPIVersion

func (hc *HolosComponent) GetAPIVersion() string

func (*HolosComponent) GetKind

func (hc *HolosComponent) GetKind() string

func (*HolosComponent) NewResult

func (hc *HolosComponent) NewResult() *Result

type Kind

type Kind string

Kind is a kubernetes api object kind. Defined as a type for clarity and type checking.

type KubernetesObjects

type KubernetesObjects struct {
	HolosComponent `json:",inline" yaml:",inline"`
}

KubernetesObjects represents CUE output which directly provides Kubernetes api objects to holos.

func (*KubernetesObjects) Render

func (o *KubernetesObjects) Render(ctx context.Context, path holos.InstancePath) (*Result, error)

Render produces kubernetes api objects from the APIObjectMap

type Kustomization

type Kustomization struct {
	// KsContent is the yaml representation of the flux kustomization for gitops.
	KsContent string `json:"ksContent,omitempty" yaml:"ksContent,omitempty"`
}

Kustomization holds the rendered flux kustomization api object content for git ops.

type Kustomize

type Kustomize struct {
	// KustomizeFiles holds file contents for kustomize, e.g. patch files.
	KustomizeFiles FileContentMap `json:"kustomizeFiles,omitempty" yaml:"kustomizeFiles,omitempty"`
	// ResourcesFile is the file name used for api objects in kustomization.yaml
	ResourcesFile string `json:"resourcesFile,omitempty" yaml:"resourcesFile,omitempty"`
}

Kustomize represents resources necessary to execute a kustomize build. Intended for at least two use cases:

  1. Process raw yaml file resources in a holos component directory.
  2. Post process a HelmChart to inject istio, add custom labels, etc...

type KustomizeBuild

type KustomizeBuild struct {
	HolosComponent `json:",inline" yaml:",inline"`
}

KustomizeBuild renders plain yaml files in the holos component directory using kubectl kustomize build.

func (*KustomizeBuild) Render

func (kb *KustomizeBuild) Render(ctx context.Context, path holos.InstancePath) (*Result, error)

Render produces a Result by executing kubectl kustomize on the holos component path. Useful for processing raw yaml files.

type Label

type Label string

Label is an arbitrary unique identifier. Defined as a type for clarity and type checking.

type ObjectMeta

type ObjectMeta struct {
	// Name uniquely identifies the holos component instance and must be suitable as a file name.
	Name string `json:"name,omitempty" yaml:"name,omitempty"`
	// Namespace confines a holos component to a single namespace via kustomize if set.
	Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"`
	// Labels are not used but are copied from api machinery ObjectMeta for completeness.
	Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
	// Annotations are not used but are copied from api machinery ObjectMeta for completeness.
	Annotations map[string]string `json:"annotations,omitempty" yaml:"annotations,omitempty"`
}

ObjectMeta represents metadata of a holos component object. The fields are a copy of upstream kubernetes api machinery but are by holos objects distinct from kubernetes api objects.

type Platform

type Platform struct {
	TypeMeta `json:",inline" yaml:",inline"`
	Metadata ObjectMeta   `json:"metadata" yaml:"metadata"`
	Spec     PlatformSpec `json:"spec" yaml:"spec"`
}

Platform represents a platform to manage. A Platform resource informs holos which components to build. The platform resource also acts as a container for the platform model form values provided by the PlatformService. The primary use case is to collect the cluster names, cluster types, platform model, and holos components to build into one resource.

type PlatformSpec

type PlatformSpec struct {
	// Model represents the platform model holos gets from from the
	// holos.platform.v1alpha1.PlatformService.GetPlatform method and provides to
	// CUE using a tag.
	Model      structpb.Struct         `json:"model" yaml:"model"`
	Components []PlatformSpecComponent `json:"components" yaml:"components"`
}

PlatformSpec represents the platform build plan specification.

type PlatformSpecComponent

type PlatformSpecComponent struct {
	// Path is the path of the component relative to the platform root.
	Path string `json:"path" yaml:"path"`
	// Cluster is the cluster name to use when building the component.
	Cluster string `json:"cluster" yaml:"cluster"`
}

PlatformSpecComponent represents a component to build or render with flags to pass, for example the cluster name.

type Renderer

type Renderer interface {
	GetKind() string
	Render(ctx context.Context, path holos.InstancePath) (*Result, error)
}

type Repository

type Repository struct {
	Name string `json:"name"`
	URL  string `json:"url"`
}

type Result

type Result struct {
	HolosComponent

	// DeployFiles keys represent file paths relative to the cluster deploy
	// directory.  Map values represent the string encoded file contents.  Used to
	// write the argocd Application, but may be used to render any file from CUE.
	DeployFiles FileContentMap `json:"deployFiles,omitempty" yaml:"deployFiles,omitempty"`
	// contains filtered or unexported fields
}

Result is the build result for display or writing. Holos components Render the Result as a data pipeline.

func Render

func Render(ctx context.Context, r Renderer, path holos.InstancePath) (*Result, error)

Render produces a Result representing the kubernetes api objects to configure. Each of the various holos component types, e.g. Helm, Kustomize, et al, should implement the Renderer interface. This process is best conceptualized as a data pipeline, for example a component may render a result by first calling helm template, then passing the result through kustomize, then mixing in overlay api objects.

func (*Result) AccumulatedOutput

func (r *Result) AccumulatedOutput() string

AccumulatedOutput returns the accumulated rendered output.

func (*Result) Continue

func (r *Result) Continue() bool

Continue returns true if Skip is true indicating the result is to be skipped over.

func (*Result) Filename

func (r *Result) Filename(writeTo string, cluster string) string

func (*Result) KustomizationFilename

func (r *Result) KustomizationFilename(writeTo string, cluster string) string

func (*Result) Name

func (r *Result) Name() string

func (*Result) Save

func (r *Result) Save(ctx context.Context, path string, content string) error

Save writes the content to the filesystem for git ops.

func (*Result) WriteDeployFiles

func (r *Result) WriteDeployFiles(ctx context.Context, path string) error

type TypeMeta

type TypeMeta struct {
	Kind       string `json:"kind,omitempty" yaml:"kind,omitempty"`
	APIVersion string `json:"apiVersion,omitempty" yaml:"apiVersion,omitempty"`
}

func (*TypeMeta) GetAPIVersion

func (tm *TypeMeta) GetAPIVersion() string

func (*TypeMeta) GetKind

func (tm *TypeMeta) GetKind() string

Jump to

Keyboard shortcuts

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