Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ node_modules

venom.*.log
docs/README.md
orb.yml
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,8 @@ 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
4 changes: 4 additions & 0 deletions docs/contributing/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ 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.
Expand Down
8 changes: 8 additions & 0 deletions docs/orb.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
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.
7 changes: 7 additions & 0 deletions orb/@orb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
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
29 changes: 29 additions & 0 deletions orb/commands/configure_env.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
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=<<parameters.ignore-deprecations>> >> $BASH_ENV
echo PLUTO_IGNORE_REMOVALS=<<parameters.ignore-removals>> >> $BASH_ENV
echo PLUTO_TARGET_VERSIONS=<<parameters.target-versions>> >> $BASH_ENV
16 changes: 16 additions & 0 deletions orb/commands/detect.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
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: <<parameters.file>>
command: <<include(scripts/detect.sh)>>
16 changes: 16 additions & 0 deletions orb/commands/detect_files.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
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: <<parameters.directory>>
command: <<include(scripts/detect_files.sh)>>
16 changes: 16 additions & 0 deletions orb/commands/install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
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: <<parameters.version>>
command: <<include(scripts/install.sh)>>
14 changes: 14 additions & 0 deletions orb/examples/detect.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
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"
14 changes: 14 additions & 0 deletions orb/examples/detect_files.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
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"
6 changes: 6 additions & 0 deletions orb/executors/default.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
parameters:
version:
type: string
default: "stable"
docker:
- image: cimg/base:<<parameters.version>>
53 changes: 53 additions & 0 deletions orb/jobs/detect.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
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: <<parameters.executor>>
steps:
- when:
condition: << parameters.checkout >>
steps:
- checkout
- install:
version: <<parameters.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: <<parameters.file>>
53 changes: 53 additions & 0 deletions orb/jobs/detect_files.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
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: <<parameters.executor>>
steps:
- when:
condition: << parameters.checkout >>
steps:
- checkout
- install:
version: <<parameters.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: <<parameters.directory>>
9 changes: 9 additions & 0 deletions orb/scripts/detect.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -e

if [[ -z "${PLUTO_FILE}" ]]; then
echo "Error: requires a file argument"
exit 1
fi

pluto detect "$PLUTO_FILE"
10 changes: 10 additions & 0 deletions orb/scripts/detect_files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/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"
21 changes: 21 additions & 0 deletions orb/scripts/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/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"
36 changes: 36 additions & 0 deletions release-orb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/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}"