Skip to content

Commit

Permalink
fixed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
NoSkillGirl committed Nov 11, 2020
1 parent 7fbe422 commit ca31568
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 26 deletions.
14 changes: 4 additions & 10 deletions pkg/kyverno/apply/command.go
Expand Up @@ -103,8 +103,8 @@ func Command() *cobra.Command {
}
}

if len(policyPaths) == 0 && !cluster {
return sanitizedError.NewWithError(fmt.Sprintf("policy file(s) or cluster required"), err)
if len(policyPaths) == 0 {
return sanitizedError.NewWithError(fmt.Sprintf("require policy"), err)
}

policies, err := common.ValidateAndGetPolicies(policyPaths)
Expand Down Expand Up @@ -133,7 +133,7 @@ func Command() *cobra.Command {
return sanitizedError.NewWithError("failed to load resources", err)
}
}

mutatedPolicies, err := mutatePolices(policies)

msgPolicies := "1 policy"
Expand All @@ -160,12 +160,6 @@ func Command() *cobra.Command {
continue
}

if common.PolicyHasVariables(*policy) && variablesString == "" && valuesFile == "" {
rc.skip += len(resources)
fmt.Printf("\nskipping policy %s as it has variables. pass the values for the variables using set/values_file flag", policy.Name)
continue
}

if common.PolicyHasVariables(*policy) && variablesString == "" && valuesFile == "" {
return sanitizedError.NewWithError(fmt.Sprintf("policy %s have variables. pass the values for the variables using set/values_file flag", policy.Name), err)
}
Expand Down Expand Up @@ -304,7 +298,7 @@ func printReportOrViolation(policyReport bool, engineResponses []response.Engine
yamlReport, _ := yaml1.Marshal(report)
fmt.Println(string(yamlReport))
} else {
fmt.Println("----------------------------------------------------------------------\nPOLICY REPORT: not generated as no validation failure")
fmt.Println("----------------------------------------------------------------------\nPOLICY REPORT: not generated (no validation failure/resource skipped)")
}

} else {
Expand Down
15 changes: 0 additions & 15 deletions pkg/kyverno/common/fetch.go
Expand Up @@ -86,21 +86,6 @@ func GetResources(policies []*v1.ClusterPolicy, resourcePaths []string, dClient
return resources, nil
}

func getResourceFromCluster(resourceTypes []string, resourceName string, dClient *client.Client) (*unstructured.Unstructured, error) {
var resource *unstructured.Unstructured
for _, kind := range resourceTypes {
r, err := dClient.GetResource("", kind, "", resourceName, "")

if err != nil {
continue
} else {
return r, nil
}
}

return resource, nil
}

// GetResource converts raw bytes to unstructured object
func GetResource(resourceBytes []byte) ([]*unstructured.Unstructured, error) {
resources := make([]*unstructured.Unstructured, 0)
Expand Down
2 changes: 1 addition & 1 deletion pkg/utils/loadpolicy.go
Expand Up @@ -33,7 +33,7 @@ func GetPolicy(file []byte) (clusterPolicies []*v1.ClusterPolicy, errors []error
}

if !(policy.TypeMeta.Kind == "ClusterPolicy" || policy.TypeMeta.Kind == "Policy") {
errors = append(errors, fmt.Errorf(fmt.Sprintf("resource %v is not a policy/cluster policy", policy.Name)))
errors = append(errors, fmt.Errorf(fmt.Sprintf("resource %v is not a policy/clusterPolicy", policy.Name)))
continue
}
clusterPolicies = append(clusterPolicies, policy)
Expand Down

0 comments on commit ca31568

Please sign in to comment.