configloader

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	GOOS   string = runtime.GOOS
	GOARCH string = runtime.GOARCH
)

Functions

func GetPluginFileName

func GetPluginFileName(t *Tool) string

GetPluginFileName creates the file name based on the tool's name and version If the plugin {githubactions 0.0.1}, the generated name will be "githubactions_0.0.1.so"

func GetPluginMD5FileName

func GetPluginMD5FileName(t *Tool) string

GetPluginMD5FileName If the plugin {githubactions 0.0.1}, the generated name will be "githubactions_0.0.1.md5"

func GetPluginName added in v0.8.0

func GetPluginName(t *Tool) string

GetPluginName return plugin name without file extensions

func SplitConfigFileBytes added in v0.7.0

func SplitConfigFileBytes(fileBytes []byte) (coreConfig []byte, varConfig []byte, toolConfig []byte, err error)

SplitConfigFileBytes take the original config file and split it to: 1. core config 2. variables config 3. tools config Original config should be like below: --- # core config varFile: "" # If not empty, use the specified external variables config file toolFile: "" # If not empty, use the specified external tools config file state:

backend: local
options:
  stateFile: devstream.state

--- # variables config foo: bar

--- # plugins config tools:

  • name: A-PLUGIN-NAME instanceID: default options: foo: bar

See https://github.com/devstream-io/devstream/issues/596 for more details.

Types

type Config

type Config struct {
	Tools []Tool `yaml:"tools"`
	State *State
}

Config is the struct for loading DevStream configuration YAML files. It records rendered config values and is used as a general config in DevStream.

func LoadConfig added in v0.7.0

func LoadConfig(configFileName string) (*Config, error)

LoadConfig reads an input file as a general config.

func (*Config) Validate added in v0.7.0

func (c *Config) Validate() []error

func (*Config) ValidateDependency added in v0.7.0

func (c *Config) ValidateDependency() []error

type CoreConfig added in v0.7.0

type CoreConfig struct {
	// TODO(daniel-hutao): Relative path support
	VarFile string `yaml:"varFile"`
	// TODO(daniel-hutao): Relative path support
	ToolFile string `yaml:"toolFile"`
	State    *State `yaml:"state"`
}

CoreConfig is the struct representing the complete original configuration YAML files.

func (*CoreConfig) ParseToolFilePath added in v0.7.0

func (c *CoreConfig) ParseToolFilePath() error

func (*CoreConfig) ParseVarFilePath added in v0.7.0

func (c *CoreConfig) ParseVarFilePath() error

func (*CoreConfig) Validate added in v0.7.0

func (c *CoreConfig) Validate() (bool, error)

type State added in v0.5.0

type State struct {
	Backend string             `yaml:"backend"`
	Options StateConfigOptions `yaml:"options"`
}

State is the struct for reading the state configuration in the config file. It defines how the state is stored, specifies the type of backend and related options.

type StateConfigOptions added in v0.6.0

type StateConfigOptions struct {
	// for s3 backend
	Bucket string `yaml:"bucket"`
	Region string `yaml:"region"`
	Key    string `yaml:"key"`
	// for local backend
	StateFile string `yaml:"stateFile"`
}

StateConfigOptions is the struct for reading the options of the state backend.

type Tool

type Tool struct {
	Name string `yaml:"name" validate:"required"`
	// RFC 1123 - DNS Subdomain Names style
	// contain no more than 253 characters
	// contain only lowercase alphanumeric characters, '-' or '.'
	// start with an alphanumeric character
	// end with an alphanumeric character
	InstanceID string                 `yaml:"instanceID" validate:"required,dns1123subdomain"`
	DependsOn  []string               `yaml:"dependsOn"`
	Options    map[string]interface{} `yaml:"options"`
}

Tool is the struct for one section of the DevStream tool file (part of the config.)

func NewToolWithToolConfigBytesAndVarsConfigBytes added in v0.7.0

func NewToolWithToolConfigBytesAndVarsConfigBytes(toolConfigBytes, varConfigBytes []byte) ([]Tool, error)

func NewToolWithToolConfigFileAndVarsConfigFile added in v0.7.0

func NewToolWithToolConfigFileAndVarsConfigFile(toolFilePath, varFilePath string) ([]Tool, error)

func (*Tool) DeepCopy

func (t *Tool) DeepCopy() *Tool

func (*Tool) Key added in v0.7.0

func (t *Tool) Key() string

func (*Tool) Validate added in v0.7.0

func (t *Tool) Validate() []error

Jump to

Keyboard shortcuts

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