Skip to content

Commit

Permalink
chore: improve warning message to contain offended stack.
Browse files Browse the repository at this point in the history
In case a stack contains invalid paths in after/before/wants/wanted_by
the offended stack needs to be in the warning output.

Signed-off-by: i4k <[email protected]>
  • Loading branch information
i4ki committed Sep 16, 2024
1 parent e57310e commit 764f8ea
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions e2etests/core/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func TestCLIRunOrder(t *testing.T) {
Stdout: nljoin(
`/stack`,
),
StderrRegex: "Warning: Stack references invalid path in 'after' attribute",
StderrRegex: "Warning: Stack /stack references invalid path in 'after' attribute",
},
},
{
Expand All @@ -91,7 +91,7 @@ func TestCLIRunOrder(t *testing.T) {
Stdout: nljoin(
`/stack`,
),
StderrRegex: "Warning: Stack references invalid path in 'after' attribute",
StderrRegex: "Warning: Stack /stack references invalid path in 'after' attribute",
},
},
{
Expand Down Expand Up @@ -1501,7 +1501,7 @@ func TestRunWantedBy(t *testing.T) {
"/stacks/stack-b",
),
StderrRegexes: []string{
"Stack references invalid path in 'wanted_by' attribute",
"Stack /stacks/stack-a references invalid path in 'wanted_by' attribute",
"no such file or directory",
},
},
Expand Down
1 change: 1 addition & 0 deletions hcl/stack.tm.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ stack {
description = "package hcl // import \"github.com/terramate-io/terramate/hcl\"\n\nPackage hcl provides parsing functionality for Terramate HCL configuration.\nIt also provides printing and formatting for Terramate configuration.\n\nconst ErrHCLSyntax errors.Kind = \"HCL syntax error\" ...\nconst ErrScriptNoLabels errors.Kind = \"terramate schema error: (script): must provide at least one label\" ...\nconst SharingIsCaringExperimentName = \"outputs-sharing\"\nconst StackBlockType = \"stack\"\nfunc IsRootConfig(rootdir string) (bool, error)\nfunc MatchAnyGlob(globs []glob.Glob, s string) bool\nfunc PrintConfig(w io.Writer, cfg Config) error\nfunc PrintImports(w io.Writer, imports []string) error\nfunc ValueAsStringList(val cty.Value) ([]string, error)\ntype AssertConfig struct{ ... }\ntype ChangeDetectionConfig struct{ ... }\ntype CloudConfig struct{ ... }\ntype Command ast.Attribute\n func NewScriptCommand(attr ast.Attribute) *Command\ntype Commands ast.Attribute\n func NewScriptCommands(attr ast.Attribute) *Commands\ntype Config struct{ ... }\n func NewConfig(dir string) (Config, error)\n func ParseDir(root string, dir string, experiments ...string) (Config, error)\ntype Evaluator interface{ ... }\ntype GenFileBlock struct{ ... }\ntype GenHCLBlock struct{ ... }\ntype GenerateConfig struct{ ... }\ntype GenerateRootConfig struct{ ... }\ntype GitConfig struct{ ... }\n func NewGitConfig() *GitConfig\ntype Input struct{ ... }\ntype Inputs []Input\ntype ManifestConfig struct{ ... }\ntype ManifestDesc struct{ ... }\ntype OptionalCheck int\n const CheckIsUnset OptionalCheck = iota ...\n func ToOptionalCheck(v bool) OptionalCheck\ntype Output struct{ ... }\ntype Outputs []Output\ntype RawConfig struct{ ... }\n func NewCustomRawConfig(handlers map[string]mergeHandler) RawConfig\n func NewTopLevelRawConfig() RawConfig\ntype RootConfig struct{ ... }\ntype RunConfig struct{ ... }\n func NewRunConfig() *RunConfig\ntype RunEnv struct{ ... }\ntype Script struct{ ... }\ntype ScriptJob struct{ ... }\ntype SharingBackend struct{ ... }\ntype SharingBackendType int\n const TerraformSharingBackend SharingBackendType = iota + 1\ntype SharingBackends []SharingBackend\ntype Stack struct{ ... }\ntype StackFilterConfig struct{ ... }\ntype TargetsConfig struct{ ... }\ntype TerragruntChangeDetectionEnabledOption int\n const TerragruntAutoOption TerragruntChangeDetectionEnabledOption = iota ...\ntype TerragruntConfig struct{ ... }\ntype Terramate struct{ ... }\ntype TerramateParser struct{ ... }\n func NewStrictTerramateParser(rootdir string, dir string, experiments ...string) (*TerramateParser, error)\n func NewTerramateParser(rootdir string, dir string, experiments ...string) (*TerramateParser, error)\ntype VendorConfig struct{ ... }"
tags = ["golang", "hcl"]
id = "dd11014a-a1bb-4f1c-99da-8f6d188d36d1"
after = ["/e2etess"]
}
4 changes: 2 additions & 2 deletions run/order.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,12 @@ func BuildDAG(
st, err := os.Stat(abspath)
if err != nil {
printer.Stderr.WarnWithDetails(
fmt.Sprintf("Stack references invalid path in '%s' attribute", fieldname),
fmt.Sprintf("Stack %s references invalid path in '%s' attribute", s.Dir, fieldname),
err,
)
} else if !st.IsDir() {
printer.Stderr.WarnWithDetails(
fmt.Sprintf("Stack references invalid path in '%s' attribute", fieldname),
fmt.Sprintf("Stack %s references invalid path in '%s' attribute", s.Dir, fieldname),
errors.E("Path %s is not a directory", pathstr),
)
} else {
Expand Down

0 comments on commit 764f8ea

Please sign in to comment.