Documentation ¶
Overview ¶
Package model contains the app definition and interfaces for dealing with K8s objects.
Index ¶
- Constants
- Variables
- func AssertMetadataValid(data map[string]interface{}) error
- func NameForDisplay(m K8sMeta) string
- func NewFilters(flags *pflag.FlagSet, includeAllFilters bool) func() (Filters, error)
- type App
- func (a *App) AddComponentLabel() bool
- func (a *App) BaseProperties() map[string]interface{}
- func (a *App) ClusterScopedLists() bool
- func (a *App) ComponentsForEnvironment(env string, includes, excludes []string) ([]Component, error)
- func (a *App) Context(env string) (string, error)
- func (a *App) DataSourceExamples() map[string]interface{}
- func (a *App) DataSources() []string
- func (a *App) DeclaredComputedVars() []ComputedVar
- 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) PostProcessors() []string
- func (a *App) Properties(env string) (map[string]interface{}, error)
- func (a *App) ServerURL(env string) (string, error)
- func (a *App) SetOverrideNamespace(ns string)
- func (a *App) Tag() string
- type AppMeta
- type AppSpec
- type Component
- type ComputedVar
- type Directives
- type Environment
- type ExternalVar
- type Filter
- type Filters
- type K8sLocalObject
- type K8sMeta
- type K8sObject
- type K8sQbecMeta
- type LocalAttrs
- type Namespaced
- type QbecApp
- type QbecEnvironmentMap
- type QbecEnvironmentMapSpec
- 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 QBECDirectivesNamespace = "directives.qbec.io/"
QBECDirectivesNamespace is the leading path for all directives set by the user for qbec use.
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 ComponentLabel 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 EnvVarName string // the name of the external variable that has the environment name EnvPropsVarName string // the name of the external variable that has the environment properties object 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 Directives Directives }{ ApplicationLabel: QBECMetadataPrefix + "application", TagLabel: QBECMetadataPrefix + "tag", ComponentAnnotation: QBECMetadataPrefix + "component", ComponentLabel: QBECMetadataPrefix + "component", EnvironmentLabel: QBECMetadataPrefix + "environment", PristineAnnotation: QBECMetadataPrefix + "last-applied", EnvVarName: QBECMetadataPrefix + "env", EnvPropsVarName: QBECMetadataPrefix + "envProperties", TagVarName: QBECMetadataPrefix + "tag", DefaultNsVarName: QBECMetadataPrefix + "defaultNs", CleanModeVarName: QBECMetadataPrefix + "cleanMode", Directives: Directives{ ApplyOrder: QBECDirectivesNamespace + "apply-order", DeletePolicy: QBECDirectivesNamespace + "delete-policy", UpdatePolicy: QBECDirectivesNamespace + "update-policy", WaitPolicy: QBECDirectivesNamespace + "wait-policy", }, }
QbecNames is the set of names used by Qbec.
Functions ¶
func AssertMetadataValid ¶ added in v0.10.0
AssertMetadataValid asserts that the object metadata for the supplied unstructured object is valid.
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) AddComponentLabel ¶ added in v0.13.3
AddComponentLabel returns if the qbec component name should be added as an object label in addition to the standard annotation.
func (*App) BaseProperties ¶ added in v0.10.2
BaseProperties returns the baseline properties defined for the app.
func (*App) ClusterScopedLists ¶ added in v0.13.0
ClusterScopedLists returns the value of the qbec app attribute to determine if cluster scope lists should be performed when multiple namespaces are present.
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) Context ¶ added in v0.11.1
Context returns the context for the supplied environment, if set.
func (*App) DataSourceExamples ¶ added in v0.14.4
DataSourceExamples returns example output for data sources keyed by name.
func (*App) DataSources ¶ added in v0.14.0
DataSources returns the datasource URIs defined for the app.
func (*App) DeclaredComputedVars ¶ added in v0.14.0
func (a *App) DeclaredComputedVars() []ComputedVar
DeclaredComputedVars returns a list of all computed variables.
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) PostProcessors ¶ added in v0.13.4
PostProcessors returns the post processor files for the app.
func (*App) Properties ¶ added in v0.10.2
Properties returns the configured properties for the supplied environment, merge patched into the base properties object.
func (*App) ServerURL ¶ added in v0.6.2
ServerURL returns the server URL for the supplied environment.
func (*App) SetOverrideNamespace ¶ added in v0.11.0
SetOverrideNamespace sets an override namespace that is returned in preference to the value configured in qbec.yaml for any environment.
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"` // data sources defined for the app. DataSources []string `json:"dataSources,omitempty"` // example outputs for data sources for linter use DataSourceExamples map[string]interface{} `json:"dsExamples,omitempty"` // set of environments for the app Environments map[string]Environment `json:"environments"` // additional environments pulled in from external files EnvFiles []string `json:"envFiles,omitempty"` // 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"` // properties for the baseline environment, can be used to define what env properties should look like BaseProperties map[string]interface{} `json:"baseProperties,omitempty"` // whether remote lists for GC purposes should use cluster scoped queries // when multiple namespaces are present. Not used when only one namespace is present. ClusterScopedLists bool `json:"clusterScopedLists,omitempty"` // add component name as label to Kubernetes objects, default to false AddComponentLabel bool `json:"addComponentLabel,omitempty"` }
AppSpec is the user-supplied configuration of the qbec app.
type Component ¶
type Component struct { Name string // component name Files []string // path to main component file and possibly additional files TopLevelVars []string // the top-level variables used by the component }
Component is one or more logically related files that contains objects to be applied to a cluster.
type ComputedVar ¶ added in v0.14.0
ComputedVar is a variable that is computed based on evaluating jsonnet code.
type Directives ¶ added in v0.10.0
type Directives struct { ApplyOrder string // numeric apply order for object DeletePolicy string // delete policy "default" | "never" UpdatePolicy string // update policy "default" | "never" WaitPolicy string // wait policy "default" | "never" }
Directives is the list of directive names we support.
type Environment ¶
type Environment struct { DefaultNamespace string `json:"defaultNamespace"` // default namespace to set for k8s context Server string `json:"server,omitempty"` // server URL of server, must be present unless Context string `json:"context,omitempty"` // named context to use instead of deriving from server URL 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 Properties map[string]interface{} `json:"properties,omitempty"` // properties attached to the environment, exposed via an extvar }
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.
type Filters ¶ added in v0.15.2
type Filters struct {
// contains filtered or unexported fields
}
Filters is a collection of filters.
func (Filters) ComponentExcludes ¶ added in v0.15.2
ComponentExcludes returns the components requested to be excluded
func (Filters) ComponentIncludes ¶ added in v0.15.2
ComponentIncludes returns the components requested to be included
func (Filters) GVKFilter ¶ added in v0.15.2
func (f Filters) GVKFilter(gvk schema.GroupVersionKind) bool
GVKFilter returns true if the supplied GVK should be included.
func (Filters) HasNamespaceFilters ¶ added in v0.15.2
HasNamespaceFilters returns true if filters based on namespace scope are in effect.
func (Filters) Match ¶ added in v0.15.2
func (f Filters) Match(o K8sQbecMeta, client Namespaced, defaultNS string) (bool, error)
Match returns true if the current filters match the supplied object. The client can be nil if namespace scope filters are not in effect.
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{}, attrs LocalAttrs) 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 GetAnnotations() map[string]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 LocalAttrs ¶ added in v0.13.4
LocalAttrs are the attributes used to create local k8s objects.
type Namespaced ¶ added in v0.15.2
type Namespaced interface {
IsNamespaced(gvk schema.GroupVersionKind) (bool, error)
}
Namespaced provides metadata relating to whether a K8s type is namespaced or cluster scoped.
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 QbecEnvironmentMap ¶ added in v0.10.2
type QbecEnvironmentMap struct { // object kind // required: true // pattern: ^Environments$ Kind string `json:"kind"` // requested API version // required: true APIVersion string `json:"apiVersion"` // environments spec // require: true Spec QbecEnvironmentMapSpec `json:"spec"` }
QbecEnvironmentMap is a standalone object that contains a map of environments keyed by name.
type QbecEnvironmentMapSpec ¶ added in v0.10.2
type QbecEnvironmentMapSpec struct { // set of declared environments, keyed by name // required: true Environments map[string]Environment `json:"environments"` }
QbecEnvironmentMapSpec is the spec for a QbecEnvironmentMap object.
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 Computed []ComputedVar `json:"computed,omitempty"` // ordered collection of computed vars }
Variables is a collection of external and top-level variables.