From 8e92389ca4da5c9b0bffdf23535ab96baca5f478 Mon Sep 17 00:00:00 2001 From: Adrian Ludwin Date: Thu, 10 Sep 2020 14:30:58 -0400 Subject: [PATCH] Build Krew archive Unlike in 0.6+, this change doesn't attempt to build the manifest as a part of Cloud Build. That can be done by hand after the release; too much has changed in the makefiles between the two versions. So this just focuses on creating the archive. Tested: this is virtually impossible to test given the state of the build process in v0.5 (it's much better in v0.6). I'll revert the changes to cloudbuild.yaml if I can't build a release candidate, and the changes to the hack/krew*.yaml files don't matter to anyone. --- incubator/hnc/cloudbuild.yaml | 17 ++++++++ .../hack/krew-hierarchical-namespaces.yaml | 23 ----------- incubator/hnc/hack/krew-kubectl-hns.yaml | 39 +++++++++++++++++++ 3 files changed, 56 insertions(+), 23 deletions(-) delete mode 100644 incubator/hnc/hack/krew-hierarchical-namespaces.yaml create mode 100644 incubator/hnc/hack/krew-kubectl-hns.yaml diff --git a/incubator/hnc/cloudbuild.yaml b/incubator/hnc/cloudbuild.yaml index 013c59303..0635d55ef 100644 --- a/incubator/hnc/cloudbuild.yaml +++ b/incubator/hnc/cloudbuild.yaml @@ -32,6 +32,11 @@ steps: # Build plugin GOOS=linux GOARCH=amd64 go build -o kubectl-hns_linux_amd64 ../cmd/kubectl/main.go GOOS=darwin GOARCH=amd64 go build -o kubectl-hns_darwin_amd64 ../cmd/kubectl/main.go + mkdir kubectl + cp kubectl-hns_linux_amd64 kubectl/ + cp kubectl-hns_darwin_amd64 kubectl/ + cp ../LICENSE kubectl/ + tar czvf kubectl-hns.tar.gz kubectl/ # Upload manifest - name: gcr.io/cloud-builders/curl args: @@ -68,6 +73,18 @@ steps: - '-u' - '$_HNC_USER:$_HNC_PERSONAL_ACCESS_TOKEN' - 'https://uploads.github.com/repos/kubernetes-sigs/multi-tenancy/releases/$_HNC_RELEASE_ID/assets?name=kubectl-hns_darwin_amd64' +# Upload plugin (Krew tar file) +- name: gcr.io/cloud-builders/curl + args: + - '-X' + - 'POST' + - '-H' + - 'Content-Type: application/x-application' + - '--data-binary' + - '@multi-tenancy/incubator/hnc/out/kubectl-hns.tar.gz' + - '-u' + - '$_HNC_USER:$_HNC_PERSONAL_ACCESS_TOKEN' + - 'https://uploads.github.com/repos/kubernetes-sigs/multi-tenancy/releases/$_HNC_RELEASE_ID/assets?name=kubectl-hns.tar.gz' # Build Docker image - name: gcr.io/cloud-builders/docker args: ['build', '-t', 'gcr.io/$PROJECT_ID/hnc/controller:$_HNC_IMG_TAG', 'multi-tenancy/incubator/hnc'] diff --git a/incubator/hnc/hack/krew-hierarchical-namespaces.yaml b/incubator/hnc/hack/krew-hierarchical-namespaces.yaml deleted file mode 100644 index 45e928cdc..000000000 --- a/incubator/hnc/hack/krew-hierarchical-namespaces.yaml +++ /dev/null @@ -1,23 +0,0 @@ -# For PoC purpose only. -# Will be moved to https://github.com/kubernetes-sigs/krew-index after hnc has it's release. -apiVersion: krew.googlecontainertools.github.com/v1alpha2 -kind: Plugin -metadata: - name: hierarchical-namespaces -spec: - shortDescription: Manipulates hierarchical namespaces. - description: | - Manipulates hierarchical namespaces provided by the Hierarchical Namespace Controller (HNC). - version: --- will be populated by make krew-build --- - homepage: https://github.com/kubernetes-sigs/multi-tenancy/incubator/hnc - platforms: - - uri: https://github.com/example/foo/releases/v1.0.tar.gz - selector: - matchLabels: - os: linux - arch: amd64 - sha256: --- will be populated by make krew-build --- - files: - - from: "bin/kubectl/kubectl-hns" - to: "." - bin: "./kubectl-hns" diff --git a/incubator/hnc/hack/krew-kubectl-hns.yaml b/incubator/hnc/hack/krew-kubectl-hns.yaml new file mode 100644 index 000000000..772eb274b --- /dev/null +++ b/incubator/hnc/hack/krew-kubectl-hns.yaml @@ -0,0 +1,39 @@ +### WARNING ### +# In v0.5, we don't have any automation to fill in the variables shown below +# (HNC_RELEASE_REPO_OWNER, HNC_IMG_TAG, HNC_KreW_TAR_SHA256). You must fill +# these in by hand. This is all automated in v0.6+. +apiVersion: krew.googlecontainertools.github.com/v1alpha2 +kind: Plugin +metadata: + name: hns +spec: + shortDescription: Manage hierarchical namespaces (part of HNC) + description: | + Manipulates hierarchical namespaces provided by the Hierarchical Namespace Controller (HNC). + version: HNC_IMG_TAG + homepage: https://github.com/HNC_RELEASE_REPO_OWNER/multi-tenancy/tree/master/incubator/hnc/docs/user-guide + platforms: + - uri: https://github.com/HNC_RELEASE_REPO_OWNER/multi-tenancy/releases/download/hnc-HNC_IMG_TAG/kubectl-hns.tar.gz + selector: + matchLabels: + os: linux + arch: amd64 + sha256: HNC_KREW_TAR_SHA256 + files: + - from: "bin/kubectl/kubectl-hns_linux_amd64" + to: "." + - from: "bin/kubectl/LICENSE" + to: "." + bin: "./kubectl-hns_linux_amd64" + - uri: https://github.com/HNC_RELEASE_REPO_OWNER/multi-tenancy/releases/download/hnc-HNC_IMG_TAG/kubectl-hns.tar.gz + selector: + matchLabels: + os: darwin + arch: amd64 + sha256: HNC_KREW_TAR_SHA256 + files: + - from: "bin/kubectl/kubectl-hns_darwin_amd64" + to: "." + - from: "bin/kubectl/LICENSE" + to: "." + bin: "./kubectl-hns_darwin_amd64"