Add installation of plugins and publish as tarball 23/1123/2
authorYolanda Robla <yroblamo@redhat.com>
Thu, 4 Jul 2019 14:28:04 +0000 (16:28 +0200)
committerYolanda Robla <yroblamo@redhat.com>
Thu, 4 Jul 2019 14:59:20 +0000 (16:59 +0200)
Include a plugins folder for the SiteConfig kustomize plugin.
Also refactor make build to publish as a tarball, that will
include the plugins and utils folder.

Signed-off-by: Yolanda Robla <yroblamo@redhat.com>
Change-Id: I3fcc3e5acc190ab455c996e4ca2950fabe1bcd43

Makefile
plugins/kustomize/plugin/kni.akraino.org/v1alpha1/siteconfig/SiteConfig [new file with mode: 0755]

index 0178ca8..1e3476d 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -43,8 +43,9 @@ binary:
        @./bin/$(GONAME) binary --bin_path ${BINDIR} --installer_repository ${INSTALLER_GIT_REPO} --installer_tag ${INSTALLER_GIT_TAG}
 
 build:
-       @echo "Building knictl with $(GOPATH) to ./bin"
-       @GOPATH=$(GOPATH) GOBIN=$(GOBIN) go build -o bin/$(GONAME) $(GOFILES)
+       @echo "Building knictl with $(GOPATH) to knictl.tar.gz"
+       @GOPATH=$(GOPATH) GOBIN=$(GOBIN) go build -o $(GONAME) $(GOFILES)
+       tar -czvf knictl.tar.gz $(GONAME) plugins utils
 
 clean:
        @echo "Destroying previous cluster"
diff --git a/plugins/kustomize/plugin/kni.akraino.org/v1alpha1/siteconfig/SiteConfig b/plugins/kustomize/plugin/kni.akraino.org/v1alpha1/siteconfig/SiteConfig
new file mode 100755 (executable)
index 0000000..23e65f0
--- /dev/null
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+# This is a simple kustomize transformer plugin that allows
+# injecting configuration for a site into the blueprint.
+# It's current purpose is to inject the pull secret and ssh public key
+# into the site config such that it doesn't have to be stored in git iwth the
+# blueprint. Instead, it's taken from the WORK_DIR (but could eventually be
+# retrieved from a k8s secret or a vault instead).
+# The same mechanism could be used in the future to template in more site
+# configuration parameters for which a purist "kustomization" is too cumbersome.
+
+# set -x
+set -e
+
+# Skip the config file name argument.
+shift
+
+PULL_SECRET=$(cat ${HOME}/.kni/pull-secret.json)
+SSH_PUB_KEY=$(cat ${HOME}/.kni/id_rsa.pub)
+
+cat - | sed \
+    -e "s|PULL_SECRET|\'${PULL_SECRET}\'|" \
+    -e "s|SSH_PUB_KEY|${SSH_PUB_KEY}|"
\ No newline at end of file