1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-31 03:45:17 +00:00

fix deployment-missing-labels test

Signed-off-by: Jim Bugwadia <jim@nirmata.com>
This commit is contained in:
Jim Bugwadia 2021-10-03 22:36:06 -07:00
parent c9ec282764
commit 529a3509d5
2 changed files with 9 additions and 4 deletions

View file

@ -50,11 +50,13 @@ func Command() *cobra.Command {
}
}
}()
_, err = testCommandExecute(dirPath, valuesFile, fileName)
if err != nil {
log.Log.V(3).Info("a directory is required")
return err
}
return nil
},
}
@ -192,14 +194,16 @@ func testCommandExecute(dirPath []string, valuesFile string, fileName string) (r
}
if len(errors) > 0 && log.Log.V(1).Enabled() {
fmt.Printf("ignoring errors: \n")
fmt.Printf("test errors: \n")
for _, e := range errors {
fmt.Printf(" %v \n", e.Error())
}
}
if rc.Fail > 0 {
os.Exit(1)
}
os.Exit(0)
return rc, nil
}
@ -430,12 +434,13 @@ func applyPoliciesFromPath(fs billy.Filesystem, policyBytes []byte, valuesFile s
pvInfos = append(pvInfos, info)
}
}
resultsMap, testResults := buildPolicyResults(validateEngineResponses, values.Results, pvInfos)
resultsMap, testResults := buildPolicyResults(validateEngineResponses, values.Results, pvInfos)
resultErr := printTestResult(resultsMap, testResults, rc)
if resultErr != nil {
return sanitizederror.NewWithError("Unable to genrate result. Error:", resultErr)
return sanitizederror.NewWithError("failed to print test result:", resultErr)
}
return
}

View file

@ -24,7 +24,7 @@ results:
# TEST: Deployment with Labels Should Fail
- policy: require-common-labels
rule: check-for-labels
result: fail
result: skip
resource: deployment-missing-labels
# TEST: StatefulSet with Labels Should Pass