Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add script for generating a krew plugin manifest. #645

Merged
merged 6 commits into from
Jul 31, 2019
Merged
Changes from 4 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
57 changes: 57 additions & 0 deletions hack/generate_krew.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash

# This script generates a Krew-compatible plugin manifest. It should be run after goreleaser.

VERSION=${VERSION:-$(git describe --tags |sed 's/^v//g')}

# Generate the manifest for a single platform.
function generate_platform {
ARCH="${2}"
if [ "${2}" == "amd64" ]; then
ARCH=x86_64
elif [ "${2}" == "386" ]; then
ARCH=i386
fi

cat <<EOF
- selector:
matchLabels:
os: "${1}"
arch: "${2}"
uri: https://github.com/kudobuilder/kudo/releases/download/v${VERSION}/kudo_${VERSION}_${1}_${ARCH}.tar.gz
sha256: "$(curl -L https://github.com/kudobuilder/kudo/releases/download/v${VERSION}/kudo_${VERSION}_${1}_${ARCH}.tar.gz |sha256sum - |awk '{print $1}')"
bin: "./kubectl-kudo"
files:
- from: "*"
to: "."
EOF
}

rm -f kudo.yaml

cat <<EOF >> kudo.yaml
apiVersion: krew.googlecontainertools.github.com/v1alpha2
kind: Plugin
metadata:
name: kudo
spec:
version: "${VERSION}"

shortDescription: KUDO CLI
homepage: https://kudo.dev/
description: |
The Kubernetes Universal Declarative Operator (KUDO) is a highly productive toolkit for writing operators for Kubernetes.
Using KUDO, you can deploy your applications, give your users the tools they need to operate it, and understand how it's
behaving in their environments — all without a PhD in Kubernetes.

platforms:
EOF

generate_platform linux amd64 >> kudo.yaml
generate_platform linux 386 >> kudo.yaml
generate_platform darwin amd64 >> kudo.yaml
generate_platform darwin 386 >> kudo.yaml
generate_platform windows amd64 >> kudo.yaml
generate_platform windows 386 >> kudo.yaml

echo "To publish to the krew index, create a pull request to https://github.com/kubernetes-sigs/krew-index/tree/master/plugins to update kudo.yaml with the newly generated kudo.yaml."