1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-14 11:57:48 +00:00

Removed confusing output message for the apply and replaced no of policies by no of policy rules count in the output message (#4229)

Signed-off-by: anutosh491 <andersonbhat491@gmail.com>
This commit is contained in:
Anutosh Bhat 2022-07-19 16:28:09 +05:30 committed by GitHub
parent 612b7fdff2
commit 81c699b4a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -260,9 +260,22 @@ func applyCommandHelper(resourcePaths []string, userInfoPath string, cluster boo
variables = common.SetInStoreContext(mutatedPolicies, variables)
}
msgPolicies := "1 policy"
if len(mutatedPolicies) > 1 {
msgPolicies = fmt.Sprintf("%d policies", len(policies))
var policyRulesCount, mutatedPolicyRulesCount int
for _, policy := range policies {
policyRulesCount += len(policy.GetSpec().Rules)
}
for _, policy := range mutatedPolicies {
mutatedPolicyRulesCount += len(policy.GetSpec().Rules)
}
msgPolicyRules := "1 policy rule"
if policyRulesCount > 1 {
msgPolicyRules = fmt.Sprintf("%d policy rules", policyRulesCount)
}
if mutatedPolicyRulesCount > policyRulesCount {
msgPolicyRules = fmt.Sprintf("%d policy rules", mutatedPolicyRulesCount)
}
msgResources := "1 resource"
@ -272,7 +285,11 @@ func applyCommandHelper(resourcePaths []string, userInfoPath string, cluster boo
if len(mutatedPolicies) > 0 && len(resources) > 0 {
if !stdin {
fmt.Printf("\nApplying %s to %s... \n(Total number of result count may vary as the policy is mutated by Kyverno. To check the mutated policy please try with log level 5)\n", msgPolicies, msgResources)
if mutatedPolicyRulesCount > policyRulesCount {
fmt.Printf("\nauto-generated pod policies\nApplying %s to %s...\n", msgPolicyRules, msgResources)
} else {
fmt.Printf("\nApplying %s to %s...\n", msgPolicyRules, msgResources)
}
}
}