Browse Source

Create Makefile target to install Helm binary

In Makefile there is no target which actually installs
Helm binary.

Change-Id: I74a8099d7ff9592f3a86df060a9a54e2b56f6f33
Signed-off-by: Dimitrios Markou <dm844v@att.com>
changes/00/617000/4
Dimitrios Markou 8 months ago
parent
commit
f884d248d1
3 changed files with 83 additions and 9 deletions
  1. 15
    2
      Makefile
  2. 44
    0
      tools/helm_install.sh
  3. 24
    7
      tools/helm_tk.sh

+ 15
- 2
Makefile View File

@@ -12,11 +12,12 @@
12 12
 # See the License for the specific language governing permissions and
13 13
 # limitations under the License.
14 14
 
15
+BUILD_DIR       := $(shell mkdir -p build && mktemp -d -p build)
15 16
 DOCKER_REGISTRY ?= quay.io
16 17
 IMAGE_NAME      ?= deckhand
17 18
 IMAGE_PREFIX    ?= airshipit
18 19
 IMAGE_TAG       ?= latest
19
-HELM            ?= helm
20
+HELM            := $(shell realpath $(BUILD_DIR))/helm
20 21
 PROXY           ?= http://proxy.foo.com:8000
21 22
 NO_PROXY        ?= localhost,127.0.0.1,.svc.cluster.local
22 23
 USE_PROXY       ?= false
@@ -26,16 +27,28 @@ LABEL           ?= org.airshipit.build=community
26 27
 COMMIT          ?= $(shell git rev-parse HEAD)
27 28
 IMAGE           := ${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${IMAGE_NAME}:${IMAGE_TAG}
28 29
 
30
+export
31
+
29 32
 # Build Deckhand Docker image for this project
30 33
 .PHONY: images
31 34
 images: build_deckhand
32 35
 
33 36
 # Create tgz of the chart
34 37
 .PHONY: charts
35
-charts: clean
38
+charts: helm-init
36 39
 	$(HELM) dep up charts/deckhand
37 40
 	$(HELM) package charts/deckhand
38 41
 
42
+# Initialize local helm config
43
+.PHONY: helm-init
44
+helm-init: helm-install
45
+	tools/helm_tk.sh $(HELM)
46
+
47
+# Install helm binary
48
+.PHONY: helm-install
49
+helm-install:
50
+	tools/helm_install.sh $(HELM)
51
+
39 52
 # Perform linting
40 53
 .PHONY: lint
41 54
 lint: pep8 helm_lint

+ 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

+ 24
- 7
tools/helm_tk.sh View File

@@ -16,6 +16,15 @@
16 16
 # Script to setup helm-toolkit and helm dep up the deckhand chart
17 17
 #
18 18
 HELM=$1
19
+HTK_REPO=${HTK_REPO:-"https://github.com/openstack/openstack-helm-infra"}
20
+HTK_PATH=${HTK_PATH:-""}
21
+HTK_STABLE_COMMIT=${HTK_COMMIT:-"2fce7e821201a5f578331370703e164d5a932fcc"}
22
+BUILD_DIR=${BUILD_DIR:-$(mktemp -d)}
23
+
24
+if [[ ! -z $(echo $http_proxy) ]]
25
+then
26
+  export no_proxy=$no_proxy,127.0.0.1
27
+fi
19 28
 
20 29
 set -x
21 30
 
@@ -23,7 +32,7 @@ function helm_serve {
23 32
   if [[ -d "$HOME/.helm" ]]; then
24 33
      echo ".helm directory found"
25 34
   else
26
-     ${HELM} init --client-only
35
+     ${HELM} init --client-only --skip-refresh
27 36
   fi
28 37
   if [[ -z $(curl -s 127.0.0.1:8879 | grep 'Helm Repository') ]]; then
29 38
      ${HELM} serve & > /dev/null
@@ -42,11 +51,19 @@ function helm_serve {
42 51
   ${HELM} repo add local http://localhost:8879/charts
43 52
 }
44 53
 
45
-mkdir -p build
46
-cd build
47
-git clone --depth 1 https://git.openstack.org/openstack/openstack-helm-infra.git || true
48
-cd openstack-helm-infra
49
-git pull
54
+mkdir -p "$BUILD_DIR"
55
+pushd "$BUILD_DIR"
56
+git clone $HTK_REPO || true
57
+pushd openstack-helm-infra/$HTK_PATH
58
+git reset --hard "${HTK_STABLE_COMMIT}"
59
+
50 60
 helm_serve
61
+# OSH Makefile is bugged, so ensure helm is in the path
62
+if [[ ${HELM} != "helm" ]]
63
+then
64
+  export PATH=${PATH}:$(dirname ${HELM})
65
+fi
66
+
51 67
 make helm-toolkit
52
-${HELM} dep up ../../charts/deckhand
68
+popd && popd
69
+${HELM} dep up charts/deckhand

Loading…
Cancel
Save