diff --git a/cmd/cli/kubectl-kyverno/commands/apply/command.go b/cmd/cli/kubectl-kyverno/commands/apply/command.go index de36a1b0eb..ecac57d37a 100644 --- a/cmd/cli/kubectl-kyverno/commands/apply/command.go +++ b/cmd/cli/kubectl-kyverno/commands/apply/command.go @@ -12,9 +12,9 @@ import ( "github.com/go-git/go-billy/v5/memfs" kyvernov1 "github.com/kyverno/kyverno/api/kyverno/v1" "github.com/kyverno/kyverno/api/kyverno/v1beta1" - "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/commands/test/api" + "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/output/color" + "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/test/api" cobrautils "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/utils/cobra" - "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/utils/color" "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/utils/common" reportutils "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/utils/report" sanitizederror "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/utils/sanitizedError" diff --git a/cmd/cli/kubectl-kyverno/commands/apply/table.go b/cmd/cli/kubectl-kyverno/commands/apply/table.go index a1fba950f2..fa6b742c8f 100644 --- a/cmd/cli/kubectl-kyverno/commands/apply/table.go +++ b/cmd/cli/kubectl-kyverno/commands/apply/table.go @@ -1,9 +1,9 @@ package apply import ( + "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/output/color" + "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/output/table" "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/policy/annotations" - "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/utils/color" - "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/utils/output/table" engineapi "github.com/kyverno/kyverno/pkg/engine/api" ) diff --git a/cmd/cli/kubectl-kyverno/commands/command.go b/cmd/cli/kubectl-kyverno/commands/command.go index a7cfcb502b..a5717a240c 100644 --- a/cmd/cli/kubectl-kyverno/commands/command.go +++ b/cmd/cli/kubectl-kyverno/commands/command.go @@ -9,8 +9,8 @@ import ( "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/commands/oci" "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/commands/test" "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/commands/version" + "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/experimental" cobrautils "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/utils/cobra" - "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/utils/experimental" "github.com/spf13/cobra" ) diff --git a/cmd/cli/kubectl-kyverno/commands/create/values/command.go b/cmd/cli/kubectl-kyverno/commands/create/values/command.go index b053489b48..658b9cdd59 100644 --- a/cmd/cli/kubectl-kyverno/commands/create/values/command.go +++ b/cmd/cli/kubectl-kyverno/commands/create/values/command.go @@ -6,7 +6,7 @@ import ( "text/template" "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/commands/create/templates" - "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/commands/test/api" + "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/test/api" cobrautils "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/utils/cobra" "github.com/spf13/cobra" ) diff --git a/cmd/cli/kubectl-kyverno/commands/test/api/types.go b/cmd/cli/kubectl-kyverno/commands/test/api/types.go deleted file mode 100644 index 3f2b1e43ae..0000000000 --- a/cmd/cli/kubectl-kyverno/commands/test/api/types.go +++ /dev/null @@ -1,86 +0,0 @@ -package api - -import ( - policyreportv1alpha2 "github.com/kyverno/kyverno/api/policyreport/v1alpha2" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -type Test struct { - Name string `json:"name"` - Policies []string `json:"policies"` - Resources []string `json:"resources"` - Variables string `json:"variables,omitempty"` - UserInfo string `json:"userinfo,omitempty"` - Results []TestResults `json:"results"` - Values *Values `json:"values,omitempty"` -} - -type TestResults struct { - // Policy mentions the name of the policy. - Policy string `json:"policy"` - // Rule mentions the name of the rule in the policy. - // It's required in case policy is a kyverno policy. - // +optional - Rule string `json:"rule,omitempty"` - // IsValidatingAdmissionPolicy indicates if the policy is a validating admission policy. - // It's required in case policy is a validating admission policy. - // +optional - IsValidatingAdmissionPolicy bool `json:"isValidatingAdmissionPolicy,omitempty"` - // Result mentions the result that the user is expecting. - // Possible values are pass, fail and skip. - Result policyreportv1alpha2.PolicyResult `json:"result"` - // Status mentions the status that the user is expecting. - // Possible values are pass, fail and skip. - Status policyreportv1alpha2.PolicyResult `json:"status,omitempty"` - // Resource mentions the name of the resource on which the policy is to be applied. - Resource string `json:"resource,omitempty"` - // Resources gives us the list of resources on which the policy is going to be applied. - Resources []string `json:"resources"` - // Kind mentions the kind of the resource on which the policy is to be applied. - Kind string `json:"kind"` - // Namespace mentions the namespace of the policy which has namespace scope. - Namespace string `json:"namespace,omitempty"` - // PatchedResource takes a resource configuration file in yaml format from - // the user to compare it against the Kyverno mutated resource configuration. - PatchedResource string `json:"patchedResource,omitempty"` - // GeneratedResource takes a resource configuration file in yaml format from - // the user to compare it against the Kyverno generated resource configuration. - GeneratedResource string `json:"generatedResource,omitempty"` - // CloneSourceResource takes the resource configuration file in yaml format - // from the user which is meant to be cloned by the generate rule. - CloneSourceResource string `json:"cloneSourceResource,omitempty"` -} - -type Policy struct { - Name string `json:"name"` - Resources []Resource `json:"resources"` - Rules []Rule `json:"rules"` -} - -type Rule struct { - Name string `json:"name"` - Values map[string]interface{} `json:"values"` - ForeachValues map[string][]interface{} `json:"foreachValues"` -} - -type Values struct { - Policies []Policy `json:"policies"` - GlobalValues map[string]string `json:"globalValues"` - NamespaceSelectors []NamespaceSelector `json:"namespaceSelector"` - Subresources []Subresource `json:"subresources"` -} - -type Resource struct { - Name string `json:"name"` - Values map[string]interface{} `json:"values"` -} - -type Subresource struct { - APIResource metav1.APIResource `json:"subresource"` - ParentResource metav1.APIResource `json:"parentResource"` -} - -type NamespaceSelector struct { - Name string `json:"name"` - Labels map[string]string `json:"labels"` -} diff --git a/cmd/cli/kubectl-kyverno/commands/test/command.go b/cmd/cli/kubectl-kyverno/commands/test/command.go index b757012765..07d45e01d6 100644 --- a/cmd/cli/kubectl-kyverno/commands/test/command.go +++ b/cmd/cli/kubectl-kyverno/commands/test/command.go @@ -7,11 +7,11 @@ import ( "github.com/go-git/go-billy/v5" policyreportv1alpha2 "github.com/kyverno/kyverno/api/policyreport/v1alpha2" - "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/commands/test/api" + "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/output/color" + "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/output/table" + "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/test/api" + "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/test/filter" cobrautils "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/utils/cobra" - "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/utils/color" - filterutils "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/utils/filter" - "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/utils/output/table" reportutils "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/utils/report" sanitizederror "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/utils/sanitizedError" "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/utils/store" @@ -80,7 +80,7 @@ func testCommandExecute( return rc, sanitizederror.NewWithError("a directory is required", err) } // parse filter - filter, errors := filterutils.ParseFilter(testCase) + filter, errors := filter.ParseFilter(testCase) if len(errors) > 0 { fmt.Println() fmt.Println("Filter errors:") diff --git a/cmd/cli/kubectl-kyverno/commands/test/command_test.go b/cmd/cli/kubectl-kyverno/commands/test/command_test.go index a81dac5c9b..eb77737afe 100644 --- a/cmd/cli/kubectl-kyverno/commands/test/command_test.go +++ b/cmd/cli/kubectl-kyverno/commands/test/command_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/go-git/go-billy/v5/memfs" - "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/commands/test/api" + "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/test/api" "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/utils/common" "gotest.tools/assert" "sigs.k8s.io/yaml" diff --git a/cmd/cli/kubectl-kyverno/commands/test/compare.go b/cmd/cli/kubectl-kyverno/commands/test/compare.go index bd7844259a..5580a890d2 100644 --- a/cmd/cli/kubectl-kyverno/commands/test/compare.go +++ b/cmd/cli/kubectl-kyverno/commands/test/compare.go @@ -12,7 +12,7 @@ import ( func getAndCompareResource(actualResource unstructured.Unstructured, fs billy.Filesystem, path string) (bool, error) { expectedResource, err := resource.GetResourceFromPath(fs, path) if err != nil { - return false, fmt.Errorf("Error: failed to load resources (%s)", err) + return false, fmt.Errorf("Error: failed to load resource (%s)", err) } unstructuredutils.FixupGenerateLabels(actualResource) unstructuredutils.FixupGenerateLabels(*expectedResource) diff --git a/cmd/cli/kubectl-kyverno/commands/test/test.go b/cmd/cli/kubectl-kyverno/commands/test/test.go index d217680215..bdf7cd9c99 100644 --- a/cmd/cli/kubectl-kyverno/commands/test/test.go +++ b/cmd/cli/kubectl-kyverno/commands/test/test.go @@ -7,9 +7,9 @@ import ( "github.com/go-git/go-billy/v5" kyvernov1 "github.com/kyverno/kyverno/api/kyverno/v1" "github.com/kyverno/kyverno/api/kyverno/v1beta1" - "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/commands/test/api" + "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/test/api" + "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/test/filter" "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/utils/common" - filterutils "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/utils/filter" pathutils "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/utils/path" sanitizederror "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/utils/sanitizedError" "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/utils/store" @@ -32,7 +32,7 @@ func applyPoliciesFromPath( policyResourcePath string, rc *resultCounts, openApiManager openapi.Manager, - filter filterutils.Filter, + filter filter.Filter, auditWarn bool, ) ([]api.TestResults, []engineapi.EngineResponse, error) { engineResponses := make([]engineapi.EngineResponse, 0) diff --git a/cmd/cli/kubectl-kyverno/utils/experimental/experimental.go b/cmd/cli/kubectl-kyverno/experimental/experimental.go similarity index 100% rename from cmd/cli/kubectl-kyverno/utils/experimental/experimental.go rename to cmd/cli/kubectl-kyverno/experimental/experimental.go diff --git a/cmd/cli/kubectl-kyverno/utils/experimental/experimental_test.go b/cmd/cli/kubectl-kyverno/experimental/experimental_test.go similarity index 100% rename from cmd/cli/kubectl-kyverno/utils/experimental/experimental_test.go rename to cmd/cli/kubectl-kyverno/experimental/experimental_test.go diff --git a/cmd/cli/kubectl-kyverno/utils/color/color.go b/cmd/cli/kubectl-kyverno/output/color/color.go similarity index 100% rename from cmd/cli/kubectl-kyverno/utils/color/color.go rename to cmd/cli/kubectl-kyverno/output/color/color.go diff --git a/cmd/cli/kubectl-kyverno/utils/color/color_test.go b/cmd/cli/kubectl-kyverno/output/color/color_test.go similarity index 100% rename from cmd/cli/kubectl-kyverno/utils/color/color_test.go rename to cmd/cli/kubectl-kyverno/output/color/color_test.go diff --git a/cmd/cli/kubectl-kyverno/utils/output/table/printer.go b/cmd/cli/kubectl-kyverno/output/table/printer.go similarity index 75% rename from cmd/cli/kubectl-kyverno/utils/output/table/printer.go rename to cmd/cli/kubectl-kyverno/output/table/printer.go index 5eef4640a7..c36964f638 100644 --- a/cmd/cli/kubectl-kyverno/utils/output/table/printer.go +++ b/cmd/cli/kubectl-kyverno/output/table/printer.go @@ -3,10 +3,14 @@ package table import ( "os" - "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/utils/color" + "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/output/color" "github.com/lensesio/tableprinter" ) +func rowsLength(length int) bool { + return length > 10 +} + func NewTablePrinter() *tableprinter.Printer { printer := tableprinter.New(os.Stdout) printer.BorderTop, printer.BorderBottom, printer.BorderLeft, printer.BorderRight = true, true, true, true @@ -16,8 +20,6 @@ func NewTablePrinter() *tableprinter.Printer { printer.RowCharLimit = 300 printer.HeaderBgColor = color.HeaderBgColor printer.HeaderFgColor = color.HeaderFgColor - printer.RowLengthTitle = func(rowsLength int) bool { - return rowsLength > 10 - } + printer.RowLengthTitle = rowsLength return printer } diff --git a/cmd/cli/kubectl-kyverno/output/table/printer_test.go b/cmd/cli/kubectl-kyverno/output/table/printer_test.go new file mode 100644 index 0000000000..0547640e89 --- /dev/null +++ b/cmd/cli/kubectl-kyverno/output/table/printer_test.go @@ -0,0 +1,42 @@ +package table + +import ( + "testing" +) + +func TestNewTablePrinter(t *testing.T) { + if got := NewTablePrinter(); got == nil { + t.Errorf("NewTablePrinter() return nill") + } +} + +func Test_rowsLength(t *testing.T) { + tests := []struct { + name string + length int + want bool + }{{ + name: "0", + length: 0, + want: false, + }, { + name: "10", + length: 10, + want: false, + }, { + name: "11", + length: 11, + want: true, + }, { + name: "20", + length: 20, + want: true, + }} + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := rowsLength(tt.length); got != tt.want { + t.Errorf("rowsLength() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/cmd/cli/kubectl-kyverno/utils/output/table/table.go b/cmd/cli/kubectl-kyverno/output/table/table.go similarity index 100% rename from cmd/cli/kubectl-kyverno/utils/output/table/table.go rename to cmd/cli/kubectl-kyverno/output/table/table.go diff --git a/cmd/cli/kubectl-kyverno/utils/filter/filter.go b/cmd/cli/kubectl-kyverno/test/filter/filter.go similarity index 96% rename from cmd/cli/kubectl-kyverno/utils/filter/filter.go rename to cmd/cli/kubectl-kyverno/test/filter/filter.go index ddb2bf0eae..6afc8baf42 100644 --- a/cmd/cli/kubectl-kyverno/utils/filter/filter.go +++ b/cmd/cli/kubectl-kyverno/test/filter/filter.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/commands/test/api" + "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/test/api" "github.com/kyverno/kyverno/pkg/utils/wildcard" ) diff --git a/cmd/cli/kubectl-kyverno/utils/filter/filter_test.go b/cmd/cli/kubectl-kyverno/test/filter/filter_test.go similarity index 98% rename from cmd/cli/kubectl-kyverno/utils/filter/filter_test.go rename to cmd/cli/kubectl-kyverno/test/filter/filter_test.go index fe5d57a194..578b5715a7 100644 --- a/cmd/cli/kubectl-kyverno/utils/filter/filter_test.go +++ b/cmd/cli/kubectl-kyverno/test/filter/filter_test.go @@ -5,7 +5,7 @@ import ( "reflect" "testing" - "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/commands/test/api" + "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/test/api" ) func Test_policy_Apply(t *testing.T) { @@ -313,9 +313,7 @@ func TestParseFilter(t *testing.T) { errors.New("Invalid test-case-selector (foo=bar). Parameter can only be policy, rule or resource."), errors.New("Invalid test-case-selector argument (policy). Parameter must be in the form `=`."), }, - }, - // TODO: Add test cases. - } + }} for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { got, got1 := ParseFilter(tt.in) diff --git a/cmd/cli/kubectl-kyverno/test/load.go b/cmd/cli/kubectl-kyverno/test/load.go index b38d0a1431..7a7fa0bbe0 100644 --- a/cmd/cli/kubectl-kyverno/test/load.go +++ b/cmd/cli/kubectl-kyverno/test/load.go @@ -6,7 +6,7 @@ import ( "path/filepath" "github.com/go-git/go-billy/v5" - "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/commands/test/api" + "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/test/api" "k8s.io/apimachinery/pkg/util/yaml" ) diff --git a/cmd/cli/kubectl-kyverno/test/load_test.go b/cmd/cli/kubectl-kyverno/test/load_test.go index e3c33ffc6a..2a90560751 100644 --- a/cmd/cli/kubectl-kyverno/test/load_test.go +++ b/cmd/cli/kubectl-kyverno/test/load_test.go @@ -6,7 +6,7 @@ import ( "testing" policyreportv1alpha2 "github.com/kyverno/kyverno/api/policyreport/v1alpha2" - "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/commands/test/api" + "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/test/api" ) func TestTestCases_Errors(t *testing.T) { @@ -196,9 +196,7 @@ func TestLoadTests(t *testing.T) { }, }}, wantErr: false, - }, - // TODO: Add test cases. - } + }} for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { got, err := LoadTests(tt.dirPath, tt.fileName) diff --git a/cmd/cli/kubectl-kyverno/utils/common/common.go b/cmd/cli/kubectl-kyverno/utils/common/common.go index 050eeb988d..56a1a3b04c 100644 --- a/cmd/cli/kubectl-kyverno/utils/common/common.go +++ b/cmd/cli/kubectl-kyverno/utils/common/common.go @@ -14,9 +14,9 @@ import ( "github.com/go-git/go-billy/v5" kyvernov1 "github.com/kyverno/kyverno/api/kyverno/v1" kyvernov1beta1 "github.com/kyverno/kyverno/api/kyverno/v1beta1" - "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/commands/test/api" "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/policy/annotations" "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/resource" + "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/test/api" sanitizederror "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/utils/sanitizedError" "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/utils/source" "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/utils/store" diff --git a/cmd/cli/kubectl-kyverno/utils/common/common_test.go b/cmd/cli/kubectl-kyverno/utils/common/common_test.go index 9e1654ed2d..0641b18cc6 100644 --- a/cmd/cli/kubectl-kyverno/utils/common/common_test.go +++ b/cmd/cli/kubectl-kyverno/utils/common/common_test.go @@ -4,8 +4,8 @@ import ( "testing" "github.com/kyverno/kyverno/api/kyverno/v1beta1" - "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/commands/test/api" "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/resource" + "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/test/api" yamlutils "github.com/kyverno/kyverno/pkg/utils/yaml" "gotest.tools/assert" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/cmd/cli/kubectl-kyverno/utils/common/fetch.go b/cmd/cli/kubectl-kyverno/utils/common/fetch.go index 6222e57dc6..b11903e103 100644 --- a/cmd/cli/kubectl-kyverno/utils/common/fetch.go +++ b/cmd/cli/kubectl-kyverno/utils/common/fetch.go @@ -9,8 +9,8 @@ import ( "github.com/go-git/go-billy/v5" kyvernov1 "github.com/kyverno/kyverno/api/kyverno/v1" - "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/commands/test/api" "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/resource" + "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/test/api" "github.com/kyverno/kyverno/pkg/autogen" "github.com/kyverno/kyverno/pkg/clients/dclient" kubeutils "github.com/kyverno/kyverno/pkg/utils/kube" diff --git a/cmd/cli/kubectl-kyverno/utils/common/kyverno_resources_types.go b/cmd/cli/kubectl-kyverno/utils/common/kyverno_resources_types.go index 73e8aedea8..d9f3c38535 100644 --- a/cmd/cli/kubectl-kyverno/utils/common/kyverno_resources_types.go +++ b/cmd/cli/kubectl-kyverno/utils/common/kyverno_resources_types.go @@ -2,7 +2,7 @@ package common import ( kyvernov1 "github.com/kyverno/kyverno/api/kyverno/v1" - "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/commands/test/api" + "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/test/api" "github.com/kyverno/kyverno/pkg/autogen" "github.com/kyverno/kyverno/pkg/clients/dclient" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" diff --git a/cmd/cli/kubectl-kyverno/utils/common/validatingadmission_resources_types.go b/cmd/cli/kubectl-kyverno/utils/common/validatingadmission_resources_types.go index 594645943a..888316f2b8 100644 --- a/cmd/cli/kubectl-kyverno/utils/common/validatingadmission_resources_types.go +++ b/cmd/cli/kubectl-kyverno/utils/common/validatingadmission_resources_types.go @@ -1,7 +1,7 @@ package common import ( - "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/commands/test/api" + "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/test/api" "github.com/kyverno/kyverno/pkg/clients/dclient" "k8s.io/api/admissionregistration/v1alpha1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" diff --git a/cmd/cli/kubectl-kyverno/utils/common/variables.go b/cmd/cli/kubectl-kyverno/utils/common/variables.go index b4c1f93af7..2d04237161 100644 --- a/cmd/cli/kubectl-kyverno/utils/common/variables.go +++ b/cmd/cli/kubectl-kyverno/utils/common/variables.go @@ -8,10 +8,10 @@ import ( "github.com/go-git/go-billy/v5" kyvernov1 "github.com/kyverno/kyverno/api/kyverno/v1" - "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/commands/test/api" + "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/test/api" sanitizederror "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/utils/sanitizedError" "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/utils/store" - "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/utils/values" + "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/values" "github.com/kyverno/kyverno/pkg/autogen" "github.com/kyverno/kyverno/pkg/engine/variables/regex" datautils "github.com/kyverno/kyverno/pkg/utils/data" diff --git a/cmd/cli/kubectl-kyverno/utils/values/load.go b/cmd/cli/kubectl-kyverno/values/load.go similarity index 89% rename from cmd/cli/kubectl-kyverno/utils/values/load.go rename to cmd/cli/kubectl-kyverno/values/load.go index a0254a1c5d..9d2174d4a0 100644 --- a/cmd/cli/kubectl-kyverno/utils/values/load.go +++ b/cmd/cli/kubectl-kyverno/values/load.go @@ -5,7 +5,7 @@ import ( "os" "github.com/go-git/go-billy/v5" - "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/commands/test/api" + "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/test/api" "k8s.io/apimachinery/pkg/util/yaml" ) diff --git a/cmd/cli/kubectl-kyverno/utils/values/load_test.go b/cmd/cli/kubectl-kyverno/values/load_test.go similarity index 81% rename from cmd/cli/kubectl-kyverno/utils/values/load_test.go rename to cmd/cli/kubectl-kyverno/values/load_test.go index 3b12dde21b..50fcf9c2b0 100644 --- a/cmd/cli/kubectl-kyverno/utils/values/load_test.go +++ b/cmd/cli/kubectl-kyverno/values/load_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/go-git/go-billy/v5" - "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/commands/test/api" + "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/test/api" ) func Test_readFile(t *testing.T) { @@ -31,18 +31,18 @@ func Test_readFile(t *testing.T) { wantErr: true, }, { name: "does not exist", - filepath: "../../testdata/values/doesnotexist", + filepath: "../testdata/values/doesnotexist", want: nil, wantErr: true, }, { name: "bad format", - filepath: "../../testdata/values/bad-format.yaml", - want: mustReadFile("../../testdata/values/bad-format.yaml"), + filepath: "../testdata/values/bad-format.yaml", + want: mustReadFile("../testdata/values/bad-format.yaml"), wantErr: false, }, { name: "valid", - filepath: "../../testdata/values/valid.yaml", - want: mustReadFile("../../testdata/values/valid.yaml"), + filepath: "../testdata/values/valid.yaml", + want: mustReadFile("../testdata/values/valid.yaml"), wantErr: false, }} for _, tt := range tests { @@ -73,17 +73,17 @@ func TestLoad(t *testing.T) { wantErr: true, }, { name: "does not exist", - filepath: "../../testdata/values/doesnotexist", + filepath: "../testdata/values/doesnotexist", want: nil, wantErr: true, }, { name: "bad format", - filepath: "../../testdata/values/bad-format.yaml", + filepath: "../testdata/values/bad-format.yaml", want: nil, wantErr: true, }, { name: "valid", - filepath: "../../testdata/values/valid.yaml", + filepath: "../testdata/values/valid.yaml", want: &api.Values{ NamespaceSelectors: []api.NamespaceSelector{{ Name: "test1",