Skip to content

Commit

Permalink
TER-249 fix app yaml support in generate command (#84)
Browse files Browse the repository at this point in the history
There was a bug that'd not allow yaml files in input flags even while having it documented. Reason was the extension value was inaccurately checked for `yaml` or `yml` instead of `.yaml` or `.yml`.
This change fixes the condition, and also adds unit test to assert this use-case.
  • Loading branch information
Kanak Singhal authored Sep 11, 2023
1 parent b4362a5 commit 4861be5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/cli/cmd/generate/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func readAppDependency(appYamlPath string) ([]byte, error) {
// If it's a directory, append terrarium.yaml to the path
if info.IsDir() {
appYamlPath = path.Join(appYamlPath, defaultYAMLFileName)
} else if !slices.Contains([]string{"yml", "yaml"}, path.Ext(appYamlPath)) {
} else if !slices.Contains([]string{".yml", ".yaml"}, path.Ext(appYamlPath)) {
// If it's a file but not a .yaml, return an error
return nil, eris.New("provided path is not a directory or a .yaml|.yml file")
}
Expand Down
2 changes: 1 addition & 1 deletion src/cli/cmd/generate/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestCmd(t *testing.T) {
},
{
Name: "Success (no profile)",
Args: []string{"-p", "../../../../examples/platform/", "-a", "../../../../examples/apps/voting-be", "-a", "../../../../examples/apps/voting-worker", "-o", "./testdata/.terrarium"},
Args: []string{"-p", "../../../../examples/platform/", "-a", "../../../../examples/apps/voting-be/terrarium.yaml", "-a", "../../../../examples/apps/voting-worker", "-o", "./testdata/.terrarium"},
ValidateOutput: clitesting.ValidateOutputMatch("Successfully pulled 13 of 22 terraform blocks at: ./testdata/.terrarium\n"),
},
{
Expand Down

2 comments on commit 4861be5

@code-pipes
Copy link

@code-pipes code-pipes bot commented on 4861be5 Sep 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Job Name terrarium-cli-test-integration-pipeline
Job Status failed
Total Steps 2
Progress 1
Message An unexpected error occurred: build has finished with status: Failure
View on Code Pipes

@code-pipes
Copy link

@code-pipes code-pipes bot commented on 4861be5 Sep 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Job Name terrarium-cli-test-integration-pipeline
Job Status failed
Total Steps 2
Progress 1
Message An unexpected error occurred: build has finished with status: Failure
View on Code Pipes

Please sign in to comment.