types

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 25 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ResourceBlockTypes = []string{
	kformv1alpha1.BlockTYPE_RESOURCE.String(),
	kformv1alpha1.BlockTYPE_DATA.String(),
	kformv1alpha1.BlockTYPE_LIST.String(),
}

Functions

func DeepCopy

func DeepCopy(in any) (any, error)

func GetBlockTypeNames

func GetBlockTypeNames() []string

func ListBlocks

func ListBlocks(ctx context.Context, s store.Storer[Block], opts ...ListBlockOptions) map[string]Block

func NewBlock

func NewBlock(ctx context.Context, blockType kformv1alpha1.BlockType, blockName string, rn *yaml.RNode) (*block, error)

Types

type Block

type Block interface {
	GetFileName() string
	GetIndex() string
	GetPackageName() string
	GetBlockName() string
	GetBlockType() kformv1alpha1.BlockType
	GetContext(n string) string
	HasForEach() bool
	HasCount() bool
	GetSource() string
	GetProvider() string
	GetInputParameters() map[string]any
	GetProviders() map[string]string // only relevant for mixin
	// Dependencies
	GetDependencies() sets.Set[string]
	GetPkgDependencies() sets.Set[string]
	UpdateDependencies(sets.Set[string])
	UpdatePkgDependencies(sets.Set[string])
	//GetKubeObject() *fn.KubeObject
	GetAttributes() *kformv1alpha1.Attributes
	GetData() data.BlockData
	// contains filtered or unexported methods
}

type BlockInitializer

type BlockInitializer func(ctx context.Context) BlockProcessor

type BlockProcessor

type BlockProcessor interface {
	UpdatePackage(context.Context)
}

func InitializeBlock

func InitializeBlock(ctx context.Context, blockType kformv1alpha1.BlockType) (BlockProcessor, error)

type Context

type Context struct {
	context.Context
}

func (Context) String

func (r Context) String() string

type ContextAPI

type ContextAPI struct {
	FileName     string      `json:"fileName"`
	PackageKind  PackageKind `json:"packageKind"`
	PackageName  string      `json:"packageName"`
	BlockType    *string     `json:"blockType,omitempty"`
	ResourceID   *string     `json:"resourceID,omitempty"`
	ResourceType *string     `json:"resourceType,omitempty"`
}

type CtxKey

type CtxKey string
const (
	CtxKeyRecorder     CtxKey = "recorder"
	CtxKeyPackage      CtxKey = "package" // store the Package
	CtxKeyPackageName  CtxKey = "packageName"
	CtxKeyPackageKind  CtxKey = "packageKind"
	CtxKeyFileName     CtxKey = "fileName"
	CtxKeyIndex        CtxKey = "index"
	CtxKeyBlockType    CtxKey = "blockType"
	CtxKeyResourceID   CtxKey = "resourceID"
	CtxKeyResourceType CtxKey = "resourcetype"
	CtxKeyYamlRNODE    CtxKey = "yamlRNODE" // stores the kubeObject
)

func (CtxKey) String

func (c CtxKey) String() string

type Initializer

type Initializer func() (kfplugin.Provider, error)

func ProviderInitializer added in v0.0.3

func ProviderInitializer(execPath string) Initializer

ProviderInitializer produces a provider factory that runs up the executable file in the given path and uses go-plugin to implement Provider Interface against it.

type ListBlockOptions

type ListBlockOptions struct {
	Prefix        string
	PrefixExludes []string
	ExludeOrphan  bool
}

type Package

type Package struct {
	Name string
	Kind PackageKind

	SourceDir string

	Backend Block

	ProviderRequirements store.Storer[kformv1alpha1.Provider]
	ProviderConfigs      store.Storer[Block]

	Blocks store.Storer[Block]

	DAG         dag.DAG[*VertexContext]
	ProviderDAG dag.DAG[*VertexContext]
	// contains filtered or unexported fields
}

func NewPackage

func NewPackage(name string, kind PackageKind, recorder recorder.Recorder[diag.Diagnostic]) *Package

func (*Package) AddDependencies

func (r *Package) AddDependencies(ctx context.Context)

func (*Package) GenerateDAG

func (r *Package) GenerateDAG(ctx context.Context, provider bool, usedProviderConfigs sets.Set[string]) error

func (*Package) GetBlockdata

func (r *Package) GetBlockdata(ctx context.Context) map[string]data.BlockData

func (*Package) ListBlocks

func (r *Package) ListBlocks(ctx context.Context) []string

func (*Package) ListPkgDependencies

func (r *Package) ListPkgDependencies(ctx context.Context) sets.Set[string]

func (*Package) ListProviderConfigs

func (r *Package) ListProviderConfigs(ctx context.Context) map[string]Block

func (*Package) ListProviderRequirements

func (r *Package) ListProviderRequirements(ctx context.Context) map[string]kformv1alpha1.Provider

func (*Package) ListProvidersFromResources added in v0.0.3

func (r *Package) ListProvidersFromResources(ctx context.Context) sets.Set[string]

ListProvidersFromResources lists all providers resource identified this includes direct provider mappings as well as aliases

func (*Package) ListRawProvidersFromResources added in v0.0.3

func (r *Package) ListRawProvidersFromResources(ctx context.Context) sets.Set[string]

ListRawProvidersFromResources lists all providers resource identified this includes only the main providers, no aliases

func (*Package) ListResources added in v0.0.3

func (r *Package) ListResources(ctx context.Context) sets.Set[Block]

func (*Package) ResolveDAGDependencies

func (r *Package) ResolveDAGDependencies(ctx context.Context)

func (*Package) ResolveResource2ProviderConfig

func (r *Package) ResolveResource2ProviderConfig(ctx context.Context)

func (*Package) ValidateMixinProviderConfigs

func (r *Package) ValidateMixinProviderConfigs(ctx context.Context)

type PackageKind

type PackageKind int
const (
	PackageKind_ROOT PackageKind = iota
	PackageKind_MIXIN
)

func (PackageKind) String

func (d PackageKind) String() string

type Provider

type Provider struct {
	Name string
	Initializer
	Resources       sets.Set[string]
	ReadDataSources sets.Set[string]
	ListDataSources sets.Set[string]
}

func (*Provider) Init added in v0.0.3

func (r *Provider) Init(ctx context.Context, execpath, providerName string) error

type VertexContext

type VertexContext struct {
	// FileName and PackageName provide context in which this vertex is handled
	FileName    string `json:"fileName"`
	Index       string `json:"index"`
	PackageName string `json:"packageName"`
	// BlockType determines which function we need to execute
	BlockType kformv1alpha1.BlockType `json:"blockType"`
	// BlockName has syntx <namespace>.<name>
	BlockName string `json:"blockName"`
	// provides the contextual data
	Data            data.BlockData
	Attributes      *kformv1alpha1.Attributes
	Dependencies    sets.Set[string]
	PkgDependencies sets.Set[string]
	// only relevant for blocktype resource, data and list
	//Provider string
	// only relevant for blocktype package/mixin
	// can be either a regular DAG or a provider DAG
	DAG dag.DAG[*VertexContext]
}

func (*VertexContext) AddDAG

func (r *VertexContext) AddDAG(d dag.DAG[*VertexContext])

func (*VertexContext) GetBlockDependencies

func (r *VertexContext) GetBlockDependencies() sets.Set[string]

func (*VertexContext) GetDependencies

func (r *VertexContext) GetDependencies() sets.Set[string]

func (*VertexContext) String

func (r *VertexContext) String() string

Jump to

Keyboard shortcuts

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