From a0ecb99a2750859075c0b3347a11ccb5e25823a1 Mon Sep 17 00:00:00 2001 From: Teodora Sandu Date: Thu, 9 Dec 2021 10:11:32 +0000 Subject: [PATCH] fix: remove extra error log --- cmd/template.go | 6 ++++-- main.go | 2 -- spec/e2e/push_spec.sh | 15 +++++---------- spec/e2e/template_spec.sh | 5 ++--- 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/cmd/template.go b/cmd/template.go index 157a61e..2169975 100644 --- a/cmd/template.go +++ b/cmd/template.go @@ -51,13 +51,15 @@ $ snyk-iac-rules test --help return nil }, PreRunE: func(cmd *cobra.Command, args []string) error { + ruleId := strings.ToUpper(templateParams.RuleID) + // make sure rule name doesn't have any whitespace in it - if strings.Contains(templateParams.RuleID, " ") { + if strings.Contains(ruleId, " ") { return fmt.Errorf("Rule name cannot contain whitespace") } // make sure rule name doesn't belong to Snyk namespace - if strings.HasPrefix(templateParams.RuleID, "SNYK-") { + if strings.HasPrefix(ruleId, "SNYK-") { return fmt.Errorf("Rule name cannot start with \"SNYK-\"") } diff --git a/main.go b/main.go index 64a3378..175eb85 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,6 @@ package main import ( - "fmt" "os" "github.com/snyk/snyk-iac-rules/builtins" @@ -14,7 +13,6 @@ func main() { builtins.RegisterTerraformPlanBuiltin() if err := cmd.RootCommand.Execute(); err != nil { - fmt.Println(err) os.Exit(1) } } diff --git a/spec/e2e/push_spec.sh b/spec/e2e/push_spec.sh index 119f974..ef50786 100644 --- a/spec/e2e/push_spec.sh +++ b/spec/e2e/push_spec.sh @@ -25,8 +25,7 @@ Describe './snyk-iac-rules push -r docker.io/test/test test.jpg' It 'returns failing test status' When call ./snyk-iac-rules push -r docker.io/test/test test.jpg The status should be failure - The output should include 'The path must be to a generated .tar.gz bundle' - The stderr should be present + The stderr should include 'The path must be to a generated .tar.gz bundle' End End @@ -34,8 +33,7 @@ Describe 'When call ./snyk-iac-rules push -r https://docker.io/test/test bundle. It 'returns failing test status' When call ./snyk-iac-rules push -r https://docker.io/test/test bundle.tar.gz The status should be failure - The output should include 'The provided container registry includes a protocol. Please remove it and try again' - The stderr should be present + The stderr should include 'The provided container registry includes a protocol. Please remove it and try again' End End @@ -44,8 +42,7 @@ Describe './snyk-iac-rules push -r docker.io/test/test bundle-incorrect.tar.gz' It 'returns failing test status' When call ./snyk-iac-rules push -r docker.io/test/test bundle-incorrect.tar.gz The status should be failure - The output should include 'Failed to read from the provided path' - The stderr should be present + The stderr should include 'Failed to read from the provided path' End End @@ -53,8 +50,7 @@ Describe './snyk-iac-rules push -r test bundle.tar.gz' It 'returns failing test status' When call ./snyk-iac-rules push -r test bundle.tar.gz The status should be failure - The output should include 'The provided container registry is invalid' - The stderr should be present + The stderr should include 'The provided container registry is invalid' End End @@ -64,8 +60,7 @@ Describe './snyk-iac-rules push -r docker.io/test/test bundle.tar.gz' When call ./snyk-iac-rules push -r docker.io/test/test bundle.tar.gz The status should be failure The output should include 'bundle.tar.gz' - The output should include 'Failed to push bundle to container registry: server message: insufficient_scope: authorization failed' - The stderr should be present + The stderr should include 'Failed to push bundle to container registry: server message: insufficient_scope: authorization failed' End End diff --git a/spec/e2e/template_spec.sh b/spec/e2e/template_spec.sh index a39ef21..2d72273 100644 --- a/spec/e2e/template_spec.sh +++ b/spec/e2e/template_spec.sh @@ -38,9 +38,8 @@ End Describe './snyk-iac-rules template ./fixtures/custom-rules --rule test' It 'returns passing test status' When call ./snyk-iac-rules template ./fixtures/custom-rules --rule test - Dump The status should be failure - The output should include 'Rule with the provided name already exists' - The stderr should be present + The output should include 'Template rules directory' + The stderr should include 'Rule with the provided name already exists' End End