Documentation
¶
Index ¶
- Variables
- type BaseBlueprintHandler
- func (b *BaseBlueprintHandler) Down() error
- func (b *BaseBlueprintHandler) GetDefaultTemplateData(contextName string) (map[string][]byte, error)
- func (b *BaseBlueprintHandler) GetLocalTemplateData() (map[string][]byte, error)
- 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() error
- func (b *BaseBlueprintHandler) LoadData(data map[string]any, ociInfo ...*artifact.OCIArtifactInfo) error
- func (b *BaseBlueprintHandler) WaitForKustomizations(message string, names ...string) error
- func (b *BaseBlueprintHandler) Write(overwrite ...bool) error
- type BlueprintHandler
- type JsonnetVM
- type MockBlueprintHandler
- func (m *MockBlueprintHandler) Down() error
- func (m *MockBlueprintHandler) GetDefaultTemplateData(contextName string) (map[string][]byte, error)
- func (m *MockBlueprintHandler) GetKustomizations() []blueprintv1alpha1.Kustomization
- func (m *MockBlueprintHandler) GetLocalTemplateData() (map[string][]byte, error)
- 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() error
- func (m *MockBlueprintHandler) LoadData(data map[string]any, ociInfo ...*artifact.OCIArtifactInfo) error
- func (m *MockBlueprintHandler) WaitForKustomizations(message string, names ...string) error
- func (m *MockBlueprintHandler) Write(overwrite ...bool) error
- 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) Down ¶ added in v0.6.0
func (b *BaseBlueprintHandler) Down() error
Down manages the teardown of kustomizations and related resources, ignoring "not found" errors. It suspends kustomizations and helmreleases, applies cleanup kustomizations, waits for completion, deletes main kustomizations in reverse dependency order, and removes cleanup kustomizations and namespaces. The function filters kustomizations for destruction, sorts them by dependencies, and performs cleanup if specified. Dependency resolution is achieved through topological sorting for correct deletion order.
func (*BaseBlueprintHandler) GetDefaultTemplateData ¶ added in v0.7.0
func (b *BaseBlueprintHandler) GetDefaultTemplateData(contextName string) (map[string][]byte, error)
GetDefaultTemplateData generates default template data based on the provider configuration. It uses the embedded default template to create a map of template files that can be used by the init pipeline for generating context-specific configurations.
func (*BaseBlueprintHandler) GetLocalTemplateData ¶ added in v0.7.0
func (b *BaseBlueprintHandler) GetLocalTemplateData() (map[string][]byte, error)
GetLocalTemplateData collects template data from the local contexts/_template directory. It recursively walks through the template directory and collects only .jsonnet files, maintaining the relative path structure from the template directory root.
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 all blueprint Kubernetes resources to the cluster, including the main repository, additional sources, Kustomizations, and the context ConfigMap. The method ensures the target namespace exists, applies the main and additional source repositories, creates the ConfigMap, and applies all Kustomizations. Uses the environment KUBECONFIG or in-cluster configuration for access. Returns an error if any resource application fails.
func (*BaseBlueprintHandler) LoadConfig ¶
func (b *BaseBlueprintHandler) LoadConfig() error
LoadConfig reads blueprint configuration from blueprint.yaml file. Returns an error if blueprint.yaml does not exist. Template processing is now handled by the pkg/template package.
func (*BaseBlueprintHandler) LoadData ¶ added in v0.7.0
func (b *BaseBlueprintHandler) LoadData(data map[string]any, ociInfo ...*artifact.OCIArtifactInfo) error
LoadData loads blueprint configuration from a map containing blueprint data. It marshals the input map to YAML, processes it as a Blueprint object, and updates the handler's blueprint state. The ociInfo parameter optionally provides OCI artifact source information for source resolution and tracking.
func (*BaseBlueprintHandler) WaitForKustomizations ¶ added in v0.6.0
func (b *BaseBlueprintHandler) WaitForKustomizations(message string, names ...string) error
WaitForKustomizations waits for the specified kustomizations to be ready. It polls the status of the kustomizations until they are all ready or a timeout occurs.
func (*BaseBlueprintHandler) Write ¶ added in v0.7.0
func (b *BaseBlueprintHandler) Write(overwrite ...bool) error
Write persists the current blueprint state to blueprint.yaml in the configuration root directory. If overwrite is true, the file is overwritten regardless of existence. If overwrite is false or omitted, the file is only written if it does not already exist. The method ensures the target directory exists, marshals the blueprint to YAML, and writes the file using the configured shims. Terraform variables are filtered out to prevent them from appearing in the final blueprint.yaml.
type BlueprintHandler ¶
type BlueprintHandler interface {
Initialize() error
LoadConfig() error
LoadData(data map[string]any, ociInfo ...*artifact.OCIArtifactInfo) error
Write(overwrite ...bool) error
Install() error
GetMetadata() blueprintv1alpha1.Metadata
GetSources() []blueprintv1alpha1.Source
GetRepository() blueprintv1alpha1.Repository
GetTerraformComponents() []blueprintv1alpha1.TerraformComponent
WaitForKustomizations(message string, names ...string) error
GetDefaultTemplateData(contextName string) (map[string][]byte, error)
GetLocalTemplateData() (map[string][]byte, error)
Down() 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() error
LoadDataFunc func(data map[string]any, ociInfo ...*artifact.OCIArtifactInfo) error
WriteFunc func(overwrite ...bool) error
GetMetadataFunc func() blueprintv1alpha1.Metadata
GetSourcesFunc func() []blueprintv1alpha1.Source
GetTerraformComponentsFunc func() []blueprintv1alpha1.TerraformComponent
GetKustomizationsFunc func() []blueprintv1alpha1.Kustomization
WaitForKustomizationsFunc func(message string, names ...string) error
GetDefaultTemplateDataFunc func(contextName string) (map[string][]byte, error)
GetLocalTemplateDataFunc func() (map[string][]byte, error)
InstallFunc func() error
GetRepositoryFunc func() blueprintv1alpha1.Repository
DownFunc func() 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) Down ¶ added in v0.6.0
func (m *MockBlueprintHandler) Down() error
Down mocks the Down method.
func (*MockBlueprintHandler) GetDefaultTemplateData ¶ added in v0.7.0
func (m *MockBlueprintHandler) GetDefaultTemplateData(contextName string) (map[string][]byte, error)
GetDefaultTemplateData calls the mock GetDefaultTemplateDataFunc if set, otherwise returns empty map
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) GetLocalTemplateData ¶ added in v0.7.0
func (m *MockBlueprintHandler) GetLocalTemplateData() (map[string][]byte, error)
GetLocalTemplateData calls the mock GetLocalTemplateDataFunc if set, otherwise returns empty map
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() error
LoadConfig calls the mock LoadConfigFunc if set, otherwise returns nil
func (*MockBlueprintHandler) LoadData ¶ added in v0.7.0
func (m *MockBlueprintHandler) LoadData(data map[string]any, ociInfo ...*artifact.OCIArtifactInfo) error
LoadData calls the mock LoadDataFunc if set, otherwise returns nil
func (*MockBlueprintHandler) WaitForKustomizations ¶ added in v0.6.0
func (m *MockBlueprintHandler) WaitForKustomizations(message string, names ...string) error
WaitForKustomizations calls the mock WaitForKustomizationsFunc if set, otherwise returns nil
func (*MockBlueprintHandler) Write ¶ added in v0.7.0
func (m *MockBlueprintHandler) Write(overwrite ...bool) error
Write calls the mock WriteFunc if set, otherwise returns nil
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)
ReadDir func(string) ([]os.DirEntry, error)
// Utility shims
RegexpMatchString func(pattern string, s string) (bool, error)
// Timing shims
TimeAfter func(time.Duration) <-chan time.Time
NewTicker func(time.Duration) *time.Ticker
TickerStop func(*time.Ticker)
// 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