Skip to content

Commit

Permalink
Add kubectl plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Kursell committed Feb 25, 2019
1 parent e8bfa9a commit 9e424a4
Show file tree
Hide file tree
Showing 52 changed files with 7,212 additions and 2 deletions.
20 changes: 18 additions & 2 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,7 @@
[[constraint]]
name = "k8s.io/apiserver"
revision = "kubernetes-1.13.3"

[[constraint]]
name = "k8s.io/cli-runtime"
revision = "kubernetes-1.13.3"
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ build:
GOBUILD_FLAGS="$(GOBUILD_FLAGS)" \
build/go-in-docker.sh build/build.sh

.PHONY: build-plugin
build-plugin:
@$(DEF_VARS) \
GOBUILD_FLAGS="$(GOBUILD_FLAGS)" \
build/go-in-docker.sh build/build-plugin.sh

.PHONY: clean
clean:
rm -rf bin/ .gocache/ .env
Expand Down
73 changes: 73 additions & 0 deletions build/build-plugin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/bin/bash

# Copyright 2018 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -o errexit
set -o nounset
set -o pipefail

declare -a mandatory
mandatory=(
PKG
ARCH
GIT_COMMIT
REPO_INFO
TAG
)

missing=false
for var in "${mandatory[@]}"; do
if [[ -z "${!var:-}" ]]; then
echo "Environment variable $var must be set"
missing=true
fi
done

if [ "$missing" = true ]; then
exit 1
fi

export CGO_ENABLED=0

release=cmd/plugin/release

function build_for_arch(){
os=$1
arch=$2

env GOOS=${os} GOARCH=${arch} go build \
${GOBUILD_FLAGS} \
-ldflags "-s -w \
-X ${PKG}/version.RELEASE=${TAG} \
-X ${PKG}/version.COMMIT=${GIT_COMMIT} \
-X ${PKG}/version.REPO=${REPO_INFO}" \
-o ${release}/kubectl-ingress_nginx ${PKG}/cmd/plugin

tar -C ${release} -zcvf ${release}/kubectl-ingress_nginx-${os}-${arch}.tar.gz kubectl-ingress_nginx
rm ${release}/kubectl-ingress_nginx
hash=`sha256sum ${release}/kubectl-ingress_nginx-${os}-${arch}.tar.gz | awk '{ print $1 }'`
sed -i "s/%%%shasum_${os}_${arch}%%%/${hash}/g" ${release}/ingress-nginx.yaml
}

rm -rf ${release}
mkdir ${release}

cp cmd/plugin/ingress-nginx.yaml.tmpl ${release}/ingress-nginx.yaml

sed -i "s/%%%tag%%%/${TAG}/g" ${release}/ingress-nginx.yaml

build_for_arch darwin amd64
build_for_arch linux amd64
build_for_arch windows amd64
40 changes: 40 additions & 0 deletions cmd/plugin/ingress-nginx.yaml.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
apiVersion: krew.googlecontainertools.github.com/v1alpha2
kind: Plugin
metadata:
name: ingress-nginx
spec:
shortDescription: Interact with ingress-nginx
description: |
The official kubectl plugin for ingress-nginx.
version: %%%tag%%%
platforms:
- uri: https://github.com/kubernetes/ingress-nginx/releases/download/nginx-%%%tag%%%/kubectl-ingress_nginx-darwin-amd64.tar.gz
sha256: %%%shasum_darwin_amd64%%%
files:
- from: "*"
to: "."
bin: "./kubectl-ingress_nginx"
selector:
matchLabels:
os: darwin
arch: amd64
- uri: https://github.com/kubernetes/ingress-nginx/releases/download/nginx-%%%tag%%%/kubectl-ingress_nginx-linux-amd64.tar.gz
sha256: %%%shasum_linux_amd64%%%
files:
- from: "*"
to: "."
bin: "./kubectl-ingress_nginx"
selector:
matchLabels:
os: linux
arch: amd64
- uri: https://github.com/kubernetes/ingress-nginx/releases/download/nginx-%%%tag%%%/kubectl-ingress_nginx-windows-amd64.tar.gz
sha256: %%%shasum_windows_amd64%%%
files:
- from: "*"
to: "."
bin: "./kubectl-ingress_nginx"
selector:
matchLabels:
os: windows
arch: amd64
Loading

0 comments on commit 9e424a4

Please sign in to comment.