config

package
v0.0.0-...-a480921 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Caveat:

* In this package we have global variable to define loading path.

* It means that we cannot have two separate non-loaded config files from this module.

CleanUp Interface

These functions serve to just one purpose: Make YAML be compatible with JSON.

In JSON we can have map keys with only one type

string -> (map[string]interface{})

but in YAML we can use other types. So we have a problem: YAML decoder can convert some nested map as map[interface{}]interface{} and this type cannot be validated with JSON. So we need to convert all map[interface{}]interface{} -> map[string]interface{}.

Additional info about this support from gopkg.in/yaml.v3: https://github.com/go-yaml/yaml/issues/139.

Environments

There are two kind of environments:

* simple - provided as string

* complex - provided as struct wih ability to override options

We use interface to hide implemenetation.

Projects

There are two kind of projects:

* simple - provided as string

* complex - provided as struct wih ability to override options

We use interface to hide implemenetation.

JSON Schema

Support JSON schema validation and data parsing from different formats with Conflate pkg

Index

Constants

View Source
const (
	// Default Schema for helmctl file in JSON format
	ConflateJSONSchema string = `` /* 4954-byte string literal not displayed */

)

Variables

View Source
var ConfigFilePath string = ""

Define global variable

View Source
var DryRun bool = false

Functions

func YAMLUnmarshal

func YAMLUnmarshal(data []byte, out interface{}) error

YAMLUnmarshal defines YAMLUnmarshal to use yaml3 library

Types

type Config

type Config interface {
	Load() error
	Repositories() []*Repository
	Releases() []*Release
	TargetRelease(name string, target string, targetType TargetType) (*Release, error)
	TargetReleases(target string, targetType TargetType) ([]*Release, error)
	Environments() []string
	Projects() []string
}

Config defines helmctl configuration.

func NewConfigFromFile

func NewConfigFromFile(file string, schema string, logger *logrus.Logger, dryRun bool) Config

NewConfigFromFile returns new config.

type CustomProcessor

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

CustomProcessor is a constructor struct

func (*CustomProcessor) UnmarshalYAML

func (i *CustomProcessor) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML adds additional parser to constructor

type Environment

type Environment interface {
	GetName() string
	GetValues() *Release
	SetValues(values map[string]interface{}) error
}

Environment interface type is used to hide different kind of envs

func NewEnvironmentComplex

func NewEnvironmentComplex(name string) Environment

NewEnvironmentComplex return new complex env with empty values

func NewEnvironmentSimple

func NewEnvironmentSimple(name string) Environment

NewEnvironmentSimple returns new simple env

type EnvironmentComplex

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

EnvironmentComplex complex env type

func (*EnvironmentComplex) GetName

func (e *EnvironmentComplex) GetName() string

GetName returns a name of env

func (*EnvironmentComplex) GetValues

func (e *EnvironmentComplex) GetValues() *Release

GetValues returns values

func (*EnvironmentComplex) SetValues

func (e *EnvironmentComplex) SetValues(values map[string]interface{}) error

SetValues set values

type EnvironmentSimple

type EnvironmentSimple string

EnvironmentSimple simple environment type

func (*EnvironmentSimple) GetName

func (e *EnvironmentSimple) GetName() string

GetName return a name of env

func (*EnvironmentSimple) GetValues

func (e *EnvironmentSimple) GetValues() *Release

GetValues returns empty values

func (*EnvironmentSimple) SetValues

func (e *EnvironmentSimple) SetValues(values map[string]interface{}) error

SetValues does nothing

type File

type File struct {
	Spec struct {
		Repositories []*Repository
		Releases     []*Release
		Installs     Installs
	}
	// contains filtered or unexported fields
}

File is Config implementation.

func (*File) Environments

func (cf *File) Environments() []string

func (*File) Load

func (cf *File) Load() (err error)

Load loads config from file.

func (*File) Projects

func (cf *File) Projects() []string

func (*File) ReleaseGet

func (cf *File) ReleaseGet(name string) (*Release, error)

ReleaseGet returns release object.

func (*File) Releases

func (cf *File) Releases() []*Release

Releases returns list defined of releases.

func (*File) Repositories

func (cf *File) Repositories() []*Repository

Repositories returns list of defined repositories.

func (*File) TargetRelease

func (cf *File) TargetRelease(name string, target string, targetType TargetType) (*Release, error)

TargetRelease returns releases associated to the target

func (*File) TargetReleases

func (cf *File) TargetReleases(target string, targetType TargetType) ([]*Release, error)

TargetReleases returns releases associated to the target.

type Fragment

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

Fragment is used for loading custom variables

func (*Fragment) UnmarshalYAML

func (f *Fragment) UnmarshalYAML(value *yaml.Node) (err error)

UnmarshalYAML adds additional processor to parser

type Installs

type Installs struct {
	Environments map[string][]*Environment
	Projects     map[string][]*Project
}

Installs maps releases with environments and projects.

func (*Installs) Validate

func (i *Installs) Validate() error

Validate that all parts of Installs do not have duplicates

type Project

type Project interface {
	GetName() string
	GetValues() *Release
	SetValues(values map[string]interface{}) error
}

Project interface

func NewProjectComplex

func NewProjectComplex(name string) Project

NewProjectComplex returns new complex project with empty values

func NewProjectSimple

func NewProjectSimple(name string) Project

NewProjectSimple returns new simple project

type ProjectComplex

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

ProjectComplex complex project type

func (*ProjectComplex) GetName

func (e *ProjectComplex) GetName() string

GetName returns a name of project

func (*ProjectComplex) GetValues

func (e *ProjectComplex) GetValues() *Release

GetValues returns values

func (*ProjectComplex) SetValues

func (e *ProjectComplex) SetValues(values map[string]interface{}) error

SetValues set alues for complex project

type ProjectSimple

type ProjectSimple string

ProjectSimple simple project type

func (*ProjectSimple) GetName

func (e *ProjectSimple) GetName() string

GetName returns a name of project

func (*ProjectSimple) GetValues

func (e *ProjectSimple) GetValues() *Release

GetValues returns empty values

func (*ProjectSimple) SetValues

func (e *ProjectSimple) SetValues(values map[string]interface{}) error

SetValues does nothing

type Release

type Release struct {
	Name          string
	Chart         string
	Version       string
	Namespace     string
	BeforeScripts []*string
	AfterScripts  []*string
	Atomic        *bool
	Repository    *Repository
	Values        []*Value
	ValueFiles    []*ValueFile

	IncludePath string
}

Release represents helm release with values.

type Repository

type Repository struct {
	Name     string
	URL      string
	User     string
	Password string
}

Repository represents helm repository object.

type TargetType

type TargetType string

TargetType is a helm target type.

const (
	TargetEnvironments TargetType = "environments"
	TargetProjects     TargetType = "projects"
)

Define target types

type Value

type Value struct {
	Name  string
	Value interface{}
	Type  string
}

Value represents helm value. This value will be setted via --set argument to helm.

func (*Value) GetKeyValuePair

func (v *Value) GetKeyValuePair() string

type ValueFile

type ValueFile struct {
	Name    string
	Decrypt *bool
}

ValueFile represents helm value file.

func (*ValueFile) GetDecrypt

func (vf *ValueFile) GetDecrypt() bool

Jump to

Keyboard shortcuts

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