Skip to content

Commit

Permalink
Krew automation (#18)
Browse files Browse the repository at this point in the history
* Added automation to update krew-index
  • Loading branch information
jasonrichardsmith committed Nov 2, 2018
1 parent c82c807 commit cebddc7
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Expand Up @@ -3,9 +3,9 @@ go: 1.9
services:
- docker

script:
script:
- make builddocker
- if [ -n "$TRAVIS_TAG" ]; then TAG=$TRAVIS_TAG make releases; fi
- if [ -n "$TRAVIS_TAG" ]; then TAG=$TRAVIS_TAG make full-release; fi

deploy:
- provider: releases
Expand Down
29 changes: 29 additions & 0 deletions Makefile
@@ -1,5 +1,6 @@
DOMAIN="jasonrichardsmith"
APP="rbac-view"
HUB="hub-linux-amd64-2.6.0"
USERID=$(shell id -u)
GROUPID=$(shell id -g)

Expand Down Expand Up @@ -59,3 +60,31 @@ releases:
tar -czvf rbac-view.$(TAG).linux.tar.gz bin/linux/rbac-view
tar -czvf rbac-view.$(TAG).windows.tar.gz bin/windows/rbac-view
tar -czvf rbac-view.$(TAG).darwin.tar.gz bin/darwin/rbac-view

.PHONY: krew-index
krew-index:
curl -O -L https://github.com/github/hub/releases/download/v2.6.0/$(HUB).tgz
tar -xzvf $(HUB).tgz
git clone https://github.com/jasonrichardsmith/krew-index.git
$(eval CURRENT_DIR=$(shell pwd))
$(eval export TAG)
$(eval export WINDOWS_SHA=$(shell sha256sum bin/windows/rbac-view | awk '{ print $$1 }' ))
$(eval export LINUX_SHA=$(shell sha256sum bin/linux/rbac-view | awk '{ print $$1 }' ))
$(eval export DARWIN_SHA=$(shell sha256sum bin/darwin/rbac-view | awk '{ print $$1 }' ))
envsubst < rbac-view.krew.template.yaml > krew-index/plugins/rbac-view.yaml
cd krew-index && \
git checkout -b $(TAG) && \
cat plugins/rbac-view.yaml && \
git add plugins/rbac-view.yaml && \
git commit -m 'Release $(TAG)' && \
git remote add krew-index \
https://$(GITHUB_TOKEN)@github.com/jasonrichardsmith/krew-index.git > /dev/null 2>&1 && \
git push --quiet --set-upstream krew-index $(TAG) --force

$(CURRENT_DIR)/$(HUB)/bin/hub pull-request \
--base="GoogleContainerTools:master" \
--head="jasonrichardsmith/krew-index:${TAG}" \
--message="Update rbac-view ${TAG}"

.PHONY: full-release
full-release: | releases krew-index
55 changes: 55 additions & 0 deletions rbac-view.krew.template.yaml
@@ -0,0 +1,55 @@
# Copyright © 2018 Google Inc.
#
# 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.

apiVersion: krew.googlecontainertools.github.com/v1alpha2
kind: Plugin
metadata:
name: rbac-view
spec:
version: "${TAG}"
shortDescription: A tool to visualize your RBAC permissions.
caveats: |
Run "kubectl rbac-view" to open a browser with an html view of your permissions.
You can find documentation at https://github.com/jasonrichardsmith/rbac-view.
platforms:
- uri: https://github.com/jasonrichardsmith/rbac-view/releases/download/${TRAVIS_TAG}/rbac-view.${TRAVIS_TAG}.darwin.tar.gz
sha256: ${DARWIN_SHA}
bin: rbac-view
files:
- from: bin/darwin/rbac-view
to: rbac-view
selector:
matchLabels:
os: darwin
arch: amd64
- uri: https://github.com/jasonrichardsmith/rbac-view/releases/download/${TRAVIS_TAG}/rbac-view.${TRAVIS_TAG}.linux.tar.gz
sha256: ${LINUX_SHA}
bin: rbac-view
files:
- from: bin/linux/rbac-view
to: rbac-view
selector:
matchLabels:
os: linux
arch: amd64
- uri: https://github.com/jasonrichardsmith/rbac-view/releases/download/${TRAVIS_TAG}/rbac-view.${TRAVIS_TAG}.windows.tar.gz
sha256: ${WINDOWS_SHA}
bin: rbac-view
files:
- from: bin/windows/rbac-view
to: rbac-view
selector:
matchLabels:
os: windows
arch: amd64

0 comments on commit cebddc7

Please sign in to comment.