gitops

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2021 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadClusters

func LoadClusters(configRepoPath string, versions Versions) (map[string]Cluster, error)

LoadClusters scans through the cluster/ subdirectory and build a slice of defined clusters

func LoadEnvironments

func LoadEnvironments(configRepoPath string, versions Versions, clusters map[string]Cluster) (map[string]Environment, error)

LoadEnvironments scans through the environments/ subdirectory and build a slice of defined environments

func SortReleaseTargets

func SortReleaseTargets(targets []Target)

SortReleaseTargets sorts release targets lexicographically by type, by base, and then by name

Types

type AppRelease

type AppRelease interface {
	AppVersion() string
	Environment() Environment
	Release
}

type Cluster

type Cluster interface {
	Address() string
	Target
}

func NewCluster

func NewCluster(name string, base string, address string, releases map[string]ClusterRelease) Cluster

NewCluster constructs a new Cluster

type ClusterRelease

type ClusterRelease interface {
	Cluster() Cluster
	Release
}

type Environment

type Environment interface {
	// Returns the name of the default cluster for this environment. Eg. "terra-qa"
	DefaultCluster() string
	// Returns the namespace for this environment. Eg. "terra-dev"
	Namespace() string
	Target
}

func NewEnvironment

func NewEnvironment(name string, base string, defaultCluster string, releases map[string]AppRelease) Environment

NewEnvironment constructs a new Environment

type Gitops

type Gitops interface {
	Targets() []Target
	Releases() []Release
	FilterReleases(ReleaseFilter) []Release
	GetTarget(name string) Target
}

func Load

func Load(thelmaHome string, shellRunner shell.Runner) (Gitops, error)

type MockSnapshot

type MockSnapshot struct {
	mock.Mock
}

func NewMockSnapshot

func NewMockSnapshot() *MockSnapshot

func (*MockSnapshot) AppVersion

func (s *MockSnapshot) AppVersion(releaseName string) string

func (*MockSnapshot) ChartVersion

func (s *MockSnapshot) ChartVersion(releaseName string) string

func (*MockSnapshot) ReleaseDefined

func (s *MockSnapshot) ReleaseDefined(releaseName string) bool

func (*MockSnapshot) UpdateChartVersionIfDefined

func (s *MockSnapshot) UpdateChartVersionIfDefined(releaseName string, newVersion string) error

type MockVersions

type MockVersions struct {
	mock.Mock
}

func NewMockVersions

func NewMockVersions() *MockVersions

func (*MockVersions) GetSnapshot

func (v *MockVersions) GetSnapshot(releaseType ReleaseType, versionSet VersionSet) VersionSnapshot

type Release

type Release interface {
	Name() string
	Type() ReleaseType
	IsAppRelease() bool
	IsClusterRelease() bool
	ChartVersion() string
	ChartName() string
	Repo() string
	Namespace() string
	ClusterName() string
	ClusterAddress() string
	Target() Target
	// Returns 0 if r == other, -1 if r < other, or +1 if r > other.
	Compare(Release) int
}

type ReleaseFilter

type ReleaseFilter interface {
	Matches(Release) bool
	And(ReleaseFilter) ReleaseFilter
	Or(ReleaseFilter) ReleaseFilter
}

func AnyRelease

func AnyRelease() ReleaseFilter

func HasName

func HasName(releaseName string) ReleaseFilter

func HasTarget

func HasTarget(targetName string) ReleaseFilter

type ReleaseType

type ReleaseType int

ReleaseType is an enum type referring to the two types of releases supported by terra-helmfile.

const (
	AppReleaseType ReleaseType = iota
	ClusterReleaseType
)

func ReleaseTypes

func ReleaseTypes() []ReleaseType

func (ReleaseType) Compare

func (r ReleaseType) Compare(other ReleaseType) int

Returns 0 if r == other, -1 if r < other, or +1 if r > other.

func (ReleaseType) String

func (r ReleaseType) String() string

func (*ReleaseType) UnmarshalYAML

func (r *ReleaseType) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML is a custom unmarshaler so that the string "app" or "cluster" in a yaml file can be unmarshaled into a ReleaseType

type Target

type Target interface {
	ConfigDir() string        // ConfigDir returns the subdirectory in the terra-helmfile config repo where environments or clusters are defined
	Type() TargetType         // Type is the name of the target type, either "environment" or "cluster", as referenced in the helmfile repo
	Base() string             // Base is the base of the environment or cluster
	Name() string             // Name is the name of the environment or cluster
	ReleaseType() ReleaseType // ReleaseType returns the types of releases that can be deployed to this target
	Releases() []Release      // Releases returns the set of releases configured for this target
	IsCluster() bool          // Returns true if this target is a cluster
	IsEnvironment() bool      // Returns true if this target is an environment
	Compare(other Target) int // Returns 0 if t == other, -1 if t < other, or +1 if t > other.
}

Target represents where a release is being deployed (environment or cluster)

type TargetType

type TargetType int

TargetType is an enum type referring to the two types of targets supported by terra-helmfile.

const (
	EnvironmentTargetType TargetType = iota
	ClusterTargetType
)

func (TargetType) Compare

func (t TargetType) Compare(other TargetType) int

Returns 0 if t == other, -1 if t < other, or +1 if t > other.

func (TargetType) String

func (t TargetType) String() string

func (*TargetType) UnmarshalYAML

func (t *TargetType) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML is a custom unmarshaler so that the string "environment" or "cluster" in a yaml file can be unmarshaled into a TargetType

type VersionSet

type VersionSet int

VersionSet is an enum type representing a version set defined in terra-helmfile

const (
	Dev VersionSet = iota
	Alpha
	Staging
	Prod
)

func VersionSets

func VersionSets() []VersionSet

func (VersionSet) String

func (s VersionSet) String() string

type VersionSnapshot

type VersionSnapshot interface {
	// ReleaseDefined returns true if the given release is defined in this snapshot
	ReleaseDefined(releaseName string) bool
	// ChartVersion returns the chartVersion for the given release in this snapshot. If the release is not defined, returns ""
	ChartVersion(releaseName string) string
	// AppVersion returns the chartVersion for the given release in this snapshot. If the release is not defined, returns ""
	AppVersion(releaseName string) string
	// UpdateChartVersionIfDefined sets the chartVersion for the given release to the given version.
	// If the release is not defined, or if newVersion <= the current chart version, this function does nothing.
	UpdateChartVersionIfDefined(releaseName string, newVersion string) error
}

type Versions

type Versions interface {
	// GetSnapshot returns a VersionSnapshot reference for the given release type & version set
	GetSnapshot(releaseType ReleaseType, versionSet VersionSet) VersionSnapshot
}

Versions is for manipulating chart release versions in terra-helmfile (eg. versions/app/dev.yaml, versions/cluster/dev.yaml)

func NewVersions

func NewVersions(thelmaHome string, shellRunner shell.Runner) (Versions, error)

NewVersions returns a new Versions instance

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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