Skip to content

Commit 977a0fb

Browse files
committed
Potentially fetch backend variables for most commands
* modules * providers * providers lock * providers mirror * validate * state mv * state pull * state push * state replace provider * state rm * taint * get
1 parent 316d1c2 commit 977a0fb

File tree

7 files changed

+40
-0
lines changed

7 files changed

+40
-0
lines changed

internal/command/get.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ func (c *GetCommand) Run(args []string) int {
5151
return 1
5252
}
5353

54+
diags = diags.Append(c.resolveConstVariables(path, arguments.ViewHuman))
55+
if diags.HasErrors() {
56+
c.showDiagnostics(diags)
57+
return 1
58+
}
59+
5460
path = c.normalizePath(path)
5561

5662
abort, moreDiags := getModules(ctx, &c.Meta, path, parsedArgs.TestDirectory, parsedArgs.Update)

internal/command/meta.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,11 @@ func (m *Meta) checkRequiredVersion() tfdiags.Diagnostics {
831831
return diags
832832
}
833833

834+
diags = diags.Append(m.resolveConstVariables(pwd, arguments.ViewHuman))
835+
if diags.HasErrors() {
836+
return diags
837+
}
838+
834839
config, configDiags := m.loadConfig(pwd)
835840
if configDiags.HasErrors() {
836841
diags = diags.Append(configDiags)

internal/command/modules.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ func (c *ModulesCommand) Run(rawArgs []string) int {
8080
return 1
8181
}
8282

83+
diags = diags.Append(c.resolveConstVariables(rootModPath, args.ViewType))
84+
if diags.HasErrors() {
85+
view.Diagnostics(diags)
86+
return 1
87+
}
88+
8389
config, confDiags := c.loadConfig(rootModPath)
8490
// Here we check if there are any uninstalled dependencies
8591
versionDiags := terraform.CheckCoreVersionRequirements(config)

internal/command/providers.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ func (c *ProvidersCommand) Run(args []string) int {
8484
return 1
8585
}
8686

87+
diags = diags.Append(c.resolveConstVariables(configPath, arguments.ViewHuman))
88+
if diags.HasErrors() {
89+
c.showDiagnostics(diags)
90+
return 1
91+
}
92+
8793
config, configDiags := c.loadConfigWithTests(configPath, parsedArgs.TestsDirectory)
8894
diags = diags.Append(configDiags)
8995
if configDiags.HasErrors() {

internal/command/providers_lock.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ func (c *ProvidersLockCommand) Run(args []string) int {
116116
return 1
117117
}
118118

119+
diags = diags.Append(c.resolveConstVariables(".", arguments.ViewHuman))
120+
if diags.HasErrors() {
121+
c.showDiagnostics(diags)
122+
return 1
123+
}
124+
119125
config, confDiags := c.loadConfigWithTests(".", parsedArgs.TestsDirectory)
120126
diags = diags.Append(confDiags)
121127
reqs, hclDiags := config.ProviderRequirements()

internal/command/providers_mirror.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ func (c *ProvidersMirrorCommand) Run(args []string) int {
7878
return 1
7979
}
8080

81+
diags = diags.Append(c.resolveConstVariables(".", arguments.ViewHuman))
82+
if diags.HasErrors() {
83+
c.showDiagnostics(diags)
84+
return 1
85+
}
86+
8187
config, confDiags := c.loadConfig(".")
8288
diags = diags.Append(confDiags)
8389
reqs, moreDiags := config.ProviderRequirements()

internal/command/validate.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ func (c *ValidateCommand) validate(dir string) tfdiags.Diagnostics {
101101
var diags tfdiags.Diagnostics
102102
var cfg *configs.Config
103103

104+
diags = diags.Append(c.resolveConstVariables(dir, c.ParsedArgs.ViewType))
105+
if diags.HasErrors() {
106+
return diags
107+
}
108+
104109
if c.ParsedArgs.NoTests {
105110
cfg, diags = c.loadConfig(dir)
106111
} else {

0 commit comments

Comments
 (0)