Browse Source

Merge "Create Makefile target to install Helm binary"

Zuul 4 months ago
parent
commit
97bcc9760f
3 changed files with 67 additions and 9 deletions
  1. 13
    6
      Makefile
  2. 44
    0
      tools/helm_install.sh
  3. 10
    3
      tools/helm_tk.sh

+ 13
- 6
Makefile View File

@@ -12,12 +12,15 @@
12 12
 # See the License for the specific language governing permissions and
13 13
 # limitations under the License.
14 14
 
15
-HELM := helm
16
-TASK := build
15
+BUILD_DIR       := $(shell mkdir -p build && mktemp -d -p build)
16
+HELM            := $(shell realpath $(BUILD_DIR))/helm
17
+TASK            := build
17 18
 
18
-EXCLUDES := helm-toolkit docs tests tools logs
19
-CHARTS := $(filter-out $(EXCLUDES), $(patsubst %/.,%,$(wildcard */.)))
20
-CHART := divingbell
19
+EXCLUDES        := helm-toolkit docs tests tools logs
20
+CHARTS          := $(filter-out $(EXCLUDES), $(patsubst %/.,%,$(wildcard */.)))
21
+CHART           := divingbell
22
+
23
+export
21 24
 
22 25
 all: $(CHART)
23 26
 
@@ -26,7 +29,7 @@ $(CHART):
26 29
 	@echo "===== Processing [$@] chart ====="
27 30
 	@make $(TASK)-$@
28 31
 
29
-init-%: clean
32
+init-%: clean helm-install
30 33
 	DEP_UP_LIST=$* tools/helm_tk.sh $(HELM)
31 34
 
32 35
 lint-%: init-%
@@ -62,3 +65,7 @@ docs: clean build_docs
62 65
 .PHONY: build_docs
63 66
 build_docs:
64 67
 	tox -e docs
68
+
69
+.PHONY: helm-install
70
+helm-install:
71
+	tools/helm_install.sh $(HELM)

+ 44
- 0
tools/helm_install.sh View File

@@ -0,0 +1,44 @@
1
+#!/bin/bash
2
+# Copyright 2018 AT&T Intellectual Property.  All other rights reserved.
3
+#
4
+# Licensed under the Apache License, Version 2.0 (the "License");
5
+# you may not use this file except in compliance with the License.
6
+# You may obtain a copy of the License at
7
+#
8
+#     http://www.apache.org/licenses/LICENSE-2.0
9
+#
10
+# Unless required by applicable law or agreed to in writing, software
11
+# distributed under the License is distributed on an "AS IS" BASIS,
12
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+# See the License for the specific language governing permissions and
14
+# limitations under the License.
15
+#
16
+
17
+set -x
18
+
19
+HELM=$1
20
+HELM_ARTIFACT_URL=${HELM_ARTIFACT_URL:-"https://storage.googleapis.com/kubernetes-helm/helm-v2.10.0-linux-amd64.tar.gz"}
21
+
22
+
23
+function install_helm_binary {
24
+  if [[ -z "${HELM}" ]]
25
+  then
26
+    echo "No Helm binary target location."
27
+    exit -1
28
+  fi
29
+
30
+  if [[ -w "$(dirname ${HELM})" ]]
31
+  then
32
+    TMP_DIR=${BUILD_DIR:-$(mktemp -d)}
33
+    curl -o "${TMP_DIR}/helm.tar.gz" "${HELM_ARTIFACT_URL}"
34
+    pushd ${TMP_DIR}
35
+    tar -xvzf helm.tar.gz
36
+    cp "linux-amd64/helm" "helm"
37
+    popd
38
+  else
39
+    echo "Cannot write to ${HELM}"
40
+    exit -1
41
+  fi
42
+}
43
+
44
+install_helm_binary

+ 10
- 3
tools/helm_tk.sh View File

@@ -18,6 +18,8 @@
18 18
 HELM=$1
19 19
 HTK_REPO=${HTK_REPO:-"https://github.com/openstack/openstack-helm-infra"}
20 20
 HTK_PATH=${HTK_PATH:-""}
21
+HTK_STABLE_COMMIT=${HTK_COMMIT:-"2fce7e821201a5f578331370703e164d5a932fcc"}
22
+BUILD_DIR=${BUILD_DIR:-$(mktemp -d)}
21 23
 DEP_UP_LIST=${DEP_UP_LIST:-"divingbell"}
22 24
 
23 25
 if [[ ! -z $(echo $http_proxy) ]]
@@ -31,7 +33,7 @@ function helm_serve {
31 33
   if [[ -d "$HOME/.helm" ]]; then
32 34
      echo ".helm directory found"
33 35
   else
34
-     ${HELM} init --client-only
36
+     ${HELM} init --client-only --skip-refresh
35 37
   fi
36 38
   if [[ -z $(curl -s 127.0.0.1:8879 | grep 'Helm Repository') ]]; then
37 39
      ${HELM} serve & > /dev/null
@@ -54,10 +56,15 @@ mkdir -p build
54 56
 pushd build
55 57
 git clone --depth 1 $HTK_REPO || true
56 58
 pushd ${HTK_REPO##*/}/$HTK_PATH
59
+git reset --hard "${HTK_STABLE_COMMIT}"
57 60
 
58
-git pull
59
-make helm-toolkit
60 61
 helm_serve
62
+if [[ ${HELM} != "helm" ]]
63
+then
64
+      export PATH=${PATH}:$(dirname ${HELM})
65
+fi
66
+
67
+make helm-toolkit
61 68
 
62 69
 popd && popd
63 70
 for c in $DEP_UP_LIST

Loading…
Cancel
Save