Removed confusing output message for the apply and replaced no of policies by no of policy rules count in the output message
@@ -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)
+ }
}
}
