From abaad7ed95c7c1dffff31d3d1450126eb2f724e7 Mon Sep 17 00:00:00 2001 From: Andrew Suderman Date: Tue, 19 May 2020 09:04:00 -0600 Subject: [PATCH] Add namespace to wide output (#76) * add namespace to wide output * update functional tests for namespace output. make tests run on newer versions of kind --- .circleci/config.yml | 4 +--- e2e/tests/00_static_files.yaml | 8 +++---- e2e/tests/01_helm-detect-3.yaml | 14 ++++++++--- .../assets/{helm3chart => chart}/.helmignore | 0 .../assets/{helm3chart => chart}/Chart.yaml | 0 .../{helm3chart => chart}/templates/NOTES.txt | 0 .../templates/_helpers.tpl | 0 .../templates/deployment-deprecated.yaml | 0 .../templates/deployment.yaml | 0 .../assets/{helm3chart => chart}/values.yaml | 0 e2e/tests/assets/helm3/secret.yaml | 23 +++++++++++++++++++ pkg/api/output.go | 12 ++++++++-- pkg/api/output_test.go | 16 +++++++------ pkg/api/versions.go | 4 +++- pkg/finder/finder_test.go | 9 +++++--- pkg/finder/testdata/deployment-apps-v1.yaml | 1 + .../deployment-extensions-v1beta1.json | 3 ++- .../deployment-extensions-v1beta1.yaml | 1 + pkg/helm/helm.go | 11 ++++++--- pkg/helm/helm_test.go | 6 +++-- 20 files changed, 83 insertions(+), 29 deletions(-) rename e2e/tests/assets/{helm3chart => chart}/.helmignore (100%) rename e2e/tests/assets/{helm3chart => chart}/Chart.yaml (100%) rename e2e/tests/assets/{helm3chart => chart}/templates/NOTES.txt (100%) rename e2e/tests/assets/{helm3chart => chart}/templates/_helpers.tpl (100%) rename e2e/tests/assets/{helm3chart => chart}/templates/deployment-deprecated.yaml (100%) rename e2e/tests/assets/{helm3chart => chart}/templates/deployment.yaml (100%) rename e2e/tests/assets/{helm3chart => chart}/values.yaml (100%) create mode 100644 e2e/tests/assets/helm3/secret.yaml diff --git a/.circleci/config.yml b/.circleci/config.yml index 6f45141f..2995cf5e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -66,9 +66,7 @@ workflows: branches: only: /.*/ - rok8s-scripts/kubernetes_e2e_tests: - name: e2e test kube 1.15.7 - kind_node_image: >- - "kindest/node:v1.15.7@sha256:e2df133f80ef633c53c0200114fce2ed5e1f6947477dbc83261a6a921169488d" + name: run functional tests <<: *e2e_config - release: filters: diff --git a/e2e/tests/00_static_files.yaml b/e2e/tests/00_static_files.yaml index 81d329f3..acae4f35 100644 --- a/e2e/tests/00_static_files.yaml +++ b/e2e/tests/00_static_files.yaml @@ -21,7 +21,7 @@ testcases: - name: helm template show all steps: - - script: helm template assets/helm3chart | pluto detect -t v1.16.0 -A - + - script: helm template assets/chart | pluto detect -t v1.16.0 -A - assertions: - result.code ShouldEqual 3 - result.systemout ShouldContainSubstring "NAME KIND VERSION REPLACEMENT REMOVED DEPRECATED" @@ -30,7 +30,7 @@ testcases: - name: helm template steps: - - script: helm template assets/helm3chart | pluto detect - + - script: helm template assets/chart | pluto detect - assertions: - result.systemout ShouldContainSubstring "NAME KIND VERSION REPLACEMENT REMOVED DEPRECATED" - result.systemout ShouldContainSubstring "RELEASE-NAME-helm3chart-v1beta1 Deployment extensions/v1beta1 apps/v1 true true" @@ -77,5 +77,5 @@ testcases: - script: pluto detect-files -d assets/ -owide assertions: - result.code ShouldEqual 3 - - result.systemout ShouldContainSubstring "NAME KIND VERSION REPLACEMENT DEPRECATED DEPRECATED IN REMOVED REMOVED IN" - - result.systemout ShouldContainSubstring "utilities Deployment extensions/v1beta1 apps/v1 true v1.9.0 true v1.16.0" + - result.systemout ShouldContainSubstring "NAME NAMESPACE KIND VERSION REPLACEMENT DEPRECATED DEPRECATED IN REMOVED REMOVED IN" + - result.systemout ShouldContainSubstring "utilities Deployment extensions/v1beta1 apps/v1 true v1.9.0 true v1.16.0" diff --git a/e2e/tests/01_helm-detect-3.yaml b/e2e/tests/01_helm-detect-3.yaml index c84aa02f..e29f4650 100644 --- a/e2e/tests/01_helm-detect-3.yaml +++ b/e2e/tests/01_helm-detect-3.yaml @@ -1,9 +1,9 @@ version: "2" name: "Static Code Files (including helm)" testcases: -- name: install helm chart +- name: install helm3 release secret steps: - - script: helm install test assets/helm3chart + - script: kubectl apply -f assets/helm3 assertions: - result.code ShouldEqual 0 @@ -43,6 +43,14 @@ testcases: - result.systemout ShouldContainSubstring "test/test-helm3chart-v1beta1 Deployment extensions/v1beta1 apps/v1 true true" - result.systemout ShouldContainSubstring "test/test-helm3chart Deployment apps/v1 false false" +- name: helm detect -owide + steps: + - script: pluto detect-helm --helm-version=3 -owide -t v1.16.0 + assertions: + - result.code ShouldEqual 3 + - result.systemout ShouldContainSubstring "NAME NAMESPACE KIND VERSION REPLACEMENT DEPRECATED DEPRECATED IN REMOVED REMOVED IN" + - result.systemout ShouldContainSubstring "test/test-helm3chart-v1beta1 default Deployment extensions/v1beta1 apps/v1 true v1.9.0 true v1.16.0" + - name: cleanup steps: - - script: helm delete test + - script: kubectl delete -f assets/helm3 diff --git a/e2e/tests/assets/helm3chart/.helmignore b/e2e/tests/assets/chart/.helmignore similarity index 100% rename from e2e/tests/assets/helm3chart/.helmignore rename to e2e/tests/assets/chart/.helmignore diff --git a/e2e/tests/assets/helm3chart/Chart.yaml b/e2e/tests/assets/chart/Chart.yaml similarity index 100% rename from e2e/tests/assets/helm3chart/Chart.yaml rename to e2e/tests/assets/chart/Chart.yaml diff --git a/e2e/tests/assets/helm3chart/templates/NOTES.txt b/e2e/tests/assets/chart/templates/NOTES.txt similarity index 100% rename from e2e/tests/assets/helm3chart/templates/NOTES.txt rename to e2e/tests/assets/chart/templates/NOTES.txt diff --git a/e2e/tests/assets/helm3chart/templates/_helpers.tpl b/e2e/tests/assets/chart/templates/_helpers.tpl similarity index 100% rename from e2e/tests/assets/helm3chart/templates/_helpers.tpl rename to e2e/tests/assets/chart/templates/_helpers.tpl diff --git a/e2e/tests/assets/helm3chart/templates/deployment-deprecated.yaml b/e2e/tests/assets/chart/templates/deployment-deprecated.yaml similarity index 100% rename from e2e/tests/assets/helm3chart/templates/deployment-deprecated.yaml rename to e2e/tests/assets/chart/templates/deployment-deprecated.yaml diff --git a/e2e/tests/assets/helm3chart/templates/deployment.yaml b/e2e/tests/assets/chart/templates/deployment.yaml similarity index 100% rename from e2e/tests/assets/helm3chart/templates/deployment.yaml rename to e2e/tests/assets/chart/templates/deployment.yaml diff --git a/e2e/tests/assets/helm3chart/values.yaml b/e2e/tests/assets/chart/values.yaml similarity index 100% rename from e2e/tests/assets/helm3chart/values.yaml rename to e2e/tests/assets/chart/values.yaml diff --git a/e2e/tests/assets/helm3/secret.yaml b/e2e/tests/assets/helm3/secret.yaml new file mode 100644 index 00000000..a973ddeb --- /dev/null +++ b/e2e/tests/assets/helm3/secret.yaml @@ -0,0 +1,23 @@ +{ + "apiVersion": "v1", + "data": { + "release": "SDRzSUFBQUFBQUFDLyt4N1czT3FTcmYyWDdINDNvdHZWeVdaZ0RFeldyVXVoRVRFS0ltb0hQck5XNnZvaGdEYURTdzVLTTZhLzMxWE4zZzJoN24yM0xWdlZxcFNFV2pHcVVjLzR4bHQ1d2NYT2NUak9sem1wUmwzeFlYUlc4eDFmbkJ2NFRMTi9uUzlCTWVsNTNJZFR1UkYvcHB2WFF1M1U0SHZDTTFPNi82bTNlVEZ1L3RyL3E3RDg5d1ZoNTFmZnNYMXNKZXh3ZXdpUmNzd3ljSTQ0anFjR3FXWmczRUR4U1NoZzdnckxzMmNMRSs1RHJkVGNzVkZjZWJSVzhKTlEvR3lSaFo0RFNkSmNJZ2NLcWN4MDRjTldEYVdlUlNGa1U4ZnB4NFZTWnpJVFR1dlVhUGhyWk40bVRWZW5oLysxTHFqeHovKzlmOFhPZlJRaGh1K2x6V1MyRTBiMTljMFNHbmlJSy9oZW05T2pyUEdOVzY4Y2s2UzNORFJ5OGpMdlBRbWpML1JnWDhFSGlaTkZEakw3T3A4UkVqOWlwRDNCNDM0SzllNGpodnpOSTRTSnd2K2VPViszSVNaUjlKLzgvKzVJVjdtdUU3bTNGQ1pQMSs1LzJMV29pQnV2SEpHbUlaWkk4aXlwUFB0bXlCK3YrRnYrQnVoYzgvZjg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mQvWmY1dXcvOTVoLzIvQy9menZBQUFBLy85TmZjQ25mVFFBQUE9PQ==" + }, + "kind": "Secret", + "metadata": { + "creationTimestamp": "2020-05-14T16:13:59Z", + "labels": { + "modifiedAt": "1589472839", + "name": "test", + "owner": "helm", + "status": "deployed", + "version": "1" + }, + "name": "sh.helm.release.v1.test.v1", + "namespace": "default", + "resourceVersion": "2869", + "selfLink": "/api/v1/namespaces/default/secrets/sh.helm.release.v1.test.v1", + "uid": "f8151892-2b13-4a55-929b-d7b138feeef6" + }, + "type": "helm.sh/release.v1" +} diff --git a/pkg/api/output.go b/pkg/api/output.go index 384f8c67..d1950f21 100644 --- a/pkg/api/output.go +++ b/pkg/api/output.go @@ -14,6 +14,7 @@ var padChar = byte(' ') // Output is a thing that has an apiVersion in it type Output struct { Name string `json:"name,omitempty" yaml:"name,omitempty"` + Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"` APIVersion *Version `json:"api,omitempty" yaml:"api,omitempty"` Deprecated bool `json:"deprecated" yaml:"deprecated"` Removed bool `json:"removed" yaml:"removed"` @@ -117,7 +118,7 @@ func (instance *Instance) tabOut() (*tabwriter.Writer, error) { } if instance.OutputFormat == "wide" { - _, _ = fmt.Fprintln(w, "NAME\t KIND\t VERSION\t REPLACEMENT\t DEPRECATED\t DEPRECATED IN\t REMOVED\t REMOVED IN\t") + _, _ = fmt.Fprintln(w, "NAME\t NAMESPACE\t KIND\t VERSION\t REPLACEMENT\t DEPRECATED\t DEPRECATED IN\t REMOVED\t REMOVED IN\t") for _, output := range instance.Outputs { kind := output.APIVersion.Kind @@ -129,7 +130,14 @@ func (instance *Instance) tabOut() (*tabwriter.Writer, error) { deprecatedIn := output.APIVersion.DeprecatedIn removedIn := output.APIVersion.RemovedIn - _, _ = fmt.Fprintf(w, "%s\t %s\t %s\t %s\t %s\t %s\t %s\t %s\t\n", name, kind, version, replacement, deprecated, deprecatedIn, removed, removedIn) + var namespace string + if output.Namespace == "" { + namespace = "" + } else { + namespace = output.Namespace + } + + _, _ = fmt.Fprintf(w, "%s\t %s\t %s\t %s\t %s\t %s\t %s\t %s\t %s\t\n", name, namespace, kind, version, replacement, deprecated, deprecatedIn, removed, removedIn) } } diff --git a/pkg/api/output_test.go b/pkg/api/output_test.go index ae649d80..8eba2b21 100644 --- a/pkg/api/output_test.go +++ b/pkg/api/output_test.go @@ -21,7 +21,8 @@ import ( ) var testOutput1 = &Output{ - Name: "some name one", + Name: "some name one", + Namespace: "pluto-namespace", APIVersion: &Version{ Name: "apps/v1", Kind: "Deployment", @@ -76,9 +77,9 @@ func ExampleInstance_DisplayOutput_showAll_wide() { _ = instance.DisplayOutput() // Output: - // NAME----------- KIND-------- VERSION------------- REPLACEMENT-- DEPRECATED-- DEPRECATED IN-- REMOVED-- REMOVED IN-- - // some name one-- Deployment-- apps/v1------------- ------------- false------- --------------- false---- ------------ - // some name two-- Deployment-- extensions/v1beta1-- apps/v1------ true-------- v1.9.0--------- true----- v1.16.0----- + // NAME----------- NAMESPACE-------- KIND-------- VERSION------------- REPLACEMENT-- DEPRECATED-- DEPRECATED IN-- REMOVED-- REMOVED IN-- + // some name one-- pluto-namespace-- Deployment-- apps/v1------------- ------------- false------- --------------- false---- ------------ + // some name two-- -------- Deployment-- extensions/v1beta1-- apps/v1------ true-------- v1.9.0--------- true----- v1.16.0----- } func ExampleInstance_DisplayOutput_normal() { @@ -111,8 +112,8 @@ func ExampleInstance_DisplayOutput_wide() { _ = instance.DisplayOutput() // Output: - // NAME----------- KIND-------- VERSION------------- REPLACEMENT-- DEPRECATED-- DEPRECATED IN-- REMOVED-- REMOVED IN-- - // some name two-- Deployment-- extensions/v1beta1-- apps/v1------ true-------- v1.9.0--------- true----- v1.16.0----- + // NAME----------- NAMESPACE-- KIND-------- VERSION------------- REPLACEMENT-- DEPRECATED-- DEPRECATED IN-- REMOVED-- REMOVED IN-- + // some name two-- -- Deployment-- extensions/v1beta1-- apps/v1------ true-------- v1.9.0--------- true----- v1.16.0----- } func ExampleInstance_DisplayOutput_showAll_json() { @@ -128,7 +129,7 @@ func ExampleInstance_DisplayOutput_showAll_json() { _ = instance.DisplayOutput() // Output: - // {"items":[{"name":"some name one","api":{"version":"apps/v1","kind":"Deployment","deprecated-in":"","removed-in":"","replacement-api":""},"deprecated":false,"removed":false},{"name":"some name two","api":{"version":"extensions/v1beta1","kind":"Deployment","deprecated-in":"v1.9.0","removed-in":"v1.16.0","replacement-api":"apps/v1"},"deprecated":true,"removed":true}],"show-all":true,"target-version":"v1.16.0"} + // {"items":[{"name":"some name one","namespace":"pluto-namespace","api":{"version":"apps/v1","kind":"Deployment","deprecated-in":"","removed-in":"","replacement-api":""},"deprecated":false,"removed":false},{"name":"some name two","api":{"version":"extensions/v1beta1","kind":"Deployment","deprecated-in":"v1.9.0","removed-in":"v1.16.0","replacement-api":"apps/v1"},"deprecated":true,"removed":true}],"show-all":true,"target-version":"v1.16.0"} } func ExampleInstance_DisplayOutput_showAll_yaml() { @@ -146,6 +147,7 @@ func ExampleInstance_DisplayOutput_showAll_yaml() { // Output: // items: // - name: some name one + // namespace: pluto-namespace // api: // version: apps/v1 // kind: Deployment diff --git a/pkg/api/versions.go b/pkg/api/versions.go index 22e0495c..5fd768a9 100644 --- a/pkg/api/versions.go +++ b/pkg/api/versions.go @@ -34,7 +34,8 @@ type Stub struct { // StubMeta will catch kube resource metadata type StubMeta struct { - Name string `json:"name" yaml:"name"` + Name string `json:"name" yaml:"name"` + Namespace string `json:"namespace" yaml:"namespace"` } // Version is an apiVersion and a flag for deprecation @@ -79,6 +80,7 @@ func IsVersioned(data []byte) ([]*Output, error) { version := checkVersion(stub) if version != nil { output.Name = stub.Metadata.Name + output.Namespace = stub.Metadata.Namespace output.APIVersion = version } else { continue diff --git a/pkg/finder/finder_test.go b/pkg/finder/finder_test.go index e006f480..ac1d6815 100644 --- a/pkg/finder/finder_test.go +++ b/pkg/finder/finder_test.go @@ -26,7 +26,8 @@ var testPath = "testdata" var deploymentAppsV1Yaml = "testdata/deployment-apps-v1.yaml" var deploymentAppsV1YamlFile = []*api.Output{{ - Name: "utilities", + Name: "utilities", + Namespace: "test-namespaces", APIVersion: &api.Version{ Name: "apps/v1", Kind: "Deployment", @@ -36,7 +37,8 @@ var deploymentAppsV1YamlFile = []*api.Output{{ var deploymentExtensionsV1Yaml = "testdata/deployment-extensions-v1beta1.yaml" var deploymentExtensionsV1YamlFile = []*api.Output{{ - Name: "utilities", + Name: "utilities", + Namespace: "yaml-namespace", APIVersion: &api.Version{ Name: "extensions/v1beta1", Kind: "Deployment", @@ -48,7 +50,8 @@ var deploymentExtensionsV1YamlFile = []*api.Output{{ var deploymentExtensionsV1JSON = "testdata/deployment-extensions-v1beta1.json" var deploymentExtensionsV1JSONFile = []*api.Output{{ - Name: "utilities", + Name: "utilities", + Namespace: "json-namespace", APIVersion: &api.Version{ Name: "extensions/v1beta1", Kind: "Deployment", diff --git a/pkg/finder/testdata/deployment-apps-v1.yaml b/pkg/finder/testdata/deployment-apps-v1.yaml index 9f774e9d..cbd8e504 100644 --- a/pkg/finder/testdata/deployment-apps-v1.yaml +++ b/pkg/finder/testdata/deployment-apps-v1.yaml @@ -2,6 +2,7 @@ apiVersion: apps/v1 kind: Deployment metadata: name: utilities + namespace: test-namespaces labels: app: utilities spec: diff --git a/pkg/finder/testdata/deployment-extensions-v1beta1.json b/pkg/finder/testdata/deployment-extensions-v1beta1.json index de6648e1..15f4e2bb 100644 --- a/pkg/finder/testdata/deployment-extensions-v1beta1.json +++ b/pkg/finder/testdata/deployment-extensions-v1beta1.json @@ -5,7 +5,8 @@ "labels": { "app": "utilities" }, - "name": "utilities" + "name": "utilities", + "namespace": "json-namespace" }, "spec": { "replicas": 1, diff --git a/pkg/finder/testdata/deployment-extensions-v1beta1.yaml b/pkg/finder/testdata/deployment-extensions-v1beta1.yaml index 9df38b42..4120075d 100644 --- a/pkg/finder/testdata/deployment-extensions-v1beta1.yaml +++ b/pkg/finder/testdata/deployment-extensions-v1beta1.yaml @@ -2,6 +2,7 @@ apiVersion: extensions/v1beta1 kind: Deployment metadata: name: utilities + namespace: yaml-namespace labels: app: utilities spec: diff --git a/pkg/helm/helm.go b/pkg/helm/helm.go index cd441295..9c44f3b4 100644 --- a/pkg/helm/helm.go +++ b/pkg/helm/helm.go @@ -34,16 +34,20 @@ type Helm struct { Kube *kube } +// Release represents a single helm release type Release struct { - Name string `json:"name"` - Chart *Chart `json:"chart"` - Manifest string `json:"manifest"` + Name string `json:"name"` + Namespace string `json:"namespace"` + Chart *Chart `json:"chart"` + Manifest string `json:"manifest"` } +// Chart represents a single helm chart type Chart struct { Metadata *ChartMeta `json:"metadata"` } +// ChartMeta is the metadata of a Helm chart type ChartMeta struct { Name string `json:"name"` Version string `json:"version"` @@ -142,6 +146,7 @@ func (h *Helm) findVersions() error { } for _, out := range outList { out.Name = release.Name + "/" + out.Name + out.Namespace = release.Namespace } h.Outputs = append(h.Outputs, outList...) diff --git a/pkg/helm/helm_test.go b/pkg/helm/helm_test.go index 0ef5f238..eff1d377 100644 --- a/pkg/helm/helm_test.go +++ b/pkg/helm/helm_test.go @@ -59,7 +59,8 @@ var ( } wantOutput = []*api.Output{ { - Name: "helmtest/helmtest-helmchartest-v1beta1", + Name: "helmtest/helmtest-helmchartest-v1beta1", + Namespace: "default", APIVersion: &api.Version{ Name: "extensions/v1beta1", Kind: "Deployment", @@ -69,7 +70,8 @@ var ( }, }, { - Name: "helmtest/helmtest-helmchartest", + Name: "helmtest/helmtest-helmchartest", + Namespace: "default", APIVersion: &api.Version{ Name: "apps/v1", Kind: "Deployment",