component

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2018 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TypeJsonnet is a Jsonnet component.
	TypeJsonnet = "jsonnet"
)
View Source
const (
	// TypeYAML is a YAML component.
	TypeYAML = "yaml"
)

Variables

View Source
var (
	// DefaultManager is the default manager for components.
	DefaultManager = &defaultManager{}
)

Functions

func Create

func Create(ksApp app.App, moduleName, name, text string, params param.Params, templateType prototype.TemplateType) (string, error)

Create creates a component.

func Delete

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

Delete deletes the component file and all references. Write operations will happen at the end to minimal-ize failures that leave the directory structure in a half-finished state.

func FromName added in v0.12.0

func FromName(name string) (string, string)

FromName returns a module and a component name given a component description. Component descriptions can be one of the following:

module.component
component

func GenParamsContent

func GenParamsContent() []byte

GenParamsContent is the default content for params.libsonnet.

func MakePaths

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

MakePaths creates a slice of component paths

func ModuleFromPath added in v0.12.0

func ModuleFromPath(a app.App, path string) string

ModuleFromPath returns a module name from a file system path.

func Path

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

Path returns returns the file system path for a component.

func ResolvePath

func ResolvePath(ksApp app.App, path string) (Module, Component, error)

ResolvePath resolves a given path to a module and a component.

Types

type Component

type Component interface {
	// DeleteParam deletes a component parameter.
	DeleteParam(path []string) error
	// Name is the component name.
	Name(wantsNamedSpaced bool) string
	// Params returns a list of all parameters for a component. If envName is a
	// blank string, it will report the local parameters.
	Params(envName string) ([]ModuleParameter, error)
	// Remove removes the component
	Remove() error
	// SetParams sets a component paramaters.
	SetParam(path []string, value interface{}) error
	// Summarize returns a summary of the component.
	Summarize() (Summary, error)
	// ToNode converts a component to a Jsonnet node.
	ToNode(envName string) (string, ast.Node, error)
	// Type returns the type of component.
	Type() string
}

Component is a ksonnet Component interface.

func ExtractComponent

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

ExtractComponent extracts a component from a path.

func LocateComponent

func LocateComponent(ksApp app.App, module, name string) (Component, error)

LocateComponent locates a component given a module and a name.

type FilesystemModule

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

FilesystemModule is a component module that uses a filesystem for storage.

func NewModule

func NewModule(ksApp app.App, path string) *FilesystemModule

NewModule creates an instance of module.

func (*FilesystemModule) Components

func (m *FilesystemModule) Components() ([]Component, error)

Components returns the components in a module.

func (*FilesystemModule) DeleteParam

func (m *FilesystemModule) DeleteParam(path []string) error

DeleteParam deletes params for a module.

func (*FilesystemModule) Dir

func (m *FilesystemModule) Dir() string

Dir is the absolute directory for a module.

func (*FilesystemModule) Name

func (m *FilesystemModule) Name() string

Name returns the module name.

func (*FilesystemModule) Params

func (m *FilesystemModule) Params(envName string) ([]ModuleParameter, error)

Params returns the params for a module.

func (*FilesystemModule) ParamsPath

func (m *FilesystemModule) ParamsPath() string

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

func (*FilesystemModule) ParamsSource added in v0.12.0

func (m *FilesystemModule) ParamsSource() (io.ReadCloser, error)

ParamsSource returns the source of params for a module as a reader.

func (*FilesystemModule) Render

func (m *FilesystemModule) Render(envName string, componentNames ...string) (*astext.Object, map[string]string, error)

Render converts components to JSON. If there are component names, only include those components.

func (*FilesystemModule) ResolvedParams

func (m *FilesystemModule) ResolvedParams(envName string) (string, error)

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

func (*FilesystemModule) SetParam

func (m *FilesystemModule) SetParam(path []string, value interface{}) error

SetParam sets params for a module.

type Jsonnet

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

Jsonnet is a component base on jsonnet.

func NewJsonnet

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

NewJsonnet creates an instance of Jsonnet.

func (*Jsonnet) DeleteParam

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

DeleteParam deletes a param.

func (*Jsonnet) Name

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

Name is the name of this component.

func (*Jsonnet) Params

func (j *Jsonnet) Params(envName string) ([]ModuleParameter, error)

Params returns params for a component.

func (*Jsonnet) Remove added in v0.12.0

func (j *Jsonnet) Remove() error

Remove removes the component.

func (*Jsonnet) SetParam

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

SetParam set parameter for a component.

func (*Jsonnet) Summarize

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

Summarize creates a summary for the component.

func (*Jsonnet) ToNode

func (j *Jsonnet) ToNode(envName string) (string, ast.Node, error)

ToNode converts a Jsonnet component to a Jsonnet node.

func (*Jsonnet) Type

func (j *Jsonnet) Type() string

Type always returns "jsonnet".

type Manager

type Manager interface {
	Components(ksApp app.App, module string) ([]Component, error)
	Component(ksApp app.App, module, componentName string) (Component, error)
	CreateModule(ksApp app.App, name string) error
	Module(ksApp app.App, moduleName string) (Module, error)
	Modules(ksApp app.App, envName string) ([]Module, error)
}

Manager is an interface for interacting with components.

type Module

type Module interface {
	// Components returns a slice of components in this module.
	Components() ([]Component, error)
	// DeleteParam deletes a parameter.
	DeleteParam(path []string) error
	// Dir returns the directory for the module.
	Dir() string
	// Name is the name of the module.
	Name() string
	// Params returns parameters defined in this module.
	Params(envName string) ([]ModuleParameter, error)
	// ParamsPath returns the path of the parameters for this module
	ParamsPath() string
	// paramsSource returns the source of the params for this module.
	ParamsSource() (io.ReadCloser, error)
	// Render renders the components in the module to a Jsonnet object.
	Render(envName string, componentNames ...string) (*astext.Object, map[string]string, error)
	// ResolvedParams evaluates the parameters for a module within an environment.
	ResolvedParams(envName string) (string, error)
	// SetParam sets a parameter for module.
	SetParam(path []string, value interface{}) error
}

Module is a component module

func GetModule

func GetModule(a app.App, moduleName string) (Module, error)

GetModule gets a module by path.

func Modules

func Modules(a app.App) ([]Module, error)

Modules returns all component modules

func ModulesFromEnv

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

ModulesFromEnv returns all modules given an environment. If environment == "", all modules (globally) are returned.

type ModuleParameter

type ModuleParameter struct {
	Component string
	Key       string
	Value     string
}

ModuleParameter is a module parameter.

func (*ModuleParameter) IsSameType

func (mp *ModuleParameter) IsSameType(other ModuleParameter) bool

IsSameType returns true if the other ModuleParams is the same type. The types are the same if the component, index, and key match.

type ParamOptions

type ParamOptions struct {
	Index int
}

ParamOptions is options for parameters.

type Summary

type Summary struct {
	ComponentName string `json:"component_name,omitempty"`
	Type          string `json:"type,omitempty"`
	APIVersion    string `json:"api_version,omitempty"`
	Kind          string `json:"kind,omitempty"`
	Name          string `json:"name,omitempty"`
}

Summary summarizes items found in components.

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, module, source, paramsPath string) *YAML

NewYAML creates an instance of YAML.

func (*YAML) DeleteParam

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

DeleteParam deletes a param.

func (*YAML) Name

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

Name is the component name.

func (*YAML) Params

func (y *YAML) Params(envName string) ([]ModuleParameter, error)

Params returns params for a component.

func (*YAML) Remove added in v0.12.0

func (y *YAML) Remove() error

Remove removes the component.

func (*YAML) SetParam

func (y *YAML) SetParam(path []string, value interface{}) 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.

func (*YAML) ToNode

func (y *YAML) ToNode(envName string) (string, ast.Node, error)

ToNode converts a YAML component to a Jsonnet node.

func (*YAML) Type

func (y *YAML) Type() string

Type always returns "yaml".

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