Documentation
¶
Index ¶
- Variables
- func Create(ksApp app.App, name, text string, params param.Params, ...) (string, error)
- func Delete(a app.App, name string) error
- func GenParamsContent() []byte
- func MakePaths(a app.App, env string) ([]string, error)
- func Path(a app.App, name string) (string, error)
- func ResolvePath(ksApp app.App, path string) (Module, Component, error)
- type Component
- type FilesystemModule
- func (m *FilesystemModule) Components() ([]Component, error)
- func (m *FilesystemModule) DeleteParam(path []string) error
- func (m *FilesystemModule) Dir() string
- func (m *FilesystemModule) Name() string
- func (m *FilesystemModule) Params(envName string) ([]ModuleParameter, error)
- func (m *FilesystemModule) ParamsPath() string
- func (m *FilesystemModule) ResolvedParams() (string, error)
- func (m *FilesystemModule) SetParam(path []string, value interface{}) error
- type Jsonnet
- func (j *Jsonnet) DeleteParam(path []string, options ParamOptions) error
- func (j *Jsonnet) Name(wantsNameSpaced bool) string
- func (j *Jsonnet) Objects(paramsStr, envName string) ([]*unstructured.Unstructured, error)
- func (j *Jsonnet) Params(envName string) ([]ModuleParameter, error)
- func (j *Jsonnet) SetParam(path []string, value interface{}, options ParamOptions) error
- func (j *Jsonnet) Summarize() ([]Summary, error)
- type Manager
- type Module
- type ModuleParameter
- type ParamOptions
- type Summary
- type YAML
- func (y *YAML) DeleteParam(path []string, options ParamOptions) error
- func (y *YAML) Name(wantsNameSpaced bool) string
- func (y *YAML) Objects(paramsStr, envName string) ([]*unstructured.Unstructured, error)
- func (y *YAML) Params(envName string) ([]ModuleParameter, error)
- func (y *YAML) SetParam(path []string, value interface{}, options ParamOptions) error
- func (y *YAML) Summarize() ([]Summary, error)
Constants ¶
This section is empty.
Variables ¶
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 ¶
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.
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. If envName is a
// blank string, it will report the local parameters.
Params(envName string) ([]ModuleParameter, error)
// Summarize returns a summary of the component.
Summarize() ([]Summary, error)
}
Component is a ksonnet Component interface.
func ExtractComponent ¶
ExtractComponent extracts a component from a path.
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) 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 ¶
NewJsonnet creates an instance of Jsonnet.
func (*Jsonnet) DeleteParam ¶
func (j *Jsonnet) DeleteParam(path []string, options ParamOptions) error
DeleteParam deletes a param.
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(envName string) ([]ModuleParameter, error)
Params returns params for a component.
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)
// TODO: is this needed?
Dir() string
Name() string
Params(envName string) ([]ModuleParameter, error)
ParamsPath() string
ResolvedParams() (string, error)
SetParam(path []string, value interface{}) error
DeleteParam(path []string) error
}
Module is a component module
func ExtractModuleComponent ¶
ExtractModuleComponent extracts a module and a component from a path.
type ModuleParameter ¶
ModuleParameter is a module parameter.
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 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 (*YAML) DeleteParam ¶
func (y *YAML) DeleteParam(path []string, options ParamOptions) error
DeleteParam deletes a param.
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(envName string) ([]ModuleParameter, error)
Params returns params for a component.