Documentation ¶
Overview ¶
Package model contains the app definition and interfaces for dealing with K8s objects.
Index ¶
- Constants
- Variables
- func NameForDisplay(m K8sMeta) string
- type App
- func (a *App) ComponentsForEnvironment(env string, includes, excludes []string) ([]Component, error)
- func (a *App) DeclaredTopLevelVars() map[string]interface{}
- func (a *App) DeclaredVars() map[string]interface{}
- func (a *App) DefaultNamespace(env string) string
- func (a *App) Environments() map[string]Environment
- func (a *App) LibPaths() []string
- func (a *App) Name() string
- func (a *App) ParamsFile() string
- func (a *App) PostProcessor() string
- func (a *App) ServerURL(env string) (string, error)
- func (a *App) Tag() string
- type AppMeta
- type AppSpec
- type Component
- type Environment
- type ExternalVar
- type Filter
- type K8sLocalObject
- type K8sMeta
- type K8sObject
- type K8sQbecMeta
- type QbecApp
- type QbecMeta
- type TopLevelVar
- type Var
- type Variables
Constants ¶
const ( DefaultComponentsDir = "components" // the default components directory DefaultParamsFile = "params.libsonnet" // the default params files )
Default values
const Baseline = "_"
Baseline is a special environment name that represents the baseline environment with no customizations.
const LatestAPIVersion = "qbec.io/v1alpha1"
LatestAPIVersion is the latest version of the API we support.
const QBECMetadataPrefix = "qbec.io/"
QBECMetadataPrefix is the leading path for all metadata set by qbec.
Variables ¶
var QbecNames = struct { ApplicationLabel string // the label to use for tagging an object with an application name TagLabel string // the label to use for tagging an object with a scoped GC tag ComponentAnnotation string // the label to use for tagging an object with a component EnvironmentLabel string // the label to use for tagging an object with an annotation PristineAnnotation string // the annotation to use for storing the pristine object ParamsCodeVarName string // the name of the code variable that stores env params EnvVarName string // the name of the external variable that has the environment name TagVarName string // the name of the external variable that has the tag name DefaultNsVarName string // the name of the external variable that has the default namespace CleanModeVarName string // name of external variable that has the indicator for clean mode }{ ApplicationLabel: QBECMetadataPrefix + "application", TagLabel: QBECMetadataPrefix + "tag", ComponentAnnotation: QBECMetadataPrefix + "component", EnvironmentLabel: QBECMetadataPrefix + "environment", PristineAnnotation: QBECMetadataPrefix + "last-applied", ParamsCodeVarName: QBECMetadataPrefix + "params", EnvVarName: QBECMetadataPrefix + "env", TagVarName: QBECMetadataPrefix + "tag", DefaultNsVarName: QBECMetadataPrefix + "defaultNs", CleanModeVarName: QBECMetadataPrefix + "cleanMode", }
QbecNames is the set of names used by Qbec.
Functions ¶
func NameForDisplay ¶ added in v0.7.1
NameForDisplay returns the local name of the metadata object, taking generated names into account.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App is a qbec application wrapped with some runtime attributes.
func (*App) ComponentsForEnvironment ¶
func (a *App) ComponentsForEnvironment(env string, includes, excludes []string) ([]Component, error)
ComponentsForEnvironment returns a slice of components for the specified environment, taking intrinsic as well as specified inclusions and exclusions into account. All names in the supplied subsets must be valid component names. If a specified component is valid but has been excluded for the environment, it is simply not returned. The environment can be specified as the baseline environment.
func (*App) DeclaredTopLevelVars ¶ added in v0.6.2
DeclaredTopLevelVars returns a map of all declared TLA variables, keyed by variable name. The values are always `true`.
func (*App) DeclaredVars ¶ added in v0.6.2
DeclaredVars returns defaults for all declared external variables, keyed by variable name.
func (*App) DefaultNamespace ¶ added in v0.6.2
DefaultNamespace returns the default namespace for the environment, potentially suffixing it with any app-tag, if configured.
func (*App) Environments ¶ added in v0.7.1
func (a *App) Environments() map[string]Environment
Environments returns the environments defined for the app.
func (*App) ParamsFile ¶ added in v0.6.2
ParamsFile returns the runtime parameters file for the app.
func (*App) PostProcessor ¶ added in v0.7.3
PostProcessor returns the post processor file for the app or the empty string if not defined.
type AppMeta ¶
type AppMeta struct { // required: true Name string `json:"name"` }
AppMeta is the simplified metadata object for a qbec app.
type AppSpec ¶
type AppSpec struct { // directory containing component files, default to components/ ComponentsDir string `json:"componentsDir,omitempty"` // standard file containing parameters for all environments returning correct values based on qbec.io/env external // variable, defaults to params.libsonnet ParamsFile string `json:"paramsFile,omitempty"` // file containing jsonnet code that can be used to post-process all objects, typically adding metadata like // annotations. PostProcessor string `json:"postProcessor,omitempty"` // the interface for jsonnet variables. Vars Variables `json:"vars,omitempty"` // set of environments for the app // required: true Environments map[string]Environment `json:"environments"` // list of components to exclude by default for every environment Excludes []string `json:"excludes,omitempty"` // list of library paths to add to the jsonnet VM at evaluation LibPaths []string `json:"libPaths,omitempty"` // automatically suffix default namespace defined for environment when app-tag provided. NamespaceTagSuffix bool `json:"namespaceTagSuffix,omitempty"` }
AppSpec is the user-supplied configuration of the qbec app.
type Component ¶
type Component struct { Name string // component name File string // path to component file TopLevelVars []string // the top-level variables used by the component }
Component is a file that contains objects to be applied to a cluster.
type Environment ¶
type Environment struct { DefaultNamespace string `json:"defaultNamespace"` // default namespace to set for k8s context Server string `json:"server"` // server URL of server Includes []string `json:"includes,omitempty"` // components to be included in this env even if excluded at the app level Excludes []string `json:"excludes,omitempty"` // additional components to exclude for this env }
Environment points to a specific destination and has its own set of runtime parameters.
type ExternalVar ¶ added in v0.6.2
type ExternalVar struct { Var Default interface{} `json:"default,omitempty"` // the default value to use if none specified on the command line. }
ExternalVar is a variable that is set as an extVar in the jsonnet VM
type Filter ¶
type Filter interface { HasFilters() bool // returns true if filtering is needed ShouldInclude(s string) bool // returns true if the supplied string matches the filter }
Filter filters inputs.
func NewComponentFilter ¶
NewComponentFilter returns a filter for component names.
func NewKindFilter ¶
NewKindFilter returns a filter for object kinds that ignores case and takes pluralization into account.
type K8sLocalObject ¶
K8sLocalObject is the interface to access a kubernetes object that has additional qbec attributes. It can be serialized to valid JSON or YAML that represents the fully-formed object.
func NewK8sLocalObject ¶
func NewK8sLocalObject(data map[string]interface{}, app, tag, component, env string) K8sLocalObject
NewK8sLocalObject wraps a K8sLocalObject implementation around the unstructured object data specified as a bag of attributes for the supplied application, component and environment.
type K8sMeta ¶
type K8sMeta interface { GetKind() string GroupVersionKind() schema.GroupVersionKind GetNamespace() string GetName() string GetGenerateName() string }
K8sMeta is the minimum metadata needed for an object and is satisfied by an unstructured.Unstructured instance.
type K8sObject ¶
type K8sObject interface { K8sMeta ToUnstructured() *unstructured.Unstructured }
K8sObject is the interface to access a kubernetes object. It can be serialized to valid JSON or YAML that represents the fully-formed object.
func NewK8sObject ¶
NewK8sObject wraps a K8sObject implementation around the unstructured object data specified as a bag of attributes.
type K8sQbecMeta ¶
K8sQbecMeta has K8s as well as qbec metadata.
type QbecApp ¶
type QbecApp struct { // object kind // required: true // pattern: ^App$ Kind string `json:"kind"` // requested API version // required: true APIVersion string `json:"apiVersion"` // app metadata // required: true Metadata AppMeta `json:"metadata,omitempty"` // app specification // required: true Spec AppSpec `json:"spec"` }
QbecApp is a set of components that can be applied to multiple environments with tweaked runtime configurations. The list of all components for the app is derived as all the supported (jsonnet, json, yaml) files in the components subdirectory. swagger:model App
type QbecMeta ¶
type QbecMeta interface { Application() string // the application name Component() string // the component name Environment() string // the environment name Tag() string // the GC Tag name }
QbecMeta provides qbec metadata.
type TopLevelVar ¶ added in v0.6.2
type TopLevelVar struct { Var Components []string `json:"components,omitempty"` // the components for which this TLA is applicable }
TopLevelVar is a variable that is set as a TLA in the jsonnet VM. Note that there is no provision to set a default value - default values should be set in the jsonnet code instead.
type Var ¶ added in v0.6.2
type Var struct { Name string `json:"name"` // variable name Secret bool `json:"secret,omitempty"` // true if the variable is a secret }
Var is a base variable.
type Variables ¶ added in v0.6.2
type Variables struct { External []ExternalVar `json:"external,omitempty"` // collection of ext vars TopLevel []TopLevelVar `json:"topLevel,omitempty"` // collection of TLAs }
Variables is a collection of external and top-level variables.