data

package
v0.0.0-...-c2786f3 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Generators = make([]Generator, 0)

Functions

func ConvertToYaml

func ConvertToYaml(root Node) interface{}

Converts internal node tree to Yaml

func GetEncodedSecrets

func GetEncodedSecrets(scriptName string, destinationDir string, name string, descriptorPath string) (map[string]string, error)

func ToMap

func ToMap(node Node) interface{}

Types

type Apply

type Apply struct {
	DefaultVisitor
	Path     Path
	Function func(interface{}) interface{}
}

func (*Apply) OnKey

func (visitor *Apply) OnKey(node *KeyNode)

type ConfigGenerator

type ConfigGenerator struct {
}

func (*ConfigGenerator) Generate

func (*ConfigGenerator) Generate(sourceDir string, destinationDir string) ([]*Resource, error)

func (*ConfigGenerator) IsManagedDir

func (*ConfigGenerator) IsManagedDir(dir string) bool

type ConfigSource

type ConfigSource struct {
	Url  string `yaml:",omitempty"`
	Path string `yaml:",omitempty"`
}

type Configuration

type Configuration struct {
	Name            string                `yaml:",omitempty"`
	Description     string                `yaml:",omitempty"`
	Source          []ConfigSource        `yaml:",omitempty"`
	Import          []ImportConfiguration `yaml:",omitempty"`
	Transformations []yaml.MapSlice       `yaml:",omitempty"`
	ResourcesDir    string                `yaml:"resources,omitempty"`
	Standalone      bool                  `yaml:"-"`
	Header          string                `yaml:"header"`
}

func ReadConfiguration

func ReadConfiguration(dir string) (Configuration, string, error)

read configuration from flekszible.yaml or Flekszible file

type DefaultVisitor

type DefaultVisitor struct{}

func (DefaultVisitor) AfterList

func (DefaultVisitor) AfterList(node *ListNode)

func (DefaultVisitor) AfterListItem

func (DefaultVisitor) AfterListItem(node *ListNode, item Node, index int)

func (DefaultVisitor) AfterMap

func (DefaultVisitor) AfterMap(node *MapNode)

func (DefaultVisitor) AfterMapItem

func (DefaultVisitor) AfterMapItem(node *MapNode, key string, index int)

func (DefaultVisitor) BeforeList

func (DefaultVisitor) BeforeList(node *ListNode)

func (DefaultVisitor) BeforeListItem

func (DefaultVisitor) BeforeListItem(node *ListNode, item Node, index int)

func (DefaultVisitor) BeforeMap

func (DefaultVisitor) BeforeMap(node *MapNode)

func (DefaultVisitor) BeforeMapItem

func (DefaultVisitor) BeforeMapItem(node *MapNode, key string, index int)

func (DefaultVisitor) OnKey

func (DefaultVisitor) OnKey(*KeyNode)

type Downloader

type Downloader interface {
	Download(url string, destinationDir string, rootPath string) error
}
var DownloaderPlugin Downloader = NodeDownloader{}

type EnvSource

type EnvSource struct {
	Dir string
}

func (*EnvSource) GetPath

func (source *EnvSource) GetPath(manager *SourceCacheManager) (string, error)

func (*EnvSource) ToString

func (source *EnvSource) ToString() string

type FixPath

type FixPath struct {
	DefaultVisitor
	CurrentPath Path
}

func (*FixPath) AfterList

func (visitor *FixPath) AfterList(node *ListNode)

func (*FixPath) AfterListItem

func (visitor *FixPath) AfterListItem(node *ListNode, item Node, index int)

func (*FixPath) AfterMap

func (visitor *FixPath) AfterMap(node *MapNode)

func (*FixPath) AfterMapItem

func (visitor *FixPath) AfterMapItem(node *MapNode, key string, index int)

func (*FixPath) BeforeList

func (visitor *FixPath) BeforeList(node *ListNode)

func (*FixPath) BeforeListItem

func (visitor *FixPath) BeforeListItem(node *ListNode, item Node, index int)

func (*FixPath) BeforeMap

func (visitor *FixPath) BeforeMap(node *MapNode)

func (*FixPath) BeforeMapItem

func (visitor *FixPath) BeforeMapItem(node *MapNode, key string, index int)

func (*FixPath) OnKey

func (visitor *FixPath) OnKey(node *KeyNode)

type Generator

type Generator interface {
	Generate(sourceDir string, destinationDir string) ([]*Resource, error)
	IsManagedDir(dir string) bool
}

type Get

type Get struct {
	DefaultVisitor
	Path        Path
	ReturnValue Node
	Found       bool
}

func (*Get) BeforeList

func (visitor *Get) BeforeList(node *ListNode)

func (*Get) BeforeMap

func (visitor *Get) BeforeMap(node *MapNode)

func (*Get) OnKey

func (visitor *Get) OnKey(node *KeyNode)

func (*Get) ValueAsString

func (visitor *Get) ValueAsString() string

type GetAll

type GetAll struct {
	DefaultVisitor
	Path   Path
	Result []GetAllResult
}

func (*GetAll) BeforeList

func (visitor *GetAll) BeforeList(node *ListNode)

func (*GetAll) BeforeMap

func (visitor *GetAll) BeforeMap(node *MapNode)

func (*GetAll) OnKey

func (visitor *GetAll) OnKey(node *KeyNode)

type GetAllResult

type GetAllResult struct {
	Path  Path
	Value Node
}

type GetKeys

type GetKeys struct {
	DefaultVisitor
	Result []GetAllResult
}

func (*GetKeys) OnKey

func (visitor *GetKeys) OnKey(node *KeyNode)

type GetKeysResult

type GetKeysResult struct {
	Path  Path
	Value Node
}

type ImportConfiguration

type ImportConfiguration struct {
	Path            string
	Destination     string          `yaml:",omitempty"`
	Transformations []yaml.MapSlice `yaml:",omitempty"`
}

type KeyNode

type KeyNode struct {
	Value interface{}
	Path  Path
}

----------------- KEY NODE --------------

func NewKeyNode

func NewKeyNode(path Path, value interface{}) KeyNode

func (*KeyNode) Accept

func (node *KeyNode) Accept(v Visitor)

func (*KeyNode) GetPath

func (node *KeyNode) GetPath() Path

func (*KeyNode) MarshalJSON

func (keyNode *KeyNode) MarshalJSON() ([]byte, error)

type Kubeconfig

type Kubeconfig struct {
	Path string
}

func CreateKubeConfig

func CreateKubeConfig() Kubeconfig

func CreateKubeConfigFromFile

func CreateKubeConfigFromFile(path string) Kubeconfig

func (*Kubeconfig) ReadCurrentNamespace

func (config *Kubeconfig) ReadCurrentNamespace() (string, error)

type ListNode

type ListNode struct {
	Children []Node
	Path     Path
}

----------------- LIST NODE --------------

func NewListNode

func NewListNode(path Path) ListNode

func (*ListNode) Accept

func (node *ListNode) Accept(v Visitor)

func (*ListNode) AddValue

func (node *ListNode) AddValue(value string)

func (*ListNode) Append

func (node *ListNode) Append(value Node)

func (*ListNode) CreateMap

func (node *ListNode) CreateMap() *MapNode

func (*ListNode) GetPath

func (node *ListNode) GetPath() Path

func (*ListNode) Len

func (node *ListNode) Len() int

func (*ListNode) MarshalJSON

func (listNode *ListNode) MarshalJSON() ([]byte, error)

type LocalSource

type LocalSource struct {
	Dir string
}

func (*LocalSource) GetPath

func (source *LocalSource) GetPath(manager *SourceCacheManager) (string, error)

func (*LocalSource) ToString

func (source *LocalSource) ToString() string

type MapNode

type MapNode struct {
	Path Path
	// contains filtered or unexported fields
}

----------------- MAP NODE --------------

func NewMapNode

func NewMapNode(path Path) MapNode

func ReadManifestFile

func ReadManifestFile(file string) (*MapNode, error)

func ReadManifestString

func ReadManifestString(content []byte) (*MapNode, error)

func (*MapNode) Accept

func (node *MapNode) Accept(v Visitor)

func (*MapNode) CreateList

func (node *MapNode) CreateList(key string) *ListNode

func (*MapNode) CreateMap

func (node *MapNode) CreateMap(key string) *MapNode

func (MapNode) Get

func (node MapNode) Get(s string) Node

func (*MapNode) GetPath

func (node *MapNode) GetPath() Path

func (*MapNode) GetStringValue

func (node *MapNode) GetStringValue(s string) string

func (MapNode) HasKey

func (node MapNode) HasKey(s string) bool

func (*MapNode) Keys

func (node *MapNode) Keys() []string

func (*MapNode) Len

func (node *MapNode) Len() int

func (*MapNode) MarshalJSON

func (mapNode *MapNode) MarshalJSON() ([]byte, error)

func (*MapNode) Put

func (node *MapNode) Put(key string, value Node)

func (*MapNode) PutValue

func (node *MapNode) PutValue(key string, value interface{})

func (*MapNode) Remove

func (node *MapNode) Remove(key string)

func (*MapNode) ToMap

func (m *MapNode) ToMap() map[string]interface{}

func (*MapNode) ToString

func (node *MapNode) ToString() (string, error)

type Node

type Node interface {
	Accept(Visitor)
	GetPath() Path
}

func ConvertToNode

func ConvertToNode(object interface{}, path Path) (Node, error)

Converts raw Yaml structure to file to internal node tree

func NodeFromPathValue

func NodeFromPathValue(path Path, value interface{}) Node

type NodeDownloader

type NodeDownloader struct {
}

func (NodeDownloader) Download

func (NodeDownloader) Download(url string, destinationDir string, rootPath string) error

type OutputGenerator

type OutputGenerator struct {
}

func (*OutputGenerator) Generate

func (*OutputGenerator) Generate(sourceDir string, destinationDir string) ([]*Resource, error)

func (*OutputGenerator) IsManagedDir

func (*OutputGenerator) IsManagedDir(dir string) bool

type Path

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

func NewPath

func NewPath(segs ...string) Path

func RootPath

func RootPath() Path

func (Path) Equal

func (path Path) Equal(other Path) bool

func (Path) Extend

func (path Path) Extend(segment string) Path

func (Path) IsEmpty

func (path Path) IsEmpty() bool

func (Path) Last

func (path Path) Last() string

func (Path) Length

func (path Path) Length() int

func (Path) Match

func (this Path) Match(that Path) bool

func (Path) MatchLimited

func (this Path) MatchLimited(that Path) (bool, string)

match if that is a shorter path, but all the elements are matched

func (Path) MatchSegments

func (this Path) MatchSegments(segments ...string) bool

func (Path) Parent

func (path Path) Parent() Path

func (Path) Segment

func (path Path) Segment(i int) string

func (Path) ToString

func (path Path) ToString() string

func (*Path) UnmarshalYAML

func (path *Path) UnmarshalYAML(unmarshal func(interface{}) error) error

type PrintVisitor

type PrintVisitor struct {
	DefaultVisitor
}

func (PrintVisitor) BeforeList

func (PrintVisitor) BeforeList(node *ListNode)

func (PrintVisitor) BeforeMap

func (PrintVisitor) BeforeMap(node *MapNode)

func (PrintVisitor) OnKey

func (PrintVisitor) OnKey(node *KeyNode)

type ReSet

type ReSet struct {
	DefaultVisitor
	Path     Path
	NewValue interface{}
}

func (*ReSet) BeforeMap

func (visitor *ReSet) BeforeMap(node *MapNode)

func (*ReSet) OnKey

func (visitor *ReSet) OnKey(node *KeyNode)

type RemoteSource

type RemoteSource struct {
	Url      string
	CacheDir string
}

func (*RemoteSource) EnsureDownloaded

func (source *RemoteSource) EnsureDownloaded(manager *SourceCacheManager) error

func (*RemoteSource) GetPath

func (source *RemoteSource) GetPath(manager *SourceCacheManager) (string, error)

func (*RemoteSource) ToString

func (source *RemoteSource) ToString() string

type Resource

type Resource struct {
	Path                string
	Filename            string
	Content             *MapNode
	Destination         string
	DestinationFileName string
	Metadata            map[string]string
}

func GenerateSecret

func GenerateSecret(destinationDir string, name string, secrets map[string]string) (*Resource, error)

func LoadResourceFromByte

func LoadResourceFromByte(data []byte) ([]*Resource, error)

func LoadResourceFromFile

func LoadResourceFromFile(dir string, file string) ([]*Resource, error)

Load k8s resources from one yaml file

func LoadResourceFromFileInfo

func LoadResourceFromFileInfo(dir string, file os.FileInfo) ([]*Resource, error)

func NewResource

func NewResource() Resource

func ReadResourcesFromDir

func ReadResourcesFromDir(dir string) []*Resource

read all the resources from a directory

func (*Resource) Get

func (r *Resource) Get(path Path) string

func (*Resource) Kind

func (r *Resource) Kind() string

func (*Resource) Name

func (r *Resource) Name() string

type SecretGenerator

type SecretGenerator struct {
}

func (*SecretGenerator) Generate

func (kt *SecretGenerator) Generate(sourceDir string, destinationDir string) ([]*Resource, error)

func (*SecretGenerator) IsManagedDir

func (*SecretGenerator) IsManagedDir(dir string) bool

type SecretGetConfig

type SecretGetConfig struct {
	Script string
}

func ReadConfig

func ReadConfig(file string) (SecretGetConfig, error)

type Set

type Set struct {
	DefaultVisitor
	Path     Path
	NewValue interface{}
}

func (*Set) BeforeMap

func (visitor *Set) BeforeMap(node *MapNode)

func (*Set) OnKey

func (visitor *Set) OnKey(node *KeyNode)

type SmartGetAll

type SmartGetAll struct {
	DefaultVisitor
	Path   Path
	Result []GetAllResult
}

func (*SmartGetAll) BeforeList

func (visitor *SmartGetAll) BeforeList(node *ListNode)

func (*SmartGetAll) BeforeMap

func (visitor *SmartGetAll) BeforeMap(node *MapNode)

func (*SmartGetAll) OnKey

func (visitor *SmartGetAll) OnKey(node *KeyNode)

type Source

type Source interface {
	GetPath(manager *SourceCacheManager) (string, error)
	ToString() string
}

func LocalSourcesFromEnv

func LocalSourcesFromEnv() []Source

type SourceCacheManager

type SourceCacheManager struct {
	RootPath string
	// contains filtered or unexported fields
}

func NewSourceCacheManager

func NewSourceCacheManager(root string) SourceCacheManager

func (*SourceCacheManager) DoOnce

func (manager *SourceCacheManager) DoOnce(cacheKey string, task func() error) error

func (*SourceCacheManager) GetCacheDir

func (manager *SourceCacheManager) GetCacheDir(id string) string

type Visitor

type Visitor interface {
	OnKey(*KeyNode)

	BeforeMap(node *MapNode)
	AfterMap(node *MapNode)
	BeforeMapItem(node *MapNode, key string, index int)
	AfterMapItem(node *MapNode, key string, index int)

	BeforeList(node *ListNode)
	AfterList(node *ListNode)
	BeforeListItem(node *ListNode, item Node, index int)
	AfterListItem(node *ListNode, item Node, index int)
}

type Yamlize

type Yamlize struct {
	DefaultVisitor
	Path      Path
	Serialize bool
	// contains filtered or unexported fields
}

func (*Yamlize) BeforeMapItem

func (visitor *Yamlize) BeforeMapItem(node *MapNode, key string, index int)

Jump to

Keyboard shortcuts

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