{"modulePath":"github.com/windsorcli/cli","version":"v0.7.1","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package generators\n\n## Types\n\n```go\ntype BaseGenerator struct {\n\t// contains filtered or unexported fields\n}\n```\nBaseGenerator is a base implementation of the Generator interface\n\n```go\nfunc NewGenerator(injector di.Injector) *BaseGenerator\n```\nNewGenerator creates a new BaseGenerator\n\n```go\nfunc (g *BaseGenerator) Generate(data map[string]any, overwrite ...bool) error\n```\nGenerate 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.\n\n```go\nfunc (g *BaseGenerator) Initialize() error\n```\nInitialize 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.\n\n```go\nfunc (g *BaseGenerator) Write(overwrite ...bool) error\n```\nWrite is a placeholder implementation of the Write method. Concrete implementations should override this method to provide specific generation logic.\n\n```go\ntype Generator interface {\n\tInitialize() error\n\tWrite(overwrite ...bool) error\n\tGenerate(data map[string]any, overwrite ...bool) error\n}\n```\nGenerator is the interface for all code generators It defines methods for initialization and file generation All generators must implement this interface\n\n```go\ntype GitGenerator struct {\n\tBaseGenerator\n}\n```\nGitGenerator is a generator that writes Git configuration files\n\n```go\nfunc NewGitGenerator(injector di.Injector) *GitGenerator\n```\nNewGitGenerator creates a new GitGenerator\n\n```go\nfunc (g *GitGenerator) Generate(data map[string]any, overwrite ...bool) error\n```\nGenerate 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.\n\n```go\nfunc (g *GitGenerator) Write(overwrite ...bool) error\n```\nWrite 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.\n\n```go\ntype MockGenerator struct {\n\tInitializeFunc func() error\n\tWriteFunc      func(overwrite ...bool) error\n\tGenerateFunc   func(data map[string]any, overwrite ...bool) error\n}\n```\nMockGenerator is a mock implementation of the Generator interface for testing purposes\n\n```go\nfunc NewMockGenerator() *MockGenerator\n```\nNewMockGenerator creates a new instance of MockGenerator\n\n```go\nfunc (m *MockGenerator) Generate(data map[string]any, overwrite ...bool) error\n```\nGenerate calls the mock GenerateFunc if set, otherwise returns nil\n\n```go\nfunc (m *MockGenerator) Initialize() error\n```\nInitialize calls the mock InitializeFunc if set, otherwise returns nil\n\n```go\nfunc (m *MockGenerator) Write(overwrite ...bool) error\n```\nWrite calls the mock WriteFunc if set, otherwise returns nil\n\n```go\ntype Shims struct {\n\tWriteFile      func(name string, data []byte, perm os.FileMode) error\n\tReadFile       func(name string) ([]byte, error)\n\tMkdirAll       func(path string, perm os.FileMode) error\n\tStat           func(name string) (os.FileInfo, error)\n\tMarshalYAML    func(v any) ([]byte, error)\n\tRemoveAll      func(path string) error\n\tChdir          func(dir string) error\n\tReadDir        func(name string) ([]os.DirEntry, error)\n\tSetenv         func(key, value string) error\n\tYamlUnmarshal  func(data []byte, v any) error\n\tJsonMarshal    func(v any) ([]byte, error)\n\tJsonUnmarshal  func(data []byte, v any) error\n\tFilepathRel    func(basepath, targpath string) (string, error)\n\tNewTarReader   func(r io.Reader) *tar.Reader\n\tNewBytesReader func(data []byte) io.Reader\n\tCreate         func(path string) (*os.File, error)\n\tCopy           func(dst io.Writer, src io.Reader) (int64, error)\n\tChmod          func(name string, mode os.FileMode) error\n\tEOFError       func() error\n\tTypeDir        func() byte\n}\n```\nShims provides mockable wrappers around system and runtime functions\n\n```go\nfunc NewShims() *Shims\n```\nNewShims creates a new Shims instance with default implementations\n\n```go\ntype TerraformGenerator struct {\n\tBaseGenerator\n\t// contains filtered or unexported fields\n}\n```\nTerraformGenerator is a generator that writes Terraform files\n\n```go\nfunc NewTerraformGenerator(injector di.Injector) *TerraformGenerator\n```\nNewTerraformGenerator creates a new TerraformGenerator with the provided dependency injector. It initializes the base generator and prepares it for Terraform file generation.\n\n```go\nfunc (g *TerraformGenerator) Generate(data map[string]any, overwrite ...bool) error\n```\nGenerate creates Terraform configuration files, including tfvars files, for all blueprint components. It processes template data keyed by \"terraform/\\\u003cmodule\\_path\u003e\", generating tfvars files at contexts/\\\u003ccontext\u003e/terraform/\\\u003cmodule\\_path\u003e.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.\n\n```go\nfunc (g *TerraformGenerator) Write(overwrite ...bool) error\n```\nWrite 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.\n\n```go\ntype VariableInfo struct {\n\tName        string\n\tDescription string\n\tDefault     any\n\tSensitive   bool\n}\n```\nVariableInfo holds metadata for a single Terraform variable\n\n","path":"github.com/windsorcli/cli/pkg/generators","name":"generators","synopsis":"","isRedistributable":true}
