Documentation ¶
Overview ¶
Package application provides wrapper types around the concept of an App and its associated values ConfigMap.
A standard Application type is available as well as a Cluster helper type that encapsulates both the cluster app and the associated default-apps and their values ConfigMaps. The Cluster type also handles setting the required labels and annotations on the relevant App and ConfigMap resources.
Creating an App ¶
app := application.New("test-installation", "external-dns"). WithOrganization("giantswarm"). WithVersion(""). MustWithValuesFile("./test_data/externaldns_values.yaml", &application.ValuesTemplateVars{}) appCR, configMap, err := app.Build()
Creating a Cluster ¶
cluster = application.NewClusterApp(utils.GenerateRandomName("t"), application.ProviderGCP). WithOrg(organization.NewRandomOrg()). WithAppValuesFile(path.Clean("./test_data/cluster_values.yaml"), path.Clean("./test_data/default-apps_values.yaml")) clusterApp, clusterConfigMap, defaultAppsApp, defaultAppsConfigMap, err := cluster.Build()
App Versions ¶
When specifing the App version there are a couple special cases that you can take advantage of:
- Using the value `latest` as the App version will cause the latest released version found on GitHub to be used.
- Setting the version to an empty string will allow for overriding the version from an environment variable. The environment variable `E2E_OVERRIDE_VERSIONS` can be used to provide a comma seperated list of app version overrides in the format `app-name=version` (e.g. `cluster-aws=v1.2.3,cluster-gcp=v1.2.3-2hehdu`). If no such environemnt variable is found then it will fallback to the same logic as `latest` above.
Combining these two features together allows for creating scenarios that test upgrading an App from the current latest to the version being worked on in a PR.
Example:
Assuming the `E2E_OVERRIDE_VERSIONS` env var is set to override cluster-aws with a valid version then the following will install cluster-aws as the lastest released version then later install (upgrade) again with the version overridden from the environment variable.
appCR, configMap, err := application.New("upgrade-test", "cluster-aws").WithVersion("latest").Build() // ... apply manifests and wait for install to complete... appCR, configMap, err = application.New("upgrade-test", "cluster-aws").WithVersion("").Build() // ... apply manifests and wait for upgrade to complete...
Index ¶
- Constants
- type Application
- func (a *Application) Build() (*applicationv1alpha1.App, *corev1.ConfigMap, error)
- func (a *Application) GetNamespace() string
- func (a *Application) MustWithValues(values string, config *TemplateValues) *Application
- func (a *Application) MustWithValuesFile(filePath string, config *TemplateValues) *Application
- func (a *Application) WithAppLabels(labels map[string]string) *Application
- func (a *Application) WithCatalog(catalog string) *Application
- func (a *Application) WithConfigMapLabels(labels map[string]string) *Application
- func (a *Application) WithExtraConfigs(extraConfigs []applicationv1alpha1.AppExtraConfig) *Application
- func (a *Application) WithInCluster(inCluster bool) *Application
- func (a *Application) WithOrganization(organization organization.Org) *Application
- func (a *Application) WithUserConfigSecretName(name string) *Application
- func (a *Application) WithValues(values string, config *TemplateValues) (*Application, error)
- func (a *Application) WithValuesFile(filePath string, config *TemplateValues) (*Application, error)
- func (a *Application) WithVersion(version string) *Application
- type Cluster
- func (c *Cluster) Build() (*applicationv1alpha1.App, *corev1.ConfigMap, *applicationv1alpha1.App, ...)
- func (c *Cluster) GetNamespace() string
- func (c *Cluster) WithAppValues(clusterValues string, defaultAppsValues string, templateValues *TemplateValues) *Cluster
- func (c *Cluster) WithAppValuesFile(clusterValuesFile string, defaultAppsValuesFile string, ...) *Cluster
- func (c *Cluster) WithAppVersions(clusterVersion string, defaultAppsVersion string) *Cluster
- func (c *Cluster) WithExtraConfigs(extraConfigs []applicationv1alpha1.AppExtraConfig) *Cluster
- func (c *Cluster) WithOrg(org *organization.Org) *Cluster
- func (c *Cluster) WithUserConfigSecret(secretName string) *Cluster
- type ClusterValues
- type ControlPlane
- type DefaultAppsValues
- type NodePool
- type Provider
- type TemplateValues
Constants ¶
const VersionOverrideEnvVar = "E2E_OVERRIDE_VERSIONS"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Application ¶
type Application struct { InstallName string AppName string Version string Catalog string Values string InCluster bool Organization organization.Org UserConfigSecretName string ExtraConfigs []applicationv1alpha1.AppExtraConfig AppLabels map[string]string ConfigMapLabels map[string]string }
Application contains all details for creating an App and its values ConfigMap
func (*Application) Build ¶
func (a *Application) Build() (*applicationv1alpha1.App, *corev1.ConfigMap, error)
Build generates the App and ConfigMap resources
func (*Application) GetNamespace ¶ added in v0.3.0
func (a *Application) GetNamespace() string
GetNamespace returns the app namespace.
func (*Application) MustWithValues ¶ added in v0.2.0
func (a *Application) MustWithValues(values string, config *TemplateValues) *Application
MustWithValues wraps around WithValues but panics if an error occurs. It is intended to allow for chaining functions when you're sure the file will template successfully.
func (*Application) MustWithValuesFile ¶
func (a *Application) MustWithValuesFile(filePath string, config *TemplateValues) *Application
MustWithValuesFile wraps around WithValuesFile but panics if an error occurs. It is intended to allow for chaining functions when you're sure the file will template successfully.
func (*Application) WithAppLabels ¶
func (a *Application) WithAppLabels(labels map[string]string) *Application
WithAppLabels adds the provided labels to the generated App resource
func (*Application) WithCatalog ¶
func (a *Application) WithCatalog(catalog string) *Application
WithCatalog sets the Catalog value
func (*Application) WithConfigMapLabels ¶
func (a *Application) WithConfigMapLabels(labels map[string]string) *Application
WithConfigMapLabels adds the provided labels to the generated ConfigMap resource
func (*Application) WithExtraConfigs ¶ added in v0.0.13
func (a *Application) WithExtraConfigs(extraConfigs []applicationv1alpha1.AppExtraConfig) *Application
WithExtraConfigs sets the array of AppExtraConfigs to .spec.extraConfigs
func (*Application) WithInCluster ¶
func (a *Application) WithInCluster(inCluster bool) *Application
WithInCluster sets the InCluster value
func (*Application) WithOrganization ¶ added in v0.3.0
func (a *Application) WithOrganization(organization organization.Org) *Application
WithOrganization sets the Organization value
func (*Application) WithUserConfigSecretName ¶ added in v0.0.9
func (a *Application) WithUserConfigSecretName(name string) *Application
WithUserConfigSecretName sets the provided name of the secret as UserConfigSecretName
func (*Application) WithValues ¶
func (a *Application) WithValues(values string, config *TemplateValues) (*Application, error)
WithValues sets the Values value
The values supports templating using Go template strings and uses values provided in `config` to replace placeholders.
func (*Application) WithValuesFile ¶
func (a *Application) WithValuesFile(filePath string, config *TemplateValues) (*Application, error)
WithValuesFile sets the Values property based on the contents found in the provided file path
The file supports templating using Go template strings and uses values provided in `config` to replace placeholders.
func (*Application) WithVersion ¶
func (a *Application) WithVersion(version string) *Application
WithVersion sets the Version value
If set to the value `latest“ then the version will be fetched from the latest release on GitHub. If set to an empty string (the default) then the environment variables will first be checked for a matching override var and if not found then the logic will fall back to the same as `latest“.
If the version provided is suffixed with a commit sha then the `Catalog` use for the Apps will be updated to `cluster-test`.
type Cluster ¶
type Cluster struct { Name string ClusterApp *Application DefaultAppsApp *Application Organization *organization.Org }
Cluster is a wrapper around Cluster and Default-apps Apps that makes creating them together easier
func NewClusterApp ¶
NewClusterApp generates a new Cluster object to handle creation of Cluster related apps
func (*Cluster) Build ¶
func (c *Cluster) Build() (*applicationv1alpha1.App, *corev1.ConfigMap, *applicationv1alpha1.App, *corev1.ConfigMap, error)
Build defaults and populates some required values on the apps then generated the App and Configmap pairs for both the cluster and default-apps apps.
func (*Cluster) GetNamespace ¶ added in v0.3.0
GetNamespace returns the cluster organization namespace.
func (*Cluster) WithAppValues ¶
func (c *Cluster) WithAppValues(clusterValues string, defaultAppsValues string, templateValues *TemplateValues) *Cluster
WithAppValues sets the App Values values
The values supports templating using Go template strings to replace things like the cluster name and namespace
func (*Cluster) WithAppValuesFile ¶
func (c *Cluster) WithAppValuesFile(clusterValuesFile string, defaultAppsValuesFile string, templateValues *TemplateValues) *Cluster
WithAppValuesFile sets the App Values values from the provided file paths
The values supports templating using Go template strings to replace things like the cluster name and namespace
func (*Cluster) WithAppVersions ¶
WithAppVersions sets the Version values
If the versions are set to the value `latest` then the version will be fetched from the latest release on GitHub. If set to an empty string (the default) then the environment variables will first be checked for a matching override var and if not found then the logic will fall back to the same as `latest`.
If the version provided is suffixed with a commit sha then the `Catalog` use for the Apps will be updated to `cluster-test`.
func (*Cluster) WithExtraConfigs ¶ added in v0.0.13
func (c *Cluster) WithExtraConfigs(extraConfigs []applicationv1alpha1.AppExtraConfig) *Cluster
WithExtraConfigs sets the array of AppExtraConfigs to .spec.extraConfigs
func (*Cluster) WithOrg ¶
func (c *Cluster) WithOrg(org *organization.Org) *Cluster
WithOrg sets the Organization for the cluster and updates the namespace to that specified by the provided Org
func (*Cluster) WithUserConfigSecret ¶ added in v0.0.9
WithUserConfigSecret sets the name of the referenced Secret under userConfig section
type ClusterValues ¶ added in v0.0.10
type ClusterValues struct { BaseDomain string `yaml:"baseDomain"` ControlPlane ControlPlane `yaml:"controlPlane"` NodePools map[string]NodePool `yaml:"nodePools"` }
ClusterValues holds common values for cluster-<provider> charts. These are the provider independent values and are present for all the charts
type ControlPlane ¶ added in v0.0.10
type ControlPlane struct {
Replicas int `yaml:"replicas"`
}
type DefaultAppsValues ¶ added in v0.0.12
type DefaultAppsValues struct {
BaseDomain string `yaml:"baseDomain"`
}
DefaultAppsValues holds common values for default-apps-<provider> charts. These are the provider independent values and are present for all the charts
type Provider ¶
type Provider string
Provider is the supported cluster provider name used to determine the cluster and default-apps to use
type TemplateValues ¶ added in v0.2.0
type TemplateValues struct { ClusterName string Namespace string Organization string ExtraValues map[string]string }
TemplateValues is the properties made available to the Values string when templating.
The Values string if parsed as a Go text template and will replace these properties if found.