Documentation ¶
Index ¶
- Constants
- Variables
- func Create(ksApp app.App, moduleName, name, text string, params param.Params, ...) (string, error)
- func Delete(a app.App, name string) error
- func FromName(name string) (string, string)
- func GenParamsContent() []byte
- func MakePaths(a app.App, env string) ([]string, error)
- func ModuleFromPath(a app.App, path string) string
- 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) ParamsSource() (io.ReadCloser, error)
- func (m *FilesystemModule) Render(envName string, componentNames ...string) (*astext.Object, map[string]string, error)
- func (m *FilesystemModule) ResolvedParams(envName string) (string, error)
- func (m *FilesystemModule) SetParam(path []string, value interface{}) error
- type Jsonnet
- func (j *Jsonnet) DeleteParam(path []string) error
- func (j *Jsonnet) Name(wantsNameSpaced bool) string
- func (j *Jsonnet) Params(envName string) ([]ModuleParameter, error)
- func (j *Jsonnet) Remove() error
- func (j *Jsonnet) SetParam(path []string, value interface{}) error
- func (j *Jsonnet) Summarize() (Summary, error)
- func (j *Jsonnet) ToNode(envName string) (string, ast.Node, error)
- func (j *Jsonnet) Type() string
- type Manager
- type Module
- type ModuleParameter
- type ParamOptions
- type Summary
- type YAML
- func (y *YAML) DeleteParam(path []string) error
- func (y *YAML) Name(wantsNameSpaced bool) string
- func (y *YAML) Params(envName string) ([]ModuleParameter, error)
- func (y *YAML) Remove() error
- func (y *YAML) SetParam(path []string, value interface{}) error
- func (y *YAML) Summarize() (Summary, error)
- func (y *YAML) ToNode(envName string) (string, ast.Node, error)
- func (y *YAML) Type() string
Constants ¶
const (
// TypeJsonnet is a Jsonnet component.
TypeJsonnet = "jsonnet"
)
const (
// TypeYAML is a YAML component.
TypeYAML = "yaml"
)
Variables ¶
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 ¶
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
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 ModuleFromPath ¶ added in v0.12.0
ModuleFromPath returns a module name from a file system path.
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 ¶
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) 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 ¶
NewJsonnet creates an instance of Jsonnet.
func (*Jsonnet) DeleteParam ¶
DeleteParam deletes a param.
func (*Jsonnet) Params ¶
func (j *Jsonnet) Params(envName string) ([]ModuleParameter, error)
Params returns params for a component.
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
type ModuleParameter ¶
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 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 (*YAML) DeleteParam ¶
DeleteParam deletes a param.
func (*YAML) Params ¶
func (y *YAML) Params(envName string) ([]ModuleParameter, error)
Params returns params for a component.
func (*YAML) Summarize ¶
Summarize generates a summary for a YAML component. For each manifest, it will return a slice of summaries of resources described.