Documentation
¶
Index ¶
- Variables
- type BaseBlueprintHandler
- func (b *BaseBlueprintHandler) GetKustomizations() []blueprintv1alpha1.Kustomization
- func (b *BaseBlueprintHandler) GetMetadata() blueprintv1alpha1.Metadata
- func (b *BaseBlueprintHandler) GetRepository() blueprintv1alpha1.Repository
- func (b *BaseBlueprintHandler) GetSources() []blueprintv1alpha1.Source
- func (b *BaseBlueprintHandler) GetTerraformComponents() []blueprintv1alpha1.TerraformComponent
- func (b *BaseBlueprintHandler) Initialize() error
- func (b *BaseBlueprintHandler) Install() error
- func (b *BaseBlueprintHandler) LoadConfig(path ...string) error
- func (b *BaseBlueprintHandler) SetKustomizations(kustomizations []blueprintv1alpha1.Kustomization) error
- func (b *BaseBlueprintHandler) SetMetadata(metadata blueprintv1alpha1.Metadata) error
- func (b *BaseBlueprintHandler) SetRepository(repository blueprintv1alpha1.Repository) error
- func (b *BaseBlueprintHandler) SetSources(sources []blueprintv1alpha1.Source) error
- func (b *BaseBlueprintHandler) SetTerraformComponents(terraformComponents []blueprintv1alpha1.TerraformComponent) error
- func (b *BaseBlueprintHandler) WriteConfig(path ...string) error
- type BlueprintHandler
- type JsonnetVM
- type MockBlueprintHandler
- func (m *MockBlueprintHandler) GetKustomizations() []blueprintv1alpha1.Kustomization
- func (m *MockBlueprintHandler) GetMetadata() blueprintv1alpha1.Metadata
- func (m *MockBlueprintHandler) GetRepository() blueprintv1alpha1.Repository
- func (m *MockBlueprintHandler) GetSources() []blueprintv1alpha1.Source
- func (m *MockBlueprintHandler) GetTerraformComponents() []blueprintv1alpha1.TerraformComponent
- func (m *MockBlueprintHandler) Initialize() error
- func (m *MockBlueprintHandler) Install() error
- func (m *MockBlueprintHandler) LoadConfig(path ...string) error
- func (m *MockBlueprintHandler) SetKustomizations(kustomizations []blueprintv1alpha1.Kustomization) error
- func (m *MockBlueprintHandler) SetMetadata(metadata blueprintv1alpha1.Metadata) error
- func (m *MockBlueprintHandler) SetRepository(repository blueprintv1alpha1.Repository) error
- func (m *MockBlueprintHandler) SetSources(sources []blueprintv1alpha1.Source) error
- func (m *MockBlueprintHandler) SetTerraformComponents(terraformComponents []blueprintv1alpha1.TerraformComponent) error
- func (m *MockBlueprintHandler) WriteConfig(path ...string) error
- type ResourceOperationConfig
- type Shims
Constants ¶
This section is empty.
Variables ¶
var DefaultBlueprint = blueprintv1alpha1.Blueprint{ Kind: "Blueprint", ApiVersion: "blueprints.windsorcli.dev/v1alpha1", Metadata: blueprintv1alpha1.Metadata{ Name: "default", Description: "A default blueprint", Authors: []string{}, }, Sources: []blueprintv1alpha1.Source{}, TerraformComponents: []blueprintv1alpha1.TerraformComponent{}, }
Functions ¶
This section is empty.
Types ¶
type BaseBlueprintHandler ¶
type BaseBlueprintHandler struct {
BlueprintHandler
// contains filtered or unexported fields
}
func NewBlueprintHandler ¶
func NewBlueprintHandler(injector di.Injector) *BaseBlueprintHandler
NewBlueprintHandler creates a new instance of BaseBlueprintHandler. It initializes the handler with the provided dependency injector.
func (*BaseBlueprintHandler) GetKustomizations ¶ added in v0.3.0
func (b *BaseBlueprintHandler) GetKustomizations() []blueprintv1alpha1.Kustomization
GetKustomizations retrieves the blueprint's Kustomization configurations, ensuring default values are set for intervals, timeouts, and adding standard PostBuild configurations for variable substitution.
func (*BaseBlueprintHandler) GetMetadata ¶
func (b *BaseBlueprintHandler) GetMetadata() blueprintv1alpha1.Metadata
GetMetadata retrieves the current blueprint's metadata.
func (*BaseBlueprintHandler) GetRepository ¶ added in v0.3.0
func (b *BaseBlueprintHandler) GetRepository() blueprintv1alpha1.Repository
GetRepository retrieves the current blueprint's repository configuration, ensuring default values are set for empty fields.
func (*BaseBlueprintHandler) GetSources ¶
func (b *BaseBlueprintHandler) GetSources() []blueprintv1alpha1.Source
GetSources retrieves the current blueprint's source configurations.
func (*BaseBlueprintHandler) GetTerraformComponents ¶
func (b *BaseBlueprintHandler) GetTerraformComponents() []blueprintv1alpha1.TerraformComponent
GetTerraformComponents retrieves the blueprint's Terraform components after resolving their sources and paths to full URLs and filesystem paths respectively.
func (*BaseBlueprintHandler) Initialize ¶
func (b *BaseBlueprintHandler) Initialize() error
Initialize sets up the BaseBlueprintHandler by resolving and assigning its dependencies, including the configHandler, contextHandler, and shell, from the provided dependency injector. It also determines the project root directory using the shell and sets the project name in the configuration. If any of these steps fail, it returns an error.
func (*BaseBlueprintHandler) Install ¶ added in v0.3.0
func (b *BaseBlueprintHandler) Install() error
Install applies the blueprint's Kubernetes resources to the cluster. It handles GitRepositories for the main repository and sources, Kustomizations for deployments, and a ConfigMap containing context-specific configuration. Uses environment KUBECONFIG or falls back to in-cluster config.
func (*BaseBlueprintHandler) LoadConfig ¶
func (b *BaseBlueprintHandler) LoadConfig(path ...string) error
LoadConfig reads and processes blueprint configuration from either a specified path or the default location. It supports both Jsonnet and YAML formats, evaluates any Jsonnet templates with the current context, and merges local blueprint data. The function handles default blueprints when no config exists.
func (*BaseBlueprintHandler) SetKustomizations ¶ added in v0.3.0
func (b *BaseBlueprintHandler) SetKustomizations(kustomizations []blueprintv1alpha1.Kustomization) error
SetKustomizations updates the Kustomizations for the current blueprint. It replaces the existing Kustomizations with the provided list of Kustomizations. If the provided list is nil, it clears the existing Kustomizations.
func (*BaseBlueprintHandler) SetMetadata ¶
func (b *BaseBlueprintHandler) SetMetadata(metadata blueprintv1alpha1.Metadata) error
SetMetadata updates the metadata for the current blueprint. It replaces the existing metadata with the provided metadata information.
func (*BaseBlueprintHandler) SetRepository ¶ added in v0.3.0
func (b *BaseBlueprintHandler) SetRepository(repository blueprintv1alpha1.Repository) error
SetRepository updates the repository for the current blueprint. It replaces the existing repository with the provided repository information.
func (*BaseBlueprintHandler) SetSources ¶
func (b *BaseBlueprintHandler) SetSources(sources []blueprintv1alpha1.Source) error
SetSources updates the source configurations for the current blueprint. It replaces the existing sources with the provided list of sources.
func (*BaseBlueprintHandler) SetTerraformComponents ¶
func (b *BaseBlueprintHandler) SetTerraformComponents(terraformComponents []blueprintv1alpha1.TerraformComponent) error
SetTerraformComponents updates the Terraform components for the current blueprint. It replaces the existing components with the provided list of Terraform components.
func (*BaseBlueprintHandler) WriteConfig ¶
func (b *BaseBlueprintHandler) WriteConfig(path ...string) error
WriteConfig persists the current blueprint configuration to disk. It handles path resolution, directory creation, and writes the blueprint in YAML format. The function cleans sensitive or redundant data before writing, such as Terraform component variables/values and empty PostBuild configs.
type BlueprintHandler ¶
type BlueprintHandler interface {
Initialize() error
LoadConfig(path ...string) error
WriteConfig(path ...string) error
Install() error
GetMetadata() blueprintv1alpha1.Metadata
GetSources() []blueprintv1alpha1.Source
GetRepository() blueprintv1alpha1.Repository
GetTerraformComponents() []blueprintv1alpha1.TerraformComponent
GetKustomizations() []blueprintv1alpha1.Kustomization
SetMetadata(metadata blueprintv1alpha1.Metadata) error
SetSources(sources []blueprintv1alpha1.Source) error
SetRepository(repository blueprintv1alpha1.Repository) error
SetTerraformComponents(terraformComponents []blueprintv1alpha1.TerraformComponent) error
SetKustomizations(kustomizations []blueprintv1alpha1.Kustomization) error
}
type JsonnetVM ¶ added in v0.5.7
type JsonnetVM interface {
// TLACode sets a top-level argument using code
TLACode(key, val string)
// ExtCode sets an external variable using code
ExtCode(key, val string)
// EvaluateAnonymousSnippet evaluates a jsonnet snippet
EvaluateAnonymousSnippet(filename, snippet string) (string, error)
}
JsonnetVM defines the interface for Jsonnet virtual machines
func NewJsonnetVM ¶ added in v0.5.7
func NewJsonnetVM() JsonnetVM
NewJsonnetVM creates a new JsonnetVM using the real jsonnet implementation
type MockBlueprintHandler ¶
type MockBlueprintHandler struct {
InitializeFunc func() error
LoadConfigFunc func(path ...string) error
GetMetadataFunc func() blueprintv1alpha1.Metadata
GetSourcesFunc func() []blueprintv1alpha1.Source
GetTerraformComponentsFunc func() []blueprintv1alpha1.TerraformComponent
GetKustomizationsFunc func() []blueprintv1alpha1.Kustomization
SetMetadataFunc func(metadata blueprintv1alpha1.Metadata) error
SetSourcesFunc func(sources []blueprintv1alpha1.Source) error
SetTerraformComponentsFunc func(terraformComponents []blueprintv1alpha1.TerraformComponent) error
SetKustomizationsFunc func(kustomizations []blueprintv1alpha1.Kustomization) error
WriteConfigFunc func(path ...string) error
InstallFunc func() error
GetRepositoryFunc func() blueprintv1alpha1.Repository
SetRepositoryFunc func(repository blueprintv1alpha1.Repository) error
}
MockBlueprintHandler is a mock implementation of BlueprintHandler interface for testing
func NewMockBlueprintHandler ¶
func NewMockBlueprintHandler(injector di.Injector) *MockBlueprintHandler
NewMockBlueprintHandler creates a new instance of MockBlueprintHandler
func (*MockBlueprintHandler) GetKustomizations ¶ added in v0.3.0
func (m *MockBlueprintHandler) GetKustomizations() []blueprintv1alpha1.Kustomization
GetKustomizations calls the mock GetKustomizationsFunc if set, otherwise returns a reasonable default slice of kustomizev1.Kustomization
func (*MockBlueprintHandler) GetMetadata ¶
func (m *MockBlueprintHandler) GetMetadata() blueprintv1alpha1.Metadata
GetMetadata calls the mock GetMetadataFunc if set, otherwise returns a reasonable default MetadataV1Alpha1
func (*MockBlueprintHandler) GetRepository ¶ added in v0.5.7
func (m *MockBlueprintHandler) GetRepository() blueprintv1alpha1.Repository
GetRepository calls the mock GetRepositoryFunc if set, otherwise returns empty Repository
func (*MockBlueprintHandler) GetSources ¶
func (m *MockBlueprintHandler) GetSources() []blueprintv1alpha1.Source
GetSources calls the mock GetSourcesFunc if set, otherwise returns a reasonable default slice of SourceV1Alpha1
func (*MockBlueprintHandler) GetTerraformComponents ¶
func (m *MockBlueprintHandler) GetTerraformComponents() []blueprintv1alpha1.TerraformComponent
GetTerraformComponents calls the mock GetTerraformComponentsFunc if set, otherwise returns a reasonable default slice of TerraformComponentV1Alpha1
func (*MockBlueprintHandler) Initialize ¶
func (m *MockBlueprintHandler) Initialize() error
Initialize initializes the blueprint handler
func (*MockBlueprintHandler) Install ¶ added in v0.3.0
func (m *MockBlueprintHandler) Install() error
Install calls the mock InstallFunc if set, otherwise returns nil
func (*MockBlueprintHandler) LoadConfig ¶
func (m *MockBlueprintHandler) LoadConfig(path ...string) error
LoadConfig calls the mock LoadConfigFunc if set, otherwise returns nil
func (*MockBlueprintHandler) SetKustomizations ¶ added in v0.3.0
func (m *MockBlueprintHandler) SetKustomizations(kustomizations []blueprintv1alpha1.Kustomization) error
SetKustomizations calls the mock SetKustomizationsFunc if set, otherwise returns nil
func (*MockBlueprintHandler) SetMetadata ¶
func (m *MockBlueprintHandler) SetMetadata(metadata blueprintv1alpha1.Metadata) error
SetMetadata calls the mock SetMetadataFunc if set, otherwise returns nil
func (*MockBlueprintHandler) SetRepository ¶ added in v0.5.7
func (m *MockBlueprintHandler) SetRepository(repository blueprintv1alpha1.Repository) error
SetRepository calls the mock SetRepositoryFunc if set, otherwise returns nil
func (*MockBlueprintHandler) SetSources ¶
func (m *MockBlueprintHandler) SetSources(sources []blueprintv1alpha1.Source) error
SetSources calls the mock SetSourcesFunc if set, otherwise returns nil
func (*MockBlueprintHandler) SetTerraformComponents ¶
func (m *MockBlueprintHandler) SetTerraformComponents(terraformComponents []blueprintv1alpha1.TerraformComponent) error
SetTerraformComponents calls the mock SetTerraformComponentsFunc if set, otherwise returns nil
func (*MockBlueprintHandler) WriteConfig ¶
func (m *MockBlueprintHandler) WriteConfig(path ...string) error
WriteConfig calls the mock WriteConfigFunc if set, otherwise returns nil
type ResourceOperationConfig ¶ added in v0.3.0
type Shims ¶ added in v0.5.7
type Shims struct {
// YAML and JSON shims
YamlMarshalNonNull func(v any) ([]byte, error)
YamlMarshal func(any) ([]byte, error)
YamlUnmarshal func([]byte, any) error
JsonMarshal func(any) ([]byte, error)
JsonUnmarshal func([]byte, any) error
K8sYamlUnmarshal func([]byte, any) error
// File system shims
WriteFile func(string, []byte, os.FileMode) error
MkdirAll func(string, os.FileMode) error
Stat func(string) (os.FileInfo, error)
ReadFile func(string) ([]byte, error)
// Utility shims
RegexpMatchString func(pattern string, s string) (bool, error)
// Kubernetes shims
ClientcmdBuildConfigFromFlags func(masterUrl, kubeconfigPath string) (*rest.Config, error)
RestInClusterConfig func() (*rest.Config, error)
KubernetesNewForConfig func(*rest.Config) (*kubernetes.Clientset, error)
// Jsonnet shims
NewJsonnetVM func() JsonnetVM
}
Shims provides mockable wrappers around system and runtime functions