model

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2019 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package model contains the app definition and interfaces for dealing with K8s objects.

Index

Constants

View Source
const (
	DefaultComponentsDir = "components"       // the default components directory
	DefaultParamsFile    = "params.libsonnet" // the default params files
)

Default values

View Source
const Baseline = "_"

Baseline is a special environment name that represents the baseline environment with no customizations.

View Source
const LatestAPIVersion = "qbec.io/v1alpha1"

LatestAPIVersion is the latest version of the API we support.

Variables

View Source
var QbecNames = struct {
	ApplicationLabel    string // the label to use for tagging an object with an application name
	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
}{
	ApplicationLabel:    qbecLeading + "/application",
	ComponentAnnotation: qbecLeading + "/component",
	EnvironmentLabel:    qbecLeading + "/environment",
	PristineAnnotation:  qbecLeading + "/last-applied",
	ParamsCodeVarName:   qbecLeading + "/params",
	EnvVarName:          qbecLeading + "/env",
}

QbecNames is the set of names used by Qbec.

Functions

func HasSensitiveInfo

func HasSensitiveInfo(obj *unstructured.Unstructured) bool

HasSensitiveInfo returns true if the supplied object has sensitive data that might need to be hidden.

func HideSensitiveInfo

func HideSensitiveInfo(obj *unstructured.Unstructured) (*unstructured.Unstructured, bool)

HideSensitiveInfo creates a new object for secrets where secret values have been replaced with stable strings that can still be diff-ed. It returns a boolean to indicate that the return value was modified from the original object. When no modifications are needed, the original object is returned as-is.

Types

type App

type App struct {
	QbecApp
	// contains filtered or unexported fields
}

App is a qbec application wrapped with some runtime attributes.

func NewApp

func NewApp(file string) (*App, error)

NewApp returns an app loading its details from the supplied file.

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) Name

func (a *App) Name() string

Name returns the name of the application.

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"`
	// 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"`
}

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
}

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 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

func NewComponentFilter(includes, excludes []string) (Filter, error)

NewComponentFilter returns a filter for component names.

func NewKindFilter

func NewKindFilter(includes, excludes []string) (Filter, error)

NewKindFilter returns a filter for object kinds that ignores case and takes pluralization into account.

type K8sKind

type K8sKind interface {
	GetKind() string
}

K8sKind is something that has a kind.

type K8sLocalObject

type K8sLocalObject interface {
	K8sObject
	QbecMeta
}

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 HideSensitiveLocalInfo

func HideSensitiveLocalInfo(in K8sLocalObject) (K8sLocalObject, bool)

HideSensitiveLocalInfo is like HideSensitiveInfo but for local objects.

func NewK8sLocalObject

func NewK8sLocalObject(data map[string]interface{}, app, 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 {
	K8sKind
	GetObjectKind() schema.ObjectKind
	GetNamespace() string
	GetName() 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

func NewK8sObject(data map[string]interface{}) K8sObject

NewK8sObject wraps a K8sObject implementation around the unstructured object data specified as a bag of attributes.

type K8sQbecMeta

type K8sQbecMeta interface {
	K8sMeta
	QbecMeta
}

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
}

QbecMeta provides qbec metadata.

Jump to

Keyboard shortcuts

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