blob: d994397269d8cdcdb7837f6d8c0c81fc7e714ba1 [file] [log] [blame]
Mike Elliott003d7292018-03-26 12:28:53 -04001# Copyright © 2017 Amdocs, Bell Canada
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
Mike Elliottae51de82018-02-16 10:48:59 -050015PARENT_CHART := onap
16COMMON_CHARTS_DIR := common
Mike Elliottae51de82018-02-16 10:48:59 -050017# FIXME OOM-765
18ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
19OUTPUT_DIR := $(ROOT_DIR)/dist
20PACKAGE_DIR := $(OUTPUT_DIR)/packages
21SECRET_DIR := $(OUTPUT_DIR)/secrets
Jakub Latusekdb52a6d2020-10-15 15:02:47 +020022HELM_BIN := helm
Krzysztof Opasiak2a4b47f2021-02-18 19:09:00 +010023
24# Helm v2 and helm v3 uses different version format so we first try in helm v3 format
25# and if it fails then we fallback to helm v2 one
26HELM_VER := $(shell $(HELM_BIN) version --template "{{.Version}}" 2>/dev/null)
27ifneq "$(findstring v3,$(HELM_VER))" "v3"
28 HELM_VER := $(shell $(HELM_BIN) version -c --template "{{.Client.SemVer}}")
29endif
30
Krzysztof Opasiakfa83b9c2020-11-06 19:33:47 +010031# use this if you would like to push onap charts to repo with other name
32# WARNING: Helm v3+ only
33# WARNING: Make sure to edit also requirements files
34HELM_REPO := local
Mike Elliottae51de82018-02-16 10:48:59 -050035
Krzysztof Opasiak2d35b232020-02-21 13:50:42 +010036ifneq ($(SKIP_LINT),TRUE)
Jakub Latusekdb52a6d2020-10-15 15:02:47 +020037 HELM_LINT_CMD := $(HELM_BIN) lint
Krzysztof Opasiak2d35b232020-02-21 13:50:42 +010038else
39 HELM_LINT_CMD := echo "Skipping linting of"
40endif
41
Sylvain Desbureaux70070412020-11-09 21:58:48 +010042SUBMODS := robot
Ubuntu5e0f3402019-12-12 23:01:28 +000043EXCLUDES := config oneclick readiness test dist helm $(PARENT_CHART) dcae $(SUBMODS)
Mateusz Pilat613343a2020-05-15 12:19:48 +020044HELM_CHARTS := $(filter-out $(EXCLUDES), $(sort $(patsubst %/.,%,$(wildcard */.)))) $(PARENT_CHART)
Mike Elliottae51de82018-02-16 10:48:59 -050045
Jakub Latusek4b4412c2020-10-30 10:32:01 +010046.PHONY: $(EXCLUDES) $(HELM_CHARTS) check-for-staging-images
Mike Elliottae51de82018-02-16 10:48:59 -050047
Sylvain Desbureaux00d473f2021-02-15 16:16:23 +010048all: print_helm_bin $(COMMON_CHARTS_DIR) $(SUBMODS) $(HELM_CHARTS) helm-repo-update plugins
Mandeep Khindaa57d8dd2018-03-09 14:29:37 +000049
Mike Elliott003d7292018-03-26 12:28:53 -040050$(COMMON_CHARTS):
Mandeep Khindaa57d8dd2018-03-09 14:29:37 +000051 @echo "\n[$@]"
52 @make package-$@
53
Mike Elliottae51de82018-02-16 10:48:59 -050054$(HELM_CHARTS):
55 @echo "\n[$@]"
56 @make package-$@
57
Ubuntu5e0f3402019-12-12 23:01:28 +000058$(SUBMODS):
59 @echo "\n[$@]"
60 @make submod-$@
61 @make package-$@
62
63submod-%:
64 @make $*/requirements.yaml
65
66%/requirements.yaml:
67 $(error Submodule $* needs to be retrieved from gerrit. See https://wiki.onap.org/display/DW/OOM+-+Development+workflow+after+code+transfer+to+tech+teams ); fi
68
Sylvain Desbureaux00d473f2021-02-15 16:16:23 +010069print_helm_bin:
70 $(info Using Helm binary ${HELM_BIN} which is helm version ${HELM_VER})
Ubuntu5e0f3402019-12-12 23:01:28 +000071
Mike Elliottae51de82018-02-16 10:48:59 -050072make-%:
73 @if [ -f $*/Makefile ]; then make -C $*; fi
74
75dep-%: make-%
Jakub Latusekdb52a6d2020-10-15 15:02:47 +020076 @if [ -f $*/requirements.yaml ]; then $(HELM_BIN) dep up $*; fi
Mike Elliottae51de82018-02-16 10:48:59 -050077
78lint-%: dep-%
Krzysztof Opasiak2d35b232020-02-21 13:50:42 +010079 @if [ -f $*/Chart.yaml ]; then $(HELM_LINT_CMD) $*; fi
Mike Elliottae51de82018-02-16 10:48:59 -050080
81package-%: lint-%
82 @mkdir -p $(PACKAGE_DIR)
Jakub Latusek6a74e0d2020-10-12 11:55:56 +000083ifeq "$(findstring v3,$(HELM_VER))" "v3"
Krzysztof Opasiakfa83b9c2020-11-06 19:33:47 +010084 @if [ -f $*/Chart.yaml ]; then PACKAGE_NAME=$$($(HELM_BIN) package -d $(PACKAGE_DIR) $* | cut -d":" -f2) && $(HELM_BIN) push -f $$PACKAGE_NAME $(HELM_REPO); fi
Jakub Latusek6a74e0d2020-10-12 11:55:56 +000085else
Jakub Latusekdb52a6d2020-10-15 15:02:47 +020086 @if [ -f $*/Chart.yaml ]; then $(HELM_BIN) package -d $(PACKAGE_DIR) $*; fi
Jakub Latusekdb52a6d2020-10-15 15:02:47 +020087 @$(HELM_BIN) repo index $(PACKAGE_DIR)
Krzysztof Opasiakfa83b9c2020-11-06 19:33:47 +010088endif
Mike Elliottae51de82018-02-16 10:48:59 -050089
90clean:
91 @rm -f */requirements.lock
Dominic Lunanuovae825fee2018-04-12 14:40:34 +000092 @find . -type f -name '*.tgz' -delete
Mike Elliottcb047cb2018-03-27 12:34:57 -040093 @rm -rf $(PACKAGE_DIR)/*
Mike Elliott6a84df32018-03-26 09:37:37 -040094
Mike Elliott2034ea72018-11-26 16:41:54 -050095# publish helm plugins via distrubtion directory
96plugins:
Sylvain Desbureauxa0b1fb12021-01-05 13:24:49 +010097 @cp -R helm $(PACKAGE_DIR)/
Mike Elliott2034ea72018-11-26 16:41:54 -050098
Mike Elliottcb047cb2018-03-27 12:34:57 -040099# start up a local helm repo to serve up helm chart packages
Krzysztof Opasiakfa83b9c2020-11-06 19:33:47 +0100100# WARNING: Only helm < v3 supported
Mike Elliott6a84df32018-03-26 09:37:37 -0400101repo:
102 @mkdir -p $(PACKAGE_DIR)
Jakub Latusekdb52a6d2020-10-15 15:02:47 +0200103 @$(HELM_BIN) serve --repo-path $(PACKAGE_DIR) &
Krzysztof Opasiak21731c92020-07-22 14:02:03 +0200104 @sleep 3
Jakub Latusekdb52a6d2020-10-15 15:02:47 +0200105 @$(HELM_BIN) repo index $(PACKAGE_DIR)
106 @$(HELM_BIN) repo add local http://127.0.0.1:8879
Mike Elliottcb047cb2018-03-27 12:34:57 -0400107
108# stop local helm repo
Krzysztof Opasiakfa83b9c2020-11-06 19:33:47 +0100109# WARNING: Only helm < v3 supported
Mike Elliottcb047cb2018-03-27 12:34:57 -0400110repo-stop:
Jakub Latusekdb52a6d2020-10-15 15:02:47 +0200111 @pkill $(HELM_BIN)
112 @$(HELM_BIN) repo remove local
Jakub Latusek4b4412c2020-10-30 10:32:01 +0100113
114check-for-staging-images:
115 $(ROOT_DIR)/contrib/tools/check-for-staging-images.sh
116
Krzysztof Opasiakfa83b9c2020-11-06 19:33:47 +0100117helm-repo-update:
118ifeq "$(findstring v3,$(HELM_VER))" "v3"
Bartek Grzybowski380f9b82020-11-24 14:13:48 +0100119 @$(HELM_BIN) repo update
Krzysztof Opasiakfa83b9c2020-11-06 19:33:47 +0100120endif
121
Mike Elliottae51de82018-02-16 10:48:59 -0500122%:
Mike Elliott13fed112018-02-28 08:33:33 -0500123 @: