Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseGenerator ¶
type BaseGenerator struct {
// contains filtered or unexported fields
}
BaseGenerator is a base implementation of the Generator interface
func NewGenerator ¶
func NewGenerator(injector di.Injector) *BaseGenerator
NewGenerator creates a new BaseGenerator
func (*BaseGenerator) Generate ¶ added in v0.7.0
func (g *BaseGenerator) Generate(data map[string]any, overwrite ...bool) error
Generate is a placeholder implementation of the Generate method. Concrete implementations should override this method to provide specific generation logic. The data parameter contains the processed template data from pkg/template's Process function. The overwrite parameter controls whether existing files should be overwritten.
func (*BaseGenerator) Initialize ¶
func (g *BaseGenerator) Initialize() error
Initialize sets up the BaseGenerator by resolving and storing required dependencies. It ensures that the config handler, blueprint handler, shell, and artifact builder are properly initialized.
func (*BaseGenerator) Write ¶
func (g *BaseGenerator) Write(overwrite ...bool) error
Write is a placeholder implementation of the Write method. Concrete implementations should override this method to provide specific generation logic.
type Generator ¶
type Generator interface {
Initialize() error
Write(overwrite ...bool) error
Generate(data map[string]any, overwrite ...bool) error
}
Generator is the interface for all code generators It defines methods for initialization and file generation All generators must implement this interface
type GitGenerator ¶
type GitGenerator struct {
BaseGenerator
}
GitGenerator is a generator that writes Git configuration files
func NewGitGenerator ¶
func NewGitGenerator(injector di.Injector) *GitGenerator
NewGitGenerator creates a new GitGenerator
func (*GitGenerator) Generate ¶ added in v0.7.0
func (g *GitGenerator) Generate(data map[string]any, overwrite ...bool) error
Generate creates the Git configuration files by creating or updating the .gitignore file. It ensures that Windsor-specific entries are added while preserving any existing user-defined entries. For GitGenerator, the data parameter is not used since it always generates the .gitignore file in the project root based on predefined rules. The overwrite parameter is not used since the GitGenerator always merges with existing content rather than overwriting.
func (*GitGenerator) Write ¶
func (g *GitGenerator) Write(overwrite ...bool) error
Write generates the Git configuration files by delegating to the Generate method. It maintains backward compatibility while Generate handles the actual file generation. The overwrite parameter is currently not used but preserved for interface compatibility.
type MockGenerator ¶
type MockGenerator struct {
InitializeFunc func() error
WriteFunc func(overwrite ...bool) error
GenerateFunc func(data map[string]any, overwrite ...bool) error
}
MockGenerator is a mock implementation of the Generator interface for testing purposes
func NewMockGenerator ¶
func NewMockGenerator() *MockGenerator
NewMockGenerator creates a new instance of MockGenerator
func (*MockGenerator) Generate ¶ added in v0.7.0
func (m *MockGenerator) Generate(data map[string]any, overwrite ...bool) error
Generate calls the mock GenerateFunc if set, otherwise returns nil
func (*MockGenerator) Initialize ¶
func (m *MockGenerator) Initialize() error
Initialize calls the mock InitializeFunc if set, otherwise returns nil
func (*MockGenerator) Write ¶
func (m *MockGenerator) Write(overwrite ...bool) error
Write calls the mock WriteFunc if set, otherwise returns nil
type Shims ¶ added in v0.5.7
type Shims struct {
WriteFile func(name string, data []byte, perm os.FileMode) error
ReadFile func(name string) ([]byte, error)
MkdirAll func(path string, perm os.FileMode) error
Stat func(name string) (os.FileInfo, error)
MarshalYAML func(v any) ([]byte, error)
RemoveAll func(path string) error
Chdir func(dir string) error
ReadDir func(name string) ([]os.DirEntry, error)
Setenv func(key, value string) error
YamlUnmarshal func(data []byte, v any) error
JsonMarshal func(v any) ([]byte, error)
JsonUnmarshal func(data []byte, v any) error
FilepathRel func(basepath, targpath string) (string, error)
NewTarReader func(r io.Reader) *tar.Reader
NewBytesReader func(data []byte) io.Reader
Create func(path string) (*os.File, error)
Copy func(dst io.Writer, src io.Reader) (int64, error)
Chmod func(name string, mode os.FileMode) error
EOFError func() error
TypeDir func() byte
}
Shims provides mockable wrappers around system and runtime functions
type TerraformGenerator ¶
type TerraformGenerator struct {
BaseGenerator
// contains filtered or unexported fields
}
TerraformGenerator is a generator that writes Terraform files
func NewTerraformGenerator ¶
func NewTerraformGenerator(injector di.Injector) *TerraformGenerator
NewTerraformGenerator creates a new TerraformGenerator with the provided dependency injector. It initializes the base generator and prepares it for Terraform file generation.
func (*TerraformGenerator) Generate ¶ added in v0.7.0
func (g *TerraformGenerator) Generate(data map[string]any, overwrite ...bool) error
Generate creates Terraform configuration files, including tfvars files, for all blueprint components. It processes template data keyed by "terraform/<module_path>", generating tfvars files at contexts/<context>/terraform/<module_path>.tfvars. For each entry in the input data, it skips keys not prefixed with "terraform/" and skips components not present in the blueprint. For all components in the blueprint, it ensures a tfvars file is generated if not already handled by the input data. The method uses the blueprint handler to retrieve TerraformComponents and determines the variables.tf location based on component source (remote or local). Module resolution is handled by pkg/terraform.
func (*TerraformGenerator) Write ¶
func (g *TerraformGenerator) Write(overwrite ...bool) error
Write generates Terraform configuration files for all components, including tfvars files. It processes jsonnet templates from the contexts/_template/terraform directory, merges template values into blueprint Terraform components, and delegates file generation to Generate. Module resolution is now handled by the pkg/terraform package.