Skip to content
This repository was archived by the owner on Jan 8, 2024. It is now read-only.

Commit 1b1de1c

Browse files
authored
Merge pull request #4112 from hashicorp/maint/core-config/fixup-panic-on-missing-use
internal/config: Fix panic if no scoped use stanza found
2 parents 5120e48 + d754b74 commit 1b1de1c

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

.changelog/4112.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
```release-note:bug
2+
core: Fix panic if no Use stanza found for given workspace scope on a build,
3+
deploy, release, or registry stanza.
4+
```

internal/config/app.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,8 @@ func (c *App) Release(ctx *hcl.EvalContext) (*Release, error) {
278278
func (c *App) BuildUse(ctx *hcl.EvalContext) (string, error) {
279279
if c.BuildRaw == nil {
280280
return "", nil
281+
} else if c.BuildRaw.Use == nil {
282+
return "", nil
281283
}
282284

283285
useType := c.BuildRaw.Use.Type
@@ -296,6 +298,8 @@ func (c *App) BuildUse(ctx *hcl.EvalContext) (string, error) {
296298
func (c *App) RegistryUse(ctx *hcl.EvalContext) (string, error) {
297299
if c.BuildRaw == nil || c.BuildRaw.Registry == nil {
298300
return "", nil
301+
} else if c.BuildRaw.Registry.Use == nil {
302+
return "", nil
299303
}
300304

301305
useType := c.BuildRaw.Registry.Use.Type
@@ -314,6 +318,8 @@ func (c *App) RegistryUse(ctx *hcl.EvalContext) (string, error) {
314318
func (c *App) DeployUse(ctx *hcl.EvalContext) (string, error) {
315319
if c.DeployRaw == nil {
316320
return "", nil
321+
} else if c.DeployRaw.Use == nil {
322+
return "", nil
317323
}
318324

319325
useType := c.DeployRaw.Use.Type
@@ -332,6 +338,8 @@ func (c *App) DeployUse(ctx *hcl.EvalContext) (string, error) {
332338
func (c *App) ReleaseUse(ctx *hcl.EvalContext) (string, error) {
333339
if c.ReleaseRaw == nil {
334340
return "", nil
341+
} else if c.ReleaseRaw.Use == nil {
342+
return "", nil
335343
}
336344

337345
useType := c.ReleaseRaw.Use.Type

0 commit comments

Comments
 (0)