Skip to content

Commit c488022

Browse files
committed
propagate projectName to projects
1 parent 8503091 commit c488022

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

libs/digger_config/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ type AssumeRoleForProject struct {
4242
}
4343

4444
type Project struct {
45+
BlockName string // the block name if this is a generated project
4546
Name string
4647
Dir string
4748
Workspace string

libs/digger_config/converters.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ func copyProjects(projects []*ProjectYaml) []Project {
6969
workspace = p.Workspace
7070
}
7171

72-
item := Project{p.Name,
72+
item := Project{
73+
p.BlockName,
74+
p.Name,
7375
p.Dir,
7476
workspace,
7577
p.Terragrunt,

libs/digger_config/digger_config.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ func HandleYamlProjectGeneration(config *DiggerConfigYaml, terraformDir string,
329329
slog.Warn("terragrunt generation using top level config is deprecated",
330330
"recommendation", "https://docs.digger.dev/howto/generate-projects#blocks-syntax-with-terragrunt")
331331

332-
err := hydrateDiggerConfigYamlWithTerragrunt(config, *config.GenerateProjectsConfig.TerragruntParsingConfig, terraformDir)
332+
err := hydrateDiggerConfigYamlWithTerragrunt(config, *config.GenerateProjectsConfig.TerragruntParsingConfig, terraformDir, "")
333333
if err != nil {
334334
slog.Error("failed to hydrate config with terragrunt", "error", err)
335335
return err
@@ -338,7 +338,7 @@ func HandleYamlProjectGeneration(config *DiggerConfigYaml, terraformDir string,
338338
slog.Warn("terragrunt generation using top level config is deprecated",
339339
"recommendation", "https://docs.digger.dev/howto/generate-projects#blocks-syntax-with-terragrunt")
340340

341-
err := hydrateDiggerConfigYamlWithTerragrunt(config, TerragruntParsingConfig{}, terraformDir)
341+
err := hydrateDiggerConfigYamlWithTerragrunt(config, TerragruntParsingConfig{}, terraformDir, "")
342342
if err != nil {
343343
slog.Error("failed to hydrate config with terragrunt", "error", err)
344344
return err
@@ -420,7 +420,7 @@ func HandleYamlProjectGeneration(config *DiggerConfigYaml, terraformDir string,
420420
tgParsingConfig.AwsRoleToAssume = b.AwsRoleToAssume
421421
tgParsingConfig.AwsCognitoOidcConfig = b.AwsCognitoOidcConfig
422422

423-
err := hydrateDiggerConfigYamlWithTerragrunt(config, *tgParsingConfig, terraformDir)
423+
err := hydrateDiggerConfigYamlWithTerragrunt(config, *tgParsingConfig, terraformDir, b.BlockName)
424424
if err != nil {
425425
slog.Error("failed to hydrate config with terragrunt",
426426
"error", err,
@@ -699,7 +699,7 @@ func ValidateDiggerConfig(config *DiggerConfig) error {
699699
return nil
700700
}
701701

702-
func hydrateDiggerConfigYamlWithTerragrunt(configYaml *DiggerConfigYaml, parsingConfig TerragruntParsingConfig, workingDir string) error {
702+
func hydrateDiggerConfigYamlWithTerragrunt(configYaml *DiggerConfigYaml, parsingConfig TerragruntParsingConfig, workingDir string, blockName string) error {
703703
slog.Info("hydrating config with terragrunt projects",
704704
"workingDir", workingDir,
705705
"filterPath", parsingConfig.FilterPath)
@@ -806,6 +806,7 @@ func hydrateDiggerConfigYamlWithTerragrunt(configYaml *DiggerConfigYaml, parsing
806806
"workspace", atlantisProject.Workspace)
807807

808808
configYaml.Projects = append(configYaml.Projects, &ProjectYaml{
809+
BlockName: blockName,
809810
Name: atlantisProject.Name,
810811
Dir: projectDir,
811812
Workspace: atlantisProject.Workspace,

libs/digger_config/yaml.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ type DependencyConfigurationYaml struct {
3535
}
3636

3737
type ProjectYaml struct {
38+
BlockName string `yaml:"block_name"`
3839
Name string `yaml:"name"`
3940
Dir string `yaml:"dir"`
4041
Workspace string `yaml:"workspace"`

0 commit comments

Comments
 (0)