component

package
v0.0.0-...-87b999f Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2018 License: Apache-2.0 Imports: 26 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ImportYaml

func ImportYaml(r io.Reader) (*TypeSpec, Properties, error)

ImportYaml converts a reader containing YAML to a TypeSpec and Properties.

func MakePaths

func MakePaths(a app.App, env string) ([]string, error)

MakePaths creates a slice of component paths

func MakePathsByNamespace

func MakePathsByNamespace(a app.App, env string) (map[Namespace][]string, error)

MakePathsByNamespace creates a map of component paths categorized by namespace.

func Path

func Path(a app.App, name string) (string, error)

Path returns returns the file system path for a component.

Types

type Component

type Component interface {
	// Name is the component name.
	Name(wantsNamedSpaced bool) string
	// Objects converts the component to a set of objects.
	Objects(paramsStr, envName string) ([]*unstructured.Unstructured, error)
	// SetParams sets a component paramaters.
	SetParam(path []string, value interface{}, options ParamOptions) error
	// DeleteParam deletes a component parameter.
	DeleteParam(path []string, options ParamOptions) error
	// Params returns a list of all parameters for a component.
	Params() ([]NamespaceParameter, error)
	// Summarize returns a summary of the component.
	Summarize() ([]Summary, error)
}

Component is a ksonnet Component interface.

func ExtractComponent

func ExtractComponent(a app.App, path string) (Component, error)

ExtractComponent extracts a component from a path.

type GVK

type GVK struct {
	GroupPath []string
	Version   string
	Kind      string
}

GVK is a group, version, kind descriptor.

func (*GVK) Group

func (gvk *GVK) Group() []string

Group returns the group this GVK represents.

func (*GVK) Path

func (gvk *GVK) Path() []string

Path returns the path of the current descriptor as a slice of strings.

type Jsonnet

type Jsonnet struct {
	// contains filtered or unexported fields
}

Jsonnet is a component base on jsonnet.

func NewJsonnet

func NewJsonnet(a app.App, nsName, source, paramsPath string) *Jsonnet

NewJsonnet creates an instance of Jsonnet.

func (*Jsonnet) DeleteParam

func (j *Jsonnet) DeleteParam(path []string, options ParamOptions) error

DeleteParam deletes a param.

func (*Jsonnet) Name

func (j *Jsonnet) Name(wantsNameSpaced bool) string

Name is the name of this component.

func (*Jsonnet) Objects

func (j *Jsonnet) Objects(paramsStr, envName string) ([]*unstructured.Unstructured, error)

Objects converts jsonnet to a slice of apimachinery unstructured objects.

func (*Jsonnet) Params

func (j *Jsonnet) Params() ([]NamespaceParameter, error)

Params returns params for a component.

func (*Jsonnet) SetParam

func (j *Jsonnet) SetParam(path []string, value interface{}, options ParamOptions) error

SetParam set parameter for a component.

func (*Jsonnet) Summarize

func (j *Jsonnet) Summarize() ([]Summary, error)

Summarize creates a summary for the component.

type Namespace

type Namespace struct {
	// contains filtered or unexported fields
}

Namespace is a component namespace.

func ExtractNamespacedComponent

func ExtractNamespacedComponent(a app.App, path string) (Namespace, string)

ExtractNamespacedComponent extracts a namespace and a component from a path.

func GetNamespace

func GetNamespace(a app.App, nsName string) (Namespace, error)

GetNamespace gets a namespace by path.

func Namespaces

func Namespaces(a app.App) ([]Namespace, error)

Namespaces returns all component namespaces

func NamespacesFromEnv

func NamespacesFromEnv(a app.App, env string) ([]Namespace, error)

NamespacesFromEnv returns all namespaces given an environment.

func NewNamespace

func NewNamespace(ksApp app.App, path string) Namespace

NewNamespace creates an instance of Namespace.

func (*Namespace) Components

func (n *Namespace) Components() ([]Component, error)

Components returns the components in a namespace.

func (*Namespace) Dir

func (n *Namespace) Dir() string

Dir is the absolute directory for a namespace.

func (*Namespace) Name

func (n *Namespace) Name() string

Name returns the namespace name.

func (*Namespace) Params

func (n *Namespace) Params() ([]NamespaceParameter, error)

Params returns the params for a namespace.

func (*Namespace) ParamsPath

func (n *Namespace) ParamsPath() string

ParamsPath generates the path to params.libsonnet for a namespace.

func (*Namespace) ResolvedParams

func (n *Namespace) ResolvedParams() (string, error)

ResolvedParams resolves paramaters for a namespace. It returns a JSON encoded string of component parameters.

func (*Namespace) SetParam

func (n *Namespace) SetParam(path []string, value interface{}) error

SetParam sets params for a namespace.

type NamespaceParameter

type NamespaceParameter struct {
	Component string
	Index     string
	Key       string
	Value     string
}

NamespaceParameter is a namespaced paramater.

type ParamOptions

type ParamOptions struct {
	Index int
}

ParamOptions is options for parameters.

type Properties

type Properties map[interface{}]interface{}

Properties are document properties

func (Properties) Name

func (p Properties) Name() (string, error)

Name extract name or generateName from metadata. If either are not found, it returns an error.

func (Properties) Paths

func (p Properties) Paths(gvk GVK) []PropertyPath

Paths returns a list of paths in properties.

func (Properties) Value

func (p Properties) Value(path []string) (interface{}, error)

Value returns the value at a path.

type PropertyPath

type PropertyPath struct {
	Path  []string
	Value interface{}
}

PropertyPath contains a property path.

type Summary

type Summary struct {
	ComponentName string
	IndexStr      string
	Index         int
	Type          string
	APIVersion    string
	Kind          string
	Name          string
}

Summary summarizes items found in components.

type TypeSpec

type TypeSpec struct {
	// contains filtered or unexported fields
}

TypeSpec describes an object's type.

func NewTypeSpec

func NewTypeSpec(apiVersion, kind string) (*TypeSpec, error)

NewTypeSpec creates an instance of TypeSpec.

func (TypeSpec) GVK

func (ts TypeSpec) GVK() GVK

GVK returns the GVK descriptor for the TypeSpec.

func (TypeSpec) Group

func (ts TypeSpec) Group() []string

Group is the group as defined by the TypeSpec.

func (TypeSpec) Kind

func (ts TypeSpec) Kind() string

Kind is the kind as specified by the TypeSpec.

func (TypeSpec) Version

func (ts TypeSpec) Version() string

Version is the version as defined by the TypeSpec.

type ValueExtractor

type ValueExtractor struct {
	// contains filtered or unexported fields
}

ValueExtractor extracts Values from a manifest.

func NewValueExtractor

func NewValueExtractor(root *astext.Object) *ValueExtractor

NewValueExtractor creates an instance of ValueExtractor.

func (*ValueExtractor) Extract

func (ve *ValueExtractor) Extract(gvk GVK, props Properties) (map[string]Values, error)

Extract extracts values from an object.

type Values

type Values struct {
	Lookup []string
	Setter string
	Value  interface{}
}

Values are values extracted from a manifest.

type YAML

type YAML struct {
	// contains filtered or unexported fields
}

YAML represents a YAML component. Since JSON is a subset of YAML, it can handle JSON as well.

func NewYAML

func NewYAML(a app.App, nsName, source, paramsPath string) *YAML

NewYAML creates an instance of YAML.

func (*YAML) DeleteParam

func (y *YAML) DeleteParam(path []string, options ParamOptions) error

DeleteParam deletes a param.

func (*YAML) Name

func (y *YAML) Name(wantsNameSpaced bool) string

Name is the component name.

func (*YAML) Objects

func (y *YAML) Objects(paramsStr, envName string) ([]*unstructured.Unstructured, error)

Objects converts YAML to a slice of apimachinery Unstructured objects. Params for a YAML based component are keyed like, `name-id`, where `name` is the file name sans the extension, and the id is the position within the file (starting at 0). Params are named this way because a YAML file can contain more than one object.

func (*YAML) Params

func (y *YAML) Params() ([]NamespaceParameter, error)

Params returns params for a component.

func (*YAML) SetParam

func (y *YAML) SetParam(path []string, value interface{}, options ParamOptions) error

SetParam set parameter for a component.

func (*YAML) Summarize

func (y *YAML) Summarize() ([]Summary, error)

Summarize generates a summary for a YAML component. For each manifest, it will return a slice of summaries of resources described.

Directories

Path Synopsis
Code generated by mockery v1.0.0
Code generated by mockery v1.0.0

Jump to

Keyboard shortcuts

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