diff --git a/pkg/kube/resources.go b/pkg/kube/resources.go index 580843b8..ace20eef 100644 --- a/pkg/kube/resources.go +++ b/pkg/kube/resources.go @@ -370,6 +370,9 @@ func addResourceFromString(contents string, resources *ResourceProvider) error { } else if resource.Kind == "Ingress" { ingress := v1beta1.Ingress{} err = decoder.Decode(&ingress) + if err != nil { + return err + } resources.Ingresses = append(resources.Ingresses, ingress) } else { newController, err := GetWorkloadFromBytes(contentBytes) @@ -377,7 +380,12 @@ func addResourceFromString(contents string, resources *ResourceProvider) error { return err } if newController == nil { - // Handle Arbitrary Kinds Here + unst := unstructured.Unstructured{} + err = decoder.Decode(&unst) + if err != nil { + return err + } + resources.ArbitraryKinds = append(resources.ArbitraryKinds, &unst) } else { resources.Controllers = append(resources.Controllers, *newController) } diff --git a/pkg/validator/controller_test.go b/pkg/validator/controller_test.go index b6510027..4834af70 100644 --- a/pkg/validator/controller_test.go +++ b/pkg/validator/controller_test.go @@ -111,7 +111,7 @@ func TestControllerLevelChecks(t *testing.T) { two := int32(2) d2.Spec.Replicas = &two k8s, dynamicClient := test.SetupTestAPI(&d1, &p1, &d2, &p2) - res, err = kube.CreateResourceProviderFromAPI(context.Background(), k8s, "test", &dynamicClient) + res, err = kube.CreateResourceProviderFromAPI(context.Background(), k8s, "test", &dynamicClient, conf.Configuration{}) assert.Equal(t, err, nil, "error should be nil") assert.Equal(t, 2, len(res.Controllers), "Should have two controllers") testResources(res) diff --git a/pkg/validator/fullaudit.go b/pkg/validator/fullaudit.go index 399a4d55..b26cea0c 100644 --- a/pkg/validator/fullaudit.go +++ b/pkg/validator/fullaudit.go @@ -34,7 +34,11 @@ func RunAudit(config conf.Configuration, kubeResources *kube.ResourceProvider, o } results = append(results, ingressResults...) - // Call Arbitrary Kind Validation here + arbitraryResults, err := ValidateArbitraryKinds(&config, kubeResources) + if err != nil { + return AuditData{}, err + } + results = append(results, arbitraryResults...) auditData := AuditData{ PolarisOutputVersion: PolarisOutputVersion, diff --git a/pkg/validator/fullaudit_test.go b/pkg/validator/fullaudit_test.go index 60fcdd24..c8cdeb46 100644 --- a/pkg/validator/fullaudit_test.go +++ b/pkg/validator/fullaudit_test.go @@ -11,11 +11,6 @@ import ( ) func TestGetTemplateData(t *testing.T) { - k8s, dynamicClient := test.SetupTestAPI(test.GetMockControllers("test")...) - resources, err := kube.CreateResourceProviderFromAPI(context.Background(), k8s, "test", &dynamicClient) - assert.Equal(t, err, nil, "error should be nil") - assert.Equal(t, 5, len(resources.Controllers)) - c := conf.Configuration{ Checks: map[string]conf.Severity{ "readinessProbeMissing": conf.SeverityDanger, @@ -23,6 +18,11 @@ func TestGetTemplateData(t *testing.T) { }, } + k8s, dynamicClient := test.SetupTestAPI(test.GetMockControllers("test")...) + resources, err := kube.CreateResourceProviderFromAPI(context.Background(), k8s, "test", &dynamicClient, c) + assert.Equal(t, err, nil, "error should be nil") + assert.Equal(t, 5, len(resources.Controllers)) + sum := CountSummary{ Successes: uint(0), Warnings: uint(3),