buildingblocks

package
v0.25.5 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2023 License: Apache-2.0 Imports: 38 Imported by: 1

Documentation

Index

Constants

View Source
const (
	GitProtocolPrefix = "git+"
)

Variables

View Source
var (
	// to signal empty result sets
	ErrNoResult = errors.New("nothing found")
)
View Source
var LICENSETmpl string

Functions

func CreateConfigDoc added in v0.17.0

func CreateConfigDoc(pathToHelmfile string) ([]byte, error)

TODO refactor

func CreateDefaultValueFiles added in v0.25.0

func CreateDefaultValueFiles(pathToHelmfile, pathToValues string)

Creates dir with all chart value files including only the default values. NB: side-effects (filesystem, panics)

func CreateJobEnvironment added in v0.18.0

func CreateJobEnvironment(bbProjectID int, bbVersion string, environment string, ciTemplatesVersion string) ([]byte, error)

CreateJobEnvironment will generate the job template for the given building block defined by the arguments, fully extended for the specified environment Output: JobEnvironment

func CreateJobTemplate added in v0.18.0

func CreateJobTemplate(bbProjectID int, bbVersion string) ([]byte, error)

CreateJobTemplate will generate the job template for the given building block defined by the arguments Output: JobTemplate

func GenerateK3sYaml added in v0.19.0

func GenerateK3sYaml(versions []string, defaultVersion string) []byte

GenerateK3sYaml creates the k3s.yaml references for gitlab-ci-templates including the k3s versions matrix and the default k3s version

func GenerateK8sVersionsConfigFile added in v0.25.5

func GenerateK8sVersionsConfigFile() []byte

Create k8sVersions.json file based on the metakube supported versions

func GenerateLicenseFile added in v0.23.0

func GenerateLicenseFile(pathToLicensesJson string) ([]byte, error)

Generate bb's LICENSE file according to licenses.json of each bb

func GenerateLicensesJson added in v0.23.0

func GenerateLicensesJson(pathToHelmfile string, pathToTemplate string) ([]byte, error)

Generates licenses.json out of the given bb's helmfile, images and template

func GenerateReadme added in v0.19.0

func GenerateReadme(bbName string, k8sVersions []string, docsPage string, upstreamComponents string, customNotes string, helmChartConfig string) ([]byte, error)

This functions generates a BB's readme

func GenerateUpstreamComponentsTables added in v0.20.0

func GenerateUpstreamComponentsTables(pathToHelmfile string) ([]byte, error)

GenerateUpstreamComponentsTables generates a markdown file for a building block that includes a table for each upstream component used by it with their versions: helm charts and docker images

func GetDefault added in v0.19.0

func GetDefault(pathToK8sVersions string) string

GetDefault returns the default K8s version defined in k8sVersions.json If the default version doesn't follow the K8s schema (x.yz), the function will fail with the relevant error message Also, the default version needs to be one of the supported versions of the config otherwise the function will fail with the relevant error message

func GetK3sDefaultImage added in v0.19.0

func GetK3sDefaultImage(k8sVersions []string, defaultVersion string) string

GetK3sDefaultImage returns the corresponding k3s image of the given default k8s version

func GetK3sImages added in v0.19.0

func GetK3sImages(k8sVersions []string) []string

GetK3sImages returns the corresponding k3s images to the given k8s versions If there are multiple patch images for one k8s version, the latest patch is chosen If there is no corresponding k3s image for a given k8s version, the function will fail with the relevant message

func GetNamespaceWithAnnotations added in v0.21.0

func GetNamespaceWithAnnotations(pathToKubeconfig string, bbProjectID int) (string, map[string]string, error)

GetNamespaceWithAnnotations will return the following info about the requested namespace: * Name: according to env vars set * Annotations: Any annotations attached to the namespace (atm, bbs have project-id and version) * Error: Error on extracting information NOTE 1 Error alone does not indicate the non-existence of the namespace The non-existence of namespace can be caught by checking the error AND the name of ns whether it's "" or not NOTE 2: The function was created to be executed from within control-repo's bb jobs (diff/deploy) So the namespace depends on the env vars set on these jobs

func GetTags added in v0.15.3

func GetTags(pID int) (s []string)

returns the list of tags for the given gitlab project.

func GetUpstreamComponentsJson added in v0.20.0

func GetUpstreamComponentsJson(pathToHelmfile string) ([]byte, error)

GetUpstreamComponentsJson generates a json file for a building block that includes all the upstream components used by it with their versions: helm charts and docker images

func GetVersions added in v0.19.0

func GetVersions(pathToK8sVersions string) []string

GetVersions returns the list of k8sVersions.json versions in the order they appear in the file If a version of the config doesn't follow the K8s schema (x.yz), the function will fail with the relevant error message

func InitializeLicensesJsonTmpl added in v0.23.1

func InitializeLicensesJsonTmpl(pathToHelmfile string) ([]byte, error)

Generates initial licenses.json.tmpl out of the given bb's helmfile, images This is a starting point to add the licenses information for a bb

func SortTags added in v0.15.3

func SortTags(versions []string) v.Collection

sorts a list of semantic versions, ascending.

func UpdateScript added in v0.15.0

func UpdateScript(versionFrom, versionTo string, p *RepoRef) ([]byte, error)

UpdateScript will generate a script containing a series of update scripts if there are any for the update of one version (versionFrom) to another (versionTo) of the given building block project ref.

Types

type BuildingBlock added in v0.18.0

type BuildingBlock struct {
	Name      string
	Version   string
	ProjectID int
}

type ChartValueOpts added in v0.25.0

type ChartValueOpts struct {
	NoDefaults,
	NoReleaseValues,
	NoReduce bool
}

for controlling chart value creation or filtering

type ChartValues added in v0.24.0

type ChartValues struct {
	Release, Chart string
	IsExtra        bool
	Consolidated   bool
	Content        []byte
}

encapsulates chart values

type Component added in v0.23.0

type Component struct {
	Name    string
	Version string
	Source  string
	License License
}

Component of LICENSE file struct

type ComponentInfo added in v0.23.0

type ComponentInfo struct {
	Name          string `json:"component"`
	Version       string `json:"version"`
	SpdxLicenseID string `json:"spdx-licenseId"`
	LicenseText   string `json:"license"`
	Source        string `json:"source"`
}

Component info of licenses.json

type DockerImages added in v0.20.0

type DockerImages struct {
	Component  string `json:"component"`
	Repository string `json:"repository"`
	Tag        string `json:"tag"`
}

Docker Images struct

type HelmChart added in v0.20.0

type HelmChart struct {
	Component string `json:"component"`
	RepoUrl   string `json:"repoUrl"`
	Name      string `json:"name"`
	Version   string `json:"version"`
}

Helm Chart struct

type Helmfile added in v0.25.0

type Helmfile struct {
	Repositories []HelmfileRepository `yaml:"repositories"`
	HelmDefaults HelmfileHelmDefaults `yaml:"helmDefaults"`
	Values       []any                `yaml:"values"`
	Releases     []HelmfileRelease    `yaml:"releases"`
}

Helmfile top level elements.

func PrepareHelmfile added in v0.25.0

func PrepareHelmfile(pathToHelmfile string) (*Helmfile, string, error)

func (*Helmfile) HelmfileValues added in v0.25.0

func (h *Helmfile) HelmfileValues() (map[string]any, error)

returns the helmfile values (which serve as template inputs for the release value templates) as a map.

type HelmfileHelmDefaults added in v0.25.0

type HelmfileHelmDefaults struct {
	Timeout int  `yaml:"timeout"`
	Wait    bool `yaml:"wait"`
}

Helmfile HelmfileHelmDefaults element.

type HelmfileRelease added in v0.25.0

type HelmfileRelease struct {
	Name               string                `yaml:"name"`
	Namespace          string                `yaml:"namespace"`
	Chart              string                `yaml:"chart"`
	Version            string                `yaml:"version"`
	DisableValidation  bool                  `yaml:"disableValidation"`
	MissingFileHandler string                `yaml:"missingFileHandler"`
	Values             []string              `yaml:"values"`
	Hooks              []HelmfileReleaseHook `yaml:"hooks"`
	Needs              []string              `yaml:"needs"`
}

Helmfile HelmfileRelease element (Helm Charts).

func (*HelmfileRelease) ExtraChartValues added in v0.25.0

func (r *HelmfileRelease) ExtraChartValues(pathToHelmfile string, hfValues map[string]any) (ReleaseValues, error)

will render extra chart golang template value files for the given helmfile path and optional helmfile values to take into account for template rendering.

func (*HelmfileRelease) LocalChartValues added in v0.25.0

func (r *HelmfileRelease) LocalChartValues(pathToHelmfile string) (ReleaseValues, error)

type HelmfileReleaseHook added in v0.25.0

type HelmfileReleaseHook struct {
	Command string   `yaml:"command"`
	Args    []string `yaml:"args"`
	Events  []string `yaml:"events"`
}

Helmfile HelmfileReleaseHook element.

type HelmfileRepository added in v0.25.0

type HelmfileRepository struct {
	Name string `yaml:"name"`
	Url  string `yaml:"url"`
}

Helmfile HelmfileRepository element.

type K3sJson added in v0.19.0

type K3sJson []struct {
	Name string `json:"name"`
}

k3s container registry json

type K3sVersions added in v0.19.0

type K3sVersions struct {
	Matrix []Matrix `yaml:"matrix"`
}

K3sVersions element

type K3sYaml added in v0.19.0

type K3sYaml struct {
	Variables Variables `yaml:".variables"`
	Parallel  Parallel  `yaml:".parallel"`
}

k3s.yaml into struct k3s top level elements.

type K8sJson added in v0.25.5

type K8sJson struct {
	Version string `json:"version"`
	Default bool   `json:"default,omitempty"`
}

metakube supported k8s versions

type K8sVersionsConfig added in v0.19.0

type K8sVersionsConfig struct {
	K8sVersions []string `json:"K8sVersions"`
	Default     string   `json:"Default"`
}

k8sVersions.json into struct

type License added in v0.23.0

type License struct {
	SpdxCode string
	Text     string
}

License struct used inside Component

type Matrix added in v0.19.0

type Matrix struct {
	K3sVersion []string `yaml:"K3S_VERSION"`
}

Matrix element

type Parallel added in v0.19.0

type Parallel struct {
	K3sVersions K3sVersions `yaml:"k3s_versions"`
}

Parallel element (Helm Charts)

type ReleaseValues added in v0.24.0

type ReleaseValues []*ChartValues

encapsulates collections of chart values

func GenerateChartValues added in v0.25.0

func GenerateChartValues(pathToHelmfile string, opts ...*ChartValueOpts) (*ReleaseValues, error)

generates all possible chart values for the given helmfile the result is consolidated by default skip fetching chart default values via optional NoDefaults skip fetching chart extra values via optional NoReleaseValues skip value consolidation via optional NoReduce

func (*ReleaseValues) AllExtraValues added in v0.25.0

func (vals *ReleaseValues) AllExtraValues(release string) []byte

returns the combined content of all extra values for the given release name.

func (*ReleaseValues) Consolidated added in v0.25.0

func (vals *ReleaseValues) Consolidated() (*ReleaseValues, error)

consolidates values for the same release into one chart value object, returns a copy of this instance

func (*ReleaseValues) Filter added in v0.25.0

func (vals *ReleaseValues) Filter(predicate func(*ChartValues) bool) *ReleaseValues

Filter returns the subset of this release values object according to the provided predicate.

func (*ReleaseValues) Releases added in v0.25.0

func (vals *ReleaseValues) Releases() []string

returns the list of (unique) release names for the given set of chart values.

func (*ReleaseValues) Write added in v0.24.0

func (vals *ReleaseValues) Write(dir string)

writes all chart values to their respective (value) files within dir

type RepoRef added in v0.15.0

type RepoRef struct {
	ID  int
	Ref string
}

type UpstreamComponents added in v0.20.0

type UpstreamComponents struct {
	HelmChart    []HelmChart    `json:"helmCharts"`
	DockerImages []DockerImages `json:"dockerImages"`
}

Upstream components struct

type Variables added in v0.19.0

type Variables struct {
	DefaultVersion string `yaml:"DEFAULT_K3S_VERSION"`
}

Variables element

Jump to

Keyboard shortcuts

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