component

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 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, 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 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 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)

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)
	// 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) 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() (string, error)

ResolvedParams resolves paramaters 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) 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(ns Module) ([]Component, error)
	Component(ksApp app.App, module, componentName string) (Component, error)
	CreateComponent(ksApp app.App, name, text string, params param.Params, templateType prototype.TemplateType) (string, error)
	CreateModule(ksApp app.App, name string) error
	Module(ksApp app.App, moduleName string) (Module, error)
	Modules(ksApp app.App, envName string) ([]Module, error)
	NSResolveParams(ns Module) (string, error)
}

Manager is an interface for interating with components.

type Module

type Module interface {
	Components() ([]Component, error)
	DeleteParam(path []string) error
	Dir() string
	Name() string
	Params(envName string) ([]ModuleParameter, error)
	ParamsPath() string
	Render(envName string, componentNames ...string) (*astext.Object, map[string]string, error)
	ResolvedParams() (string, error)
	SetParam(path []string, value interface{}) error
}

Module is a component module

func ExtractModuleComponent

func ExtractModuleComponent(a app.App, path string) (Module, string)

ExtractModuleComponent extracts a module and a component from a path.

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.

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
	Type          string
	APIVersion    string
	Kind          string
	Name          string
}

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