diff --git a/.gitignore b/.gitignore index acaf9fd0..a7376d1f 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,5 @@ pkged.go node_modules /dist -orb.yml venom.*.log docs/README.md diff --git a/Makefile b/Makefile index 212edcde..3f6e4ba8 100644 --- a/Makefile +++ b/Makefile @@ -32,8 +32,5 @@ build-windows: CGO_ENABLED=0 GOOS=windows GOARCH=amd64 $(GOBUILD) -o $(BINARY_NAME) -ldflags "-X main.version=$(VERSION) -X main.commit=$(COMMIT) -s -w" -v ./cmd/pluto/main.go build-docker: build-linux docker build --build-arg version=$(VERSION) --build-arg commit=$(COMMIT) -t us-docker.pkg.dev/fairwinds-ops/oss/pluto/$(BINARY_NAME):dev . -orb-validate: - circleci orb pack orb/ > orb.yml - circleci orb validate orb.yml circleci-validate: circleci config validate --org-slug github/FairwindsOps diff --git a/cmd/root.go b/cmd/root.go index 5641dbe2..0dc509aa 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -332,7 +332,6 @@ var detectHelmCmd = &cobra.Command{ } exitCode = apiInstance.GetReturnCode() klog.V(5).Infof("exitCode: %d", exitCode) - return }, } @@ -353,7 +352,6 @@ var detectApiResourceCmd = &cobra.Command{ } exitCode = apiInstance.GetReturnCode() klog.V(5).Infof("exitCode: %d", exitCode) - return }, } @@ -476,7 +474,7 @@ func detectHelm() error { } err = h.FindVersions() if err != nil { - return fmt.Errorf("Error running helm-detect: %v", err) + return fmt.Errorf("error running helm-detect: %v", err) } return nil } @@ -484,11 +482,11 @@ func detectHelm() error { func detectAPIResources() error { disCl, err := discoveryapi.NewDiscoveryClient(namespace, kubeContext, apiInstance, kubeConfigPath) if err != nil { - return fmt.Errorf("Error creating Discovery REST Client: %v", err) + return fmt.Errorf("error creating Discovery REST Client: %v", err) } err = disCl.GetApiResources() if err != nil { - return fmt.Errorf("Error getting API resources using discovery client: %v", err) + return fmt.Errorf("error getting API resources using discovery client: %v", err) } return nil } diff --git a/docs/contributing/guide.md b/docs/contributing/guide.md index d01f4b0c..6de5eebe 100644 --- a/docs/contributing/guide.md +++ b/docs/contributing/guide.md @@ -90,10 +90,6 @@ Each new pull request should: - Contain a clear indication of if they're ready for review or a work in progress - Be up to date and/or rebased on the master branch -## Orb development - -There is a Makefile that can assist in validating and testing the orb locally. See the commands there for more info. - ## Creating a new release Push a new tag and Goreleaser will take care of the rest. diff --git a/docs/orb.md b/docs/orb.md deleted file mode 100644 index 00d2d42e..00000000 --- a/docs/orb.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -meta: - - name: description - content: "Fairwinds Pluto | Fairwinds publishes an orb called fairwinds/pluto to provide easier configuration inside of CircleCI." ---- -# Orb - -CircleCI has introduced the concept of reusable config in the form of [Orbs](https://circleci.com/orbs/). As of pluto v5.1, Fairwinds publishes an orb called [`fairwinds/pluto`](https://circleci.com/orbs/registry/orb/fairwinds/pluto) in order to provide easier configuration inside of CircleCI. diff --git a/orb/@orb.yml b/orb/@orb.yml deleted file mode 100644 index 35496be6..00000000 --- a/orb/@orb.yml +++ /dev/null @@ -1,7 +0,0 @@ -version: 2.1 - -description: | - Pluto is a utility to help users find deprecated Kubernetes apiVersions in their code repositories and their helm releases. -display: - home_url: https://pluto.docs.fairwinds.com - source_url: https://github.com/FairwindsOps/pluto diff --git a/orb/commands/configure_env.yml b/orb/commands/configure_env.yml deleted file mode 100644 index df121e5f..00000000 --- a/orb/commands/configure_env.yml +++ /dev/null @@ -1,29 +0,0 @@ -description: Configures pluto environment variables. -parameters: - executor: - description: The name of custom executor to use. Only recommended for development. - type: executor - default: default - ignore-deprecations: - type: boolean - default: false - description: Exit Code 3 is ignored, useful if you do not want the job to fail if deprecated APIs are detected. - ignore-removals: - type: boolean - default: false - description: Exit Code 3 is ignored, useful if you do not want the job to fail if removed APIs are detected. - target-versions: - description: You can target the Kubernetes version you are concerned with. If blank defaults to latest. - type: string - default: "" -steps: - - run: - name: configure Pluto env vars - command: | - #!/bin/bash - - set -e - - echo PLUTO_IGNORE_DEPRECATIONS=<> >> $BASH_ENV - echo PLUTO_IGNORE_REMOVALS=<> >> $BASH_ENV - echo PLUTO_TARGET_VERSIONS=<> >> $BASH_ENV diff --git a/orb/commands/detect.yml b/orb/commands/detect.yml deleted file mode 100644 index 95b9a245..00000000 --- a/orb/commands/detect.yml +++ /dev/null @@ -1,16 +0,0 @@ -description: Detecting deprecated Kubernetes apiVersions within your repository. -parameters: - file: - description: The file to scan. - type: string - default: "" - executor: - description: The name of custom executor to use. Only recommended for development. - type: executor - default: default -steps: - - run: - name: Pluto detect - environment: - PLUTO_FILE: <> - command: <> diff --git a/orb/commands/detect_files.yml b/orb/commands/detect_files.yml deleted file mode 100644 index 55f189e3..00000000 --- a/orb/commands/detect_files.yml +++ /dev/null @@ -1,16 +0,0 @@ -description: Detecting deprecated Kubernetes apiVersions within your repository. -parameters: - directory: - description: The directory to scan. If blank defaults to current directory. - type: string - default: "" - executor: - description: The name of custom executor to use. Only recommended for development. - type: executor - default: default -steps: - - run: - name: Pluto detect-files - environment: - PLUTO_DIRECTORY: <> - command: <> diff --git a/orb/commands/install.yml b/orb/commands/install.yml deleted file mode 100644 index 7d8daff3..00000000 --- a/orb/commands/install.yml +++ /dev/null @@ -1,16 +0,0 @@ -description: Installs the pluto command. -parameters: - executor: - description: The name of custom executor to use. Only recommended for development. - type: executor - default: default - version: - description: The version of pluto to install. Defaults to latest stable. - type: string - default: "" -steps: - - run: - name: Install Pluto - environment: - VERSION: <> - command: <> diff --git a/orb/examples/detect.yml b/orb/examples/detect.yml deleted file mode 100644 index 5f0e39b7..00000000 --- a/orb/examples/detect.yml +++ /dev/null @@ -1,14 +0,0 @@ -description: | - A workflow for detecting deprecated Kubernetes apiVersions for a specific file. -usage: - version: 2.1 - orbs: - pluto: fairwinds/pluto@5 - workflows: - detect_files: - jobs: - - pluto/detect_files: - file: ./K8s/Descriptors/ingress.yml - ignore-deprecations: true - ignore-removals: false - target-versions: "k8s=v1.21" diff --git a/orb/examples/detect_files.yml b/orb/examples/detect_files.yml deleted file mode 100644 index 29974b52..00000000 --- a/orb/examples/detect_files.yml +++ /dev/null @@ -1,14 +0,0 @@ -description: | - A workflow for detecting deprecated Kubernetes apiVersions within your repository. -usage: - version: 2.1 - orbs: - pluto: fairwinds/pluto@5 - workflows: - detect_files: - jobs: - - pluto/detect_files: - directory: ./K8s/Descriptors - ignore-deprecations: true - ignore-removals: false - target-versions: "k8s=v1.21" diff --git a/orb/executors/default.yml b/orb/executors/default.yml deleted file mode 100644 index ec7317df..00000000 --- a/orb/executors/default.yml +++ /dev/null @@ -1,6 +0,0 @@ -parameters: - version: - type: string - default: "stable" -docker: - - image: cimg/base:<> diff --git a/orb/jobs/detect.yml b/orb/jobs/detect.yml deleted file mode 100644 index 5c112c94..00000000 --- a/orb/jobs/detect.yml +++ /dev/null @@ -1,53 +0,0 @@ -description: > - A workflow for detecting deprecated Kubernetes apiVersions within your repository. -parameters: - checkout: - type: boolean - default: true - description: "Perform checkout as first step in job." - executor: - description: The name of custom executor to use. Only recommended for development. - type: executor - default: default - file: - description: The file to scan. Required. - type: string - default: "" - use-external-context: - type: boolean - default: false - description: If this is true, then the configure_env step will be skipped. - ignore-deprecations: - type: boolean - default: false - description: Exit Code 3 is ignored, useful if you do not want the job to fail if deprecated APIs are detected. - ignore-removals: - type: boolean - default: false - description: Exit Code 3 is ignored, useful if you do not want the job to fail if removed APIs are detected. - target-versions: - description: You can target the Kubernetes version you are concerned with. If blank defaults to latest. - type: string - default: "" - version: - description: Version of Pluto to use. Defaults to latest stable. - type: string - default: "" -executor: <> -steps: - - when: - condition: << parameters.checkout >> - steps: - - checkout - - install: - version: <> - - when: - condition: - not: << parameters.use-external-context >> - steps: - - configure_env: - ignore-deprecations: << parameters.ignore-deprecations >> - ignore-removals: << parameters.ignore-removals >> - target-versions: << parameters.target-versions >> - - detect: - file: <> diff --git a/orb/jobs/detect_files.yml b/orb/jobs/detect_files.yml deleted file mode 100644 index 1f851f85..00000000 --- a/orb/jobs/detect_files.yml +++ /dev/null @@ -1,53 +0,0 @@ -description: > - A workflow for detecting deprecated Kubernetes apiVersions within your repository. -parameters: - checkout: - type: boolean - default: true - description: "Perform checkout as first step in job." - directory: - description: The directory to scan. If blank defaults to current directory. - type: string - default: "" - executor: - description: The name of custom executor to use. Only recommended for development. - type: executor - default: default - use-external-context: - type: boolean - default: false - description: If this is true, then the configure_env step will be skipped. - ignore-deprecations: - type: boolean - default: false - description: Exit Code 3 is ignored, useful if you do not want the job to fail if deprecated APIs are detected. - ignore-removals: - type: boolean - default: false - description: Exit Code 3 is ignored, useful if you do not want the job to fail if removed APIs are detected. - target-versions: - description: You can target the Kubernetes version you are concerned with. If blank defaults to latest. - type: string - default: "" - version: - description: Version of Pluto to use. Defaults to latest stable. - type: string - default: "" -executor: <> -steps: - - when: - condition: << parameters.checkout >> - steps: - - checkout - - install: - version: <> - - when: - condition: - not: << parameters.use-external-context >> - steps: - - configure_env: - ignore-deprecations: << parameters.ignore-deprecations >> - ignore-removals: << parameters.ignore-removals >> - target-versions: << parameters.target-versions >> - - detect_files: - directory: <> diff --git a/orb/scripts/detect.sh b/orb/scripts/detect.sh deleted file mode 100644 index 8d77bc0a..00000000 --- a/orb/scripts/detect.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -set -e - -if [[ -z "${PLUTO_FILE}" ]]; then - echo "Error: requires a file argument" - exit 1 -fi - -pluto detect "$PLUTO_FILE" diff --git a/orb/scripts/detect_files.sh b/orb/scripts/detect_files.sh deleted file mode 100755 index 8a95d7ae..00000000 --- a/orb/scripts/detect_files.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -set -e - -if [[ -n "${PLUTO_DIRECTORY}" ]]; then - PLUTO_ARGS="$PLUTO_ARGS --directory ${PLUTO_DIRECTORY}" -fi - -export PLUTO_ARGS - -pluto detect-files "$PLUTO_ARGS" diff --git a/orb/scripts/install.sh b/orb/scripts/install.sh deleted file mode 100755 index 6608e7fe..00000000 --- a/orb/scripts/install.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -if [[ -z "${VERSION}" ]]; then - VERSION=latest -fi - -curl -s https://api.github.com/repos/FairwindsOps/pluto/releases/${VERSION} \ -| grep "browser_download_url.*linux_amd64.tar.gz" \ -| cut -d '"' -f 4 \ -| wget -qi - - -tarball="$(find . -name "*linux_amd64.tar.gz")" -tar -xzf $tarball - -sudo mv pluto /bin - -location="$(which pluto)" -echo "Pluto binary location: $location" - -version="$(pluto version)" -echo "Pluto binary version: $version" diff --git a/pkg/api/output.go b/pkg/api/output.go index 49adfb5f..43e50644 100644 --- a/pkg/api/output.go +++ b/pkg/api/output.go @@ -123,7 +123,10 @@ func (instance *Instance) DisplayOutput() error { } t := instance.markdownOut(c) if t != nil { - t.Render() + err = t.Render() + if err != nil { + return err + } } case "csv": var c columnList @@ -256,7 +259,7 @@ func (instance *Instance) markdownOut(columns columnList) *tablewriter.Table { for _, k := range columnIndexes { row = append(row, columns[k].value(o)) } - table.Append(row) + _ = table.Append(row) } return table diff --git a/pkg/api/versions.go b/pkg/api/versions.go index 3d121422..0c1be79b 100644 --- a/pkg/api/versions.go +++ b/pkg/api/versions.go @@ -297,7 +297,7 @@ func (instance *Instance) PrintVersionList(outputFormat string) error { fmt.Println(string(data)) default: fmt.Println("The output format must be one of (normal|wide|json|yaml)") - return fmt.Errorf("The output format must be one of (normal|wide|json|yaml)") + return fmt.Errorf("the output format must be one of (normal|wide|json|yaml)") } return nil } @@ -307,7 +307,7 @@ func (instance *Instance) printVersionsTabular() error { w.Init(os.Stdout, 0, 15, 2, padChar, 0) if !instance.NoHeaders { - fmt.Fprintln(w, "KIND\t NAME\t DEPRECATED IN\t REMOVED IN\t REPLACEMENT\t REPL AVAIL IN\t COMPONENT\t") + _, _ = fmt.Fprintln(w, "KIND\t NAME\t DEPRECATED IN\t REMOVED IN\t REPLACEMENT\t REPL AVAIL IN\t COMPONENT\t") } for _, version := range instance.DeprecatedVersions { diff --git a/pkg/kube/kube_test.go b/pkg/kube/kube_test.go index 9cbb42f9..588b4a4c 100644 --- a/pkg/kube/kube_test.go +++ b/pkg/kube/kube_test.go @@ -15,7 +15,6 @@ package kube import ( - "os" "testing" "github.com/stretchr/testify/assert" @@ -75,7 +74,7 @@ func Test_getKubeClient(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - os.Setenv("KUBECONFIG", tt.kubeConfig) + t.Setenv("KUBECONFIG", tt.kubeConfig) _, err := GetConfig(tt.kubeContext, tt.kubeConfigPath) if tt.wantErr { assert.Error(t, err) diff --git a/release-orb.sh b/release-orb.sh deleted file mode 100755 index 16309e51..00000000 --- a/release-orb.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash - -function version_gt() { - test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1"; -} - -echo "Starting release." - -command -v circleci >/dev/null 2>&1 || { echo >&2 "I require circleci but it's not installed. Aborting."; exit 1; } -echo "Found circleci command." - -cli_version=$(circleci version | cut -d+ -f1) -required_version=0.1.5705 - -if version_gt "$required_version" "$cli_version"; then - echo "This script requires circleci version greater than or equal to 0.1.5705!" - exit 1 -fi - -commit=$(git log -n1 --pretty='%h') -tag=$(git describe --exact-match --tags "$commit") - -retVal=$? -echo "retVal = $retVal" -if [ $retVal -ne 0 ]; then - echo "You need to checkout a valid tag for this to work." - exit $retVal -fi - -echo "Release: $commit - $tag" - -echo "Validating..." -make orb-validate || { echo 'Orb failed to validate.' ; exit 1; } - -echo "Releasing..." -circleci orb publish orb.yml "fairwinds/pluto@${tag:1}"