cnc

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: Apache-2.0 Imports: 60 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BLOCK_TYPE_CERT = "CERTIFICATE"
	BLOCK_TYPE_KEY  = "EC PRIVATE KEY"
)
View Source
const CACHE_FILE = "cache.yaml"

Variables

View Source
var RunOpsList = []RunOp{
	&InstallFile{},
	&ExecCommand{},
	&WaitURL{},
	&PushOCI{},
	&WaitKube{},
}

Functions

func ReadOrGenerateSSHKey

func ReadOrGenerateSSHKey(basedir string, name string, comment string) (string, error)

func RunRecipe

func RunRecipe(basedir string, steps []string, dryRun bool) error

func UnpackFile

func UnpackFile(basedir string, name string) error

Types

type AddBuildOp

type AddBuildOp func(bundle Bundle, stage Stage, name string, op BuildOp)

type AddRunOp

type AddRunOp func(bundle Bundle, stage Stage, name string, op RunOp)

type BuildOp

type BuildOp interface {
	Hydrate() error
	Build(basedir string) error
	RunOps() []RunOp
}

type Bundle

type Bundle struct {
	Name        string
	IsInstaller bool
}

type Cache

type Cache struct {
	Hashes map[string]uint64 `json:"hashes,omitempty"`
}

func (*Cache) Add

func (c *Cache) Add(name string, values ...any) error

func (*Cache) IsActual

func (c *Cache) IsActual(name string, values ...any) (bool, error)

func (*Cache) Load

func (c *Cache) Load(basedir string) error

func (*Cache) Save

func (c *Cache) Save(basedir string) error

type Component

type Component interface {
	Name() string
	IsEnabled(preset Preset) bool
	Flags() []cli.Flag

	// set defaults and validate saveable config
	// called on each init/load, should set values the makes sense for user to change
	// e.g. if we need to set TLS SAN to some value for system to work, it shouldn't be set here
	// e.g. if we need some things to be available for user to change, it should be set here
	// e.g. if we want other components to be able to use some values of that component config - it should be here
	// e.g. generate TLS certificates
	// if we want to make sure that same value is used on every build - it should be set here
	Hydrate(preset Preset, fabricMode config.FabricMode) error

	// TODO rename run -> build, install -> run?
	Build(basedir string, preset Preset, fabricMode config.FabricMode, get GetComponent, wiring *wiring.Data, run AddBuildOp, install AddRunOp) error
}

type ContentGenerator

type ContentGenerator func() (string, error)

func FromKubeObjects

func FromKubeObjects(objs ...KubeObjectProvider) ContentGenerator

func FromTemplate

func FromTemplate(tmplText string, dataBuilder ...any) ContentGenerator

func FromValue

func FromValue(value string) ContentGenerator

func IgnitionFromButaneTemplate

func IgnitionFromButaneTemplate(tmplText string, dataBuilder ...any) ContentGenerator

func YAMLFrom added in v0.6.0

func YAMLFrom(obj any) ContentGenerator

type ExecCommand

type ExecCommand struct {
	Name string   `json:"name,omitempty"`
	Args []string `json:"args,omitempty"`
	Env  []string `json:"env,omitempty"`
	Dir  string   `json:"dir,omitempty"`
}

func (*ExecCommand) Hydrate

func (op *ExecCommand) Hydrate() error

func (*ExecCommand) Run

func (op *ExecCommand) Run(basedir string) error

func (*ExecCommand) Summary

func (op *ExecCommand) Summary() string

type File

type File struct {
	Name             string
	Mode             os.FileMode // local mode to set
	InstallTarget    string
	InstallName      string
	InstallMode      os.FileMode
	InstallMkdirMode os.FileMode
}

type FileGenerate

type FileGenerate struct {
	File    File
	Content ContentGenerator
}

func (*FileGenerate) Build

func (op *FileGenerate) Build(basedir string) error

func (*FileGenerate) Hydrate

func (op *FileGenerate) Hydrate() error

func (*FileGenerate) RunOps

func (op *FileGenerate) RunOps() []RunOp

type FilesORAS

type FilesORAS struct {
	Ref    Ref
	Unpack []string
	Files  []File
}

func (*FilesORAS) Build

func (op *FilesORAS) Build(basedir string) error

func (*FilesORAS) Hydrate

func (op *FilesORAS) Hydrate() error

func (*FilesORAS) RunOps

func (op *FilesORAS) RunOps() []RunOp

type GetComponent

type GetComponent func(string) Component

type InstallFile

type InstallFile struct {
	Name       string      `json:"name,omitempty"`
	Target     string      `json:"target,omitempty"`
	TargetName string      `json:"targetName,omitempty"`
	Mode       os.FileMode `json:"mode,omitempty"`
	MkdirMode  os.FileMode `json:"mkdirMode,omitempty"`
}

func (*InstallFile) Hydrate

func (op *InstallFile) Hydrate() error

func (*InstallFile) Run

func (op *InstallFile) Run(basedir string) error

func (*InstallFile) Summary

func (op *InstallFile) Summary() string

func (*InstallFile) TargetPath

func (op *InstallFile) TargetPath() string

type KeyPair

type KeyPair struct {
	Cert string `json:"cert,omitempty"`
	Key  string `json:"key,omitempty"`
}

func (*KeyPair) Ensure

func (kp *KeyPair) Ensure(cn string, parent *KeyPair, keyUsage x509.KeyUsage, extKeyUsage []x509.ExtKeyUsage, ips []string, dnsNames []string) error

func (*KeyPair) PCert

func (kp *KeyPair) PCert() (*x509.Certificate, error)

func (*KeyPair) PKey

func (kp *KeyPair) PKey() (*ecdsa.PrivateKey, error)

type KubeObjectProvider

type KubeObjectProvider struct {
	Obj meta.Object
	Err error
}

func KubeConfigMap

func KubeConfigMap(name, ns string, values ...any) KubeObjectProvider

func KubeHelmChart

func KubeHelmChart(name, ns string, spec helm.HelmChartSpec, valuesGenerator ...ContentGenerator) KubeObjectProvider

func KubeSecret

func KubeSecret(name, ns string, data map[string]string) KubeObjectProvider

func KubeService

func KubeService(name, ns string, spec core.ServiceSpec) KubeObjectProvider

type Manager

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

func New

func New(presets []Preset, bundles []Bundle, maxStage Stage, components []Component, hydrateCfg *fabwiring.HydrateConfig) *Manager

func (*Manager) Build

func (mngr *Manager) Build(pack bool) error

func (*Manager) Dump

func (mngr *Manager) Dump() error

func (*Manager) Flags

func (mngr *Manager) Flags() []cli.Flag

func (*Manager) Init

func (mngr *Manager) Init(basedir string, fromConfig string, preset Preset, fabricMode config.FabricMode, wiringPath []string, wiringGen *fabwiring.Builder, hydrate bool) error

func (*Manager) Load

func (mngr *Manager) Load(basedir string) error

func (*Manager) Pack

func (mngr *Manager) Pack() error

func (*Manager) Preset

func (mngr *Manager) Preset() Preset

func (*Manager) Save

func (mngr *Manager) Save() error

func (*Manager) Wiring

func (mngr *Manager) Wiring() *wiring.Data

type ManagerSaver

type ManagerSaver struct {
	Preset     Preset            `json:"preset,omitempty"`
	FabricMode config.FabricMode `json:"fabricMode,omitempty"`
	Config     map[string]any    `json:"config,omitempty"`
}

type Preset

type Preset string

type PushOCI

type PushOCI struct {
	Name   string `json:"name,omitempty"`
	Target Ref    `json:"target,omitempty"`
}

func (*PushOCI) Hydrate

func (op *PushOCI) Hydrate() error

func (*PushOCI) Run

func (op *PushOCI) Run(basedir string) error

func (*PushOCI) Summary

func (op *PushOCI) Summary() string

type Recipe

type Recipe struct {
	Actions []RecipeAction
}

func (*Recipe) Load

func (r *Recipe) Load(basedir string) error

func (*Recipe) Save

func (r *Recipe) Save(basedir string) error

type RecipeAction

type RecipeAction struct {
	Name string `json:"name,omitempty"`
	Op   RunOp  `json:"op,omitempty"`
}

type RecipeSaver

type RecipeSaver struct {
	Actions []RecipeSaverItem `json:"recipe,omitempty"`
}

type RecipeSaverItem

type RecipeSaverItem struct {
	Name string `json:"name,omitempty"`
	Type string `json:"action,omitempty"`
	Op   any    `json:"params,omitempty"`
}

type Ref

type Ref struct {
	Repo string `json:"repo,omitempty"`
	Name string `json:"name,omitempty"`
	Tag  string `json:"tag,omitempty"`
}

func (Ref) Fallback

func (ref Ref) Fallback(refs ...Ref) Ref

func (Ref) IsLocalhost added in v0.6.0

func (ref Ref) IsLocalhost() bool

func (Ref) RepoName

func (ref Ref) RepoName() string

func (Ref) StrictValidate

func (ref Ref) StrictValidate() error

func (Ref) String

func (ref Ref) String() string

TODO maybe rename to smth? and make it work for empty parts

type RunOp

type RunOp interface {
	Hydrate() error
	Summary() string
	Run(basedir string) error
}

type Stage

type Stage uint8

type SyncOCI

type SyncOCI struct {
	Ref    Ref
	Target Ref
}

func (*SyncOCI) Build

func (op *SyncOCI) Build(basedir string) error

func (*SyncOCI) Hydrate

func (op *SyncOCI) Hydrate() error

func (*SyncOCI) RunOps

func (op *SyncOCI) RunOps() []RunOp

type WaitKube

type WaitKube struct {
	Name            string        `json:"name,omitempty"`
	Timeout         time.Duration `json:"timeout,omitempty"`
	TimeoutResource time.Duration `json:"timeoutResource,omitempty"`
	Interval        time.Duration `json:"interval,omitempty"`
}

func (*WaitKube) Hydrate

func (op *WaitKube) Hydrate() error

func (*WaitKube) Run

func (op *WaitKube) Run(basedir string) error

func (*WaitKube) Summary

func (op *WaitKube) Summary() string

type WaitParams

type WaitParams struct {
	Delay    time.Duration `json:"delay,omitempty"`
	Interval time.Duration `json:"interval,omitempty"`
	Attempts int           `json:"attempts,omitempty"`
}

func (*WaitParams) Hydrate

func (w *WaitParams) Hydrate() error

func (*WaitParams) Wait

func (w *WaitParams) Wait(checker func() error) error

type WaitURL

type WaitURL struct {
	Wait       WaitParams `json:"wait,omitempty"`
	URL        string     `json:"url,omitempty"`
	StatusCode int        `json:"statusCode,omitempty"`
}

func (*WaitURL) Hydrate

func (op *WaitURL) Hydrate() error

func (*WaitURL) Run

func (op *WaitURL) Run(basedir string) error

func (*WaitURL) Summary

func (op *WaitURL) Summary() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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