From b6212a3f1bcadbae181e1a041aa26e90792be069 Mon Sep 17 00:00:00 2001 From: Bryan Strassner Date: Thu, 26 Oct 2017 15:05:36 -0500 Subject: [PATCH] Update makefile with additional functionality Adds linting and build of charts Change-Id: I8ccb9978e419a84ed73081f8e27b31c9dbf9982c --- .gitignore | 6 +++++- Makefile | 35 ++++++++++++++++++++++++++++++++ tools/helm_tk.sh | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+), 1 deletion(-) create mode 100755 tools/helm_tk.sh diff --git a/.gitignore b/.gitignore index 43801525..205f439a 100644 --- a/.gitignore +++ b/.gitignore @@ -102,4 +102,8 @@ ENV/ .mypy_cache/ # Generated bogus docs -ChangeLog \ No newline at end of file +ChangeLog + +# build/lint artifacts +/charts/shipyard/charts +/charts/shipyard/requirements.lock \ No newline at end of file diff --git a/Makefile b/Makefile index f97b8622..067da223 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,28 @@ AIRFLOW_IMAGE_NAME ?= airflow IMAGE_PREFIX ?= attcomdev IMAGE_TAG ?= latest SHIPYARD_IMAGE_NAME ?= shipyard +HELM ?= helm + +# Build all docker images for this project +.PHONY: images +images: build_airflow build_shipyard + +# Create tgz of the chart +.PHONY: charts +charts: clean + $(HELM) package charts/shipyard + +# Perform Linting +.PHONY: lint +lint: pep8 helm_lint + +# Dry run templating of chart +.PHONY: dry-run +dry-run: clean + tools/helm_tk.sh $(HELM) + $(HELM) template charts/shipyard + +# Make targets intended for use by the primary targets above. .PHONY: build_airflow build_airflow: @@ -24,3 +46,16 @@ build_airflow: .PHONY: build_shipyard build_shipyard: docker build -t $(IMAGE_PREFIX)/$(SHIPYARD_IMAGE_NAME):$(IMAGE_TAG) -f images/shipyard/Dockerfile . + +.PHONY: clean +clean: + rm -rf build + +.PHONY: pep8 +pep8: + tox -e pep8 + +.PHONY: helm_lint +helm_lint: clean + tools/helm_tk.sh $(HELM) + $(HELM) lint charts/shipyard diff --git a/tools/helm_tk.sh b/tools/helm_tk.sh new file mode 100755 index 00000000..7a2c7e25 --- /dev/null +++ b/tools/helm_tk.sh @@ -0,0 +1,52 @@ +#!/bin/bash +# Copyright 2017 AT&T Intellectual Property. All other rights reserved. +# +# 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. +# +# Script to setup helm-toolkit and helm dep up the shipyard chart +# +HELM=$1 + +set -x + +function helm_serve { + if [[ -d "$HOME/.helm" ]]; then + echo ".helm directory found" + else + ${HELM} init --client-only + fi + if [[ -z $(curl -s 127.0.0.1:8879 | grep 'Helm Repository') ]]; then + ${HELM} serve & > /dev/null + while [[ -z $(curl -s 127.0.0.1:8879 | grep 'Helm Repository') ]]; do + sleep 1 + echo "Waiting for Helm Repository" + done + else + echo "Helm serve already running" + fi + + if ${HELM} repo list | grep -q "^stable" ; then + ${HELM} repo remove stable + fi + + ${HELM} repo add local http://localhost:8879/charts +} + +mkdir -p build +cd build +git clone --depth 1 https://git.openstack.org/openstack/openstack-helm.git || true +cd openstack-helm +git pull +helm_serve +make helm-toolkit +${HELM} dep up ../../charts/shipyard