course

package
v1.4.1-0...-109f576 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SchemaValidationError error = errors.New("Course file has schema validation errors")
	ParseEnv              bool  = true
)

Functions

This section is empty.

Types

type ArgoApplication

type ArgoApplication struct {
	Kind       string                  `yaml:"kind"`
	APIVersion string                  `yaml:"apiVersion"`
	Metadata   ArgoApplicationMetadata `yaml:"metadata"`
	Spec       ArgoApplicationSpec     `yaml:"spec"`
}

type ArgoApplicationMetadata

type ArgoApplicationMetadata struct {
	Name        string            `yaml:"name"`
	Namespace   string            `yaml:"namespace,omitempty"`
	Annotations map[string]string `yaml:"annotations,omitempty"`
	Labels      map[string]string `yaml:"labels,omitempty"`
}

ArgoApplicationMetadata contains the k8s metadata for the gitops agent CustomResource. This is the resource/manifest/config the agent will read in, not the resources deployed by the agent.

type ArgoApplicationSpec

type ArgoApplicationSpec struct {
	Source            ArgoApplicationSpecSource       `yaml:"source"`
	Destination       ArgoApplicationSpecDestination  `yaml:"destination"`
	Project           string                          `yaml:"project"`
	SyncPolicy        ArgoApplicationSpecSyncPolicy   `yaml:"syncPolicy,omitempty"`
	IgnoreDifferences []ArgoResourceIgnoreDifferences `yaml:"ignoreDifferences,omitempty"`
}

type ArgoApplicationSpecDestination

type ArgoApplicationSpecDestination struct {
	Server    string `yaml:"server,omitempty"`
	Namespace string `yaml:"namespace,omitempty"`
}

type ArgoApplicationSpecSource

type ArgoApplicationSpecSource struct {
	Directory ArgoApplicationSpecSourceDirectory `yaml:"directory,omitempty"`
	Path      string                             `yaml:"path"`
	RepoURL   string                             `yaml:"repoURL"`
}

type ArgoApplicationSpecSourceDirectory

type ArgoApplicationSpecSourceDirectory struct {
	Recurse bool `yaml:"recurse,omitempty"`
}

type ArgoApplicationSpecSyncPolicy

type ArgoApplicationSpecSyncPolicy struct {
	Automated ArgoApplicationSpecSyncPolicyAutomated `yaml:"automated,omitempty"`
	Options   []string                               `yaml:"syncOptions,omitempty"`
}

type ArgoApplicationSpecSyncPolicyAutomated

type ArgoApplicationSpecSyncPolicyAutomated struct {
	Prune bool `yaml:"prune,omitempty"`
}

type ArgoResourceIgnoreDifferences

type ArgoResourceIgnoreDifferences struct {
	Group             string   `yaml:"group,omitempty"`
	Kind              string   `yaml:"kind"`
	Name              string   `yaml:"name,omitempty"`
	Namespace         string   `yaml:"namespace,omitempty"`
	JSONPointers      []string `yaml:"jsonPointers,omitempty"`
	JQPathExpressions []string `yaml:"jqPathExpressions,omitempty"`
	// ManagedFieldsManagers is a list of trusted managers. Fields mutated by those managers will take precedence over the
	// desired state defined in the SCM and won't be displayed in diffs
	ManagedFieldsManagers []string `yaml:"managedFieldsManagers,omitempty"`
}

ResourceIgnoreDifferences contains resource filter and list of json paths which should be ignored during comparison with live state.

type ChartsListV1

type ChartsListV1 []ReleaseV1

ChartsListV1 is a list of releases which we convert from a map of releases to preserve order

func (*ChartsListV1) UnmarshalYAML

func (cl *ChartsListV1) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML implements the yaml.Unmarshaler interface to customize how we Unmarshal this particular field of the FileV1 struct

type FileV1

type FileV1 struct {
	// DefaultNamespace is the namespace that releases will be installed into if
	// a namespace is not specified on the Release
	DefaultNamespace string `yaml:"namespace" json:"namespace"`
	// DefaultRepository is the default repository that the release will be installed
	// from if one is not specified on the Release
	DefaultRepository string `yaml:"repository" json:"repository"`
	// Context is the kubeconfig context to use when installing
	// if that context is not available, then reckoner should fail
	Context string `yaml:"context" json:"context"`
	// Repositories is a list of helm repositories that can be used to look for charts
	Repositories RepositoryMap `yaml:"repositories" json:"repositories"`
	// MinimumVersions is a block that restricts this course file from being used with
	// outdated versions of helm or reckoner
	MinimumVersions struct {
		Helm     string `yaml:"helm,omitempty" json:"helm,omitempty"`
		Reckoner string `yaml:"reckoner,omitempty" json:"reckoner,omitempty"`
	} `yaml:"minimum_versions,omitempty" json:"minimum_versions,omitempty"`
	// Hooks is a set of scripts to be run before or after the release is installed.
	Hooks Hooks `yaml:"hooks" json:"hooks"`
	// NamespaceMgmt contains the default namespace config for all namespaces managed by this course.
	NamespaceMgmt *NamespaceMgmt `yaml:"namespace_management" json:"namespace_management"`
	Secrets       SecretsList    `yaml:"secrets,omitempty" json:"secrets,omitempty"`
	// Charts is the list of releases. In the actual file this will be a map, but we must convert to a list to preserve order.
	// This conversion is done in the ChartsListV1 UnmarshalYAML function.
	Charts ChartsListV1 `yaml:"charts" json:"charts"`
	// HelmArgs is a list of arguments to pass to helm
	HelmArgs []string `yaml:"helm_args,omitempty" json:"helm_args,omitempty"`
}

FileV1 represents the v1 reckoner course structure for purpsoses of conversion

func OpenCourseV1

func OpenCourseV1(fileName string) (*FileV1, error)

OpenCourseV1 opens a v1 schema course file

func (*FileV1) UnmarshalYAML

func (f *FileV1) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML implements the yaml.Unmarshaler interface for FileV1. This allows us to do environment variable parsing and changing behavior for boolean parsing such that non-quoted `yes`, `no`, `on`, `off` become booleans.

type FileV1Unmarshal

type FileV1Unmarshal FileV1

FileV1Unmarshal is a helper type that allows us to have a custom unmarshal function for the FileV2 struct

type FileV2

type FileV2 struct {
	// SchemaVersion is the version of the reckoner schema
	SchemaVersion string `yaml:"schema,omitempty" json:"schema,omitempty"`
	// DefaultNamespace is the namespace that releases will be installed into if
	// a namespace is not specified on the Release
	DefaultNamespace string `yaml:"namespace,omitempty" json:"namespace,omitempty"`
	// DefaultRepository is the default repository that the release will be installed
	// from if one is not specified on the Release
	DefaultRepository string `yaml:"repository,omitempty" json:"repository,omitempty"`
	// Context is the kubeconfig context to use when installing
	// if that context is not available, then reckoner should fail
	Context string `yaml:"context,omitempty" json:"context,omitempty"`
	// Repositories is a list of helm repositories that can be used to look for charts
	Repositories RepositoryMap `yaml:"repositories,omitempty" json:"repositories,omitempty"`
	// MinimumVersions is a block that restricts this course file from being used with
	// outdated versions of helm or reckoner
	MinimumVersions struct {
		Helm     string `yaml:"helm,omitempty" json:"helm,omitempty"`
		Reckoner string `yaml:"reckoner,omitempty" json:"reckoner,omitempty"`
	} `yaml:"minimum_versions,omitempty" json:"minimum_versions,omitempty"`
	// Hooks is a set of scripts to be run before or after the release is installed.
	Hooks Hooks `yaml:"hooks,omitempty" json:"hooks,omitempty"`
	// NamespaceMgmt contains the default namespace config for all namespaces managed by this course.
	NamespaceMgmt *NamespaceMgmt `yaml:"namespace_management,omitempty" json:"namespace_management,omitempty"`
	Secrets       SecretsList    `yaml:"secrets,omitempty" json:"secrets,omitempty"`
	// Releases is the list of releases that should be maintained by this course file.
	Releases []*Release `yaml:"releases,omitempty" json:"releases,omitempty"`
	// HelmArgs is a list of arguments to pass to helm commands
	HelmArgs []string `yaml:"helm_args,omitempty" json:"helm_args,omitempty"`
	GitOps   GitOps   `yaml:"gitops,omitempty" json:"gitops,omitempty"`
}

FileV2 is the heart of reckoner, it contains the definitions of the releases to be installed as well as all other configuration.

func OpenCourseFile

func OpenCourseFile(fileName string, schema []byte) (*FileV2, error)

OpenCourseFile will attempt to open a V2 Course and if the SchemaVersion is not v2, attempt to open the course file as V1

func OpenCourseV2

func OpenCourseV2(fileName string) (*FileV2, error)

OpenCourseV2 opens a v2 schema course file

func (*FileV2) UnmarshalYAML

func (f *FileV2) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML implements the yaml.Unmarshaler interface for FileV2. This allows us to do environment variable parsing and changing behavior for boolean parsing such that non-quoted `yes`, `no`, `on`, `off` become booleans.

type FileV2Unmarshal

type FileV2Unmarshal FileV2

FileV2Unmarshal is a helper type that allows us to have a custom unmarshal function for the FileV2 struct

type GitOps

type GitOps struct {
	ArgoCD ArgoApplication `yaml:"argocd" json:"argocd"`
}

GitOps is a field on the root of the course.yaml file which instructs reckoner to generate CustomResources appropriate to the configured flavor of gitops agent. For instance, if gitops.argocd is present and complete, ArgoCD Application resources will be generated for each release in the course file with the corresponding values.

type Hooks

type Hooks struct {
	// PreInstall hooks run before the release is installed, but after the namespace is created and labelled/annotated
	PreInstall []string `yaml:"pre_install,omitempty" json:"pre_install,omitempty"`
	// PostInstall hooks run after the release is installed. They are skipped if the release installation fails
	PostInstall []string `yaml:"post_install,omitempty" json:"post_install,omitempty"`
}

Hooks are a set of short scripts to run before or after installation

type NSMetadata

type NSMetadata struct {
	Annotations map[string]string `yaml:"annotations,omitempty" json:"annotations,omitempty"`
	Labels      map[string]string `yaml:"labels,omitempty" json:"labels,omitempty"`
}

type NSSettings

type NSSettings struct {
	// Overwrite specifies if these annotations and labels should be overwritten in the event that they already exist.
	Overwrite *bool `yaml:"overwrite,omitempty" json:"overwrite,omitempty"`
}

type NamespaceConfig

type NamespaceConfig struct {
	Metadata NSMetadata `yaml:"metadata,omitempty" json:"metadata,omitempty"`
	Settings NSSettings `yaml:"settings" json:"settings"`
}

NamespaceConfig allows setting namespace annotations and labels

type NamespaceMgmt

type NamespaceMgmt struct {
	// Default is the default namespace config for this course
	Default *NamespaceConfig `yaml:"default" json:"default"`
}

type Release

type Release struct {
	// GitClonePath is the path where the repository should be cloned into
	// ignored when parsing to and from yaml or json
	GitClonePath *string `yaml:"-" json:"-"`
	// GitChartSubPath is the sub path of the repository where the chart is located after being cloned
	// ignored when parsing to and from yaml or json
	GitChartSubPath *string `yaml:"-" json:"-"`
	// Name is the name of the release
	Name string `yaml:"name" json:"name"`
	// Namespace is the namespace that this release should be placed in
	Namespace string `yaml:"namespace,omitempty" json:"namespace,omitempty"`
	// NamespaceMgmt is a set of labels and annotations to be added to the namespace for this release
	NamespaceMgmt *NamespaceConfig `yaml:"namespace_management,omitempty" json:"namespace_management,omitempty"`
	// Chart is the name of the chart used by this release.
	// If empty, then the release name is assumed to be the chart.
	Chart string `yaml:"chart,omitempty" json:"chart,omitempty"`
	// Hooks contains pre and post hooks for a specific release
	Hooks Hooks `yaml:"hooks,omitempty" json:"hooks,omitempty"`
	// Version is the version of the chart to install.
	// If empty, reckoner will use the latest version of the chart in the repository.
	// If this is a git repository, then this should be a git ref.
	// if this is empty, and it is a git repository, then the latest commit on the default
	// branch will be used.
	Version string `yaml:"version,omitempty" json:"version,omitempty"`
	// Repository is the name of the repository that the chart for this release comes from
	// This must correspond to a defined repository in the "header" of the course
	Repository string `yaml:"repository" json:"repository"`
	// Files is a list of external values files that should be passed to helm in addition to values
	Files []string `yaml:"files,omitempty" json:"files,omitempty"`
	// Values contains any values that you wish to pass to the release. Everything
	// underneath this key will placed in a temporary yaml file and passed to helm as a values file.
	Values map[string]interface{} `yaml:"values,omitempty" json:"values,omitempty"`
	GitOps GitOps                 `yaml:"gitops,omitempty" json:"gitops,omitempty"`
}

Release represents a helm release and all of its configuration

func (*Release) SetGitPaths

func (r *Release) SetGitPaths(clonePath, subPath string) error

SetGitPaths allows the caller to set both the clone path and the chart subpath for a release.

type ReleaseV1

type ReleaseV1 struct {
	// Name is the name of the release
	Name string `yaml:"name" json:"name"`
	// Namespace is the namespace that this release should be placed in
	Namespace string `yaml:"namespace,omitempty" json:"namespace,omitempty"`
	// NamespaceMgmt is a set of labels and annotations to be added to the namespace for this release
	NamespaceMgmt *NamespaceConfig `yaml:"namespace_management,omitempty" json:"namespace_management,omitempty"`
	// Chart is the name of the chart used by this release
	Chart string `yaml:"chart" json:"chart"`
	// Hooks are pre and post install hooks
	Hooks Hooks `yaml:"hooks,omitempty" json:"hooks,omitempty"`
	// Version is the version of the chart to install
	Version string `yaml:"version" json:"version"`
	// Repository is the repository
	Repository interface{} `yaml:"repository,omitempty" json:"repository,omitempty"`
	// Files is a list of external values files that should be passed to helm in addition to values
	Files []string `yaml:"files,omitempty" json:"files,omitempty"`
	// Values contains any values that you wish to pass to the release. Everything
	// underneath this key will placed in a temporary yaml file and passed to helm as a values file.
	Values map[string]interface{} `yaml:"values" json:"values"`
}

ReleaseV1 represents a helm release and all of its configuration from v1 schema

type Repository

type Repository struct {
	URL  string `yaml:"url,omitempty" json:"url,omitempty"`
	Git  string `yaml:"git,omitempty" json:"git,omitempty"`
	Path string `yaml:"path,omitempty" json:"path,omitempty"`
}

Repository is a helm reposotory definition

type RepositoryMap

type RepositoryMap map[string]Repository

RepositoryMap is a set of repositories

type RepositoryV1

type RepositoryV1 struct {
	Name string `yaml:"name,omitempty" json:"name,omitempty"`
	URL  string `yaml:"url,omitempty" json:"url,omitempty"`
	Git  string `yaml:"git,omitempty" json:"git,omitempty"`
	Path string `yaml:"path,omitempty" json:"path,omitempty"`
}

RepositoryV1 is a helm reposotory definition

type RepositoryV1List

type RepositoryV1List map[string]Repository

RepositoryV1List is a set of repositories

type Secret

type Secret struct {
	Name    string `yaml:"name" json:"name"`
	Backend string `yaml:"backend" json:"backend"`
	// Script is only used for Backend ShellExecutor
	Script []string `yaml:"script" json:"script"`
	// ParameterName is only used for Backend type AWSParameterStore
	ParameterName string `yaml:"parameter_name" json:"parameter_name"`
	// Region is only used for Backend type AWSParameterStore
	Region string `yaml:"region" json:"region"`
}

Secret is a single instance of a secret including what backend should be hit to retrieve the secret

type SecretsList

type SecretsList []Secret

SecretsList is, you guessed it, a list of Secret structs

Jump to

Keyboard shortcuts

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