blob: ef913e33a9a9c28b238bc147d443602f76b192e5 [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
Krzysztof Opasiakfa83b9c2020-11-06 19:33:47 +010048all: $(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
69
Mike Elliottae51de82018-02-16 10:48:59 -050070make-%:
71 @if [ -f $*/Makefile ]; then make -C $*; fi
72
73dep-%: make-%
Jakub Latusekdb52a6d2020-10-15 15:02:47 +020074 @if [ -f $*/requirements.yaml ]; then $(HELM_BIN) dep up $*; fi
Mike Elliottae51de82018-02-16 10:48:59 -050075
76lint-%: dep-%
Krzysztof Opasiak2d35b232020-02-21 13:50:42 +010077 @if [ -f $*/Chart.yaml ]; then $(HELM_LINT_CMD) $*; fi
Mike Elliottae51de82018-02-16 10:48:59 -050078
79package-%: lint-%
80 @mkdir -p $(PACKAGE_DIR)
Jakub Latusek6a74e0d2020-10-12 11:55:56 +000081ifeq "$(findstring v3,$(HELM_VER))" "v3"
Krzysztof Opasiakfa83b9c2020-11-06 19:33:47 +010082 @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 +000083else
Jakub Latusekdb52a6d2020-10-15 15:02:47 +020084 @if [ -f $*/Chart.yaml ]; then $(HELM_BIN) package -d $(PACKAGE_DIR) $*; fi
Jakub Latusekdb52a6d2020-10-15 15:02:47 +020085 @$(HELM_BIN) repo index $(PACKAGE_DIR)
Krzysztof Opasiakfa83b9c2020-11-06 19:33:47 +010086endif
Mike Elliottae51de82018-02-16 10:48:59 -050087
88clean:
89 @rm -f */requirements.lock
Dominic Lunanuovae825fee2018-04-12 14:40:34 +000090 @find . -type f -name '*.tgz' -delete
Mike Elliottcb047cb2018-03-27 12:34:57 -040091 @rm -rf $(PACKAGE_DIR)/*
Mike Elliott6a84df32018-03-26 09:37:37 -040092
Mike Elliott2034ea72018-11-26 16:41:54 -050093# publish helm plugins via distrubtion directory
94plugins:
Sylvain Desbureauxa0b1fb12021-01-05 13:24:49 +010095 @cp -R helm $(PACKAGE_DIR)/
Mike Elliott2034ea72018-11-26 16:41:54 -050096
Mike Elliottcb047cb2018-03-27 12:34:57 -040097# start up a local helm repo to serve up helm chart packages
Krzysztof Opasiakfa83b9c2020-11-06 19:33:47 +010098# WARNING: Only helm < v3 supported
Mike Elliott6a84df32018-03-26 09:37:37 -040099repo:
100 @mkdir -p $(PACKAGE_DIR)
Jakub Latusekdb52a6d2020-10-15 15:02:47 +0200101 @$(HELM_BIN) serve --repo-path $(PACKAGE_DIR) &
Krzysztof Opasiak21731c92020-07-22 14:02:03 +0200102 @sleep 3
Jakub Latusekdb52a6d2020-10-15 15:02:47 +0200103 @$(HELM_BIN) repo index $(PACKAGE_DIR)
104 @$(HELM_BIN) repo add local http://127.0.0.1:8879
Mike Elliottcb047cb2018-03-27 12:34:57 -0400105
106# stop local helm repo
Krzysztof Opasiakfa83b9c2020-11-06 19:33:47 +0100107# WARNING: Only helm < v3 supported
Mike Elliottcb047cb2018-03-27 12:34:57 -0400108repo-stop:
Jakub Latusekdb52a6d2020-10-15 15:02:47 +0200109 @pkill $(HELM_BIN)
110 @$(HELM_BIN) repo remove local
Jakub Latusek4b4412c2020-10-30 10:32:01 +0100111
112check-for-staging-images:
113 $(ROOT_DIR)/contrib/tools/check-for-staging-images.sh
114
Krzysztof Opasiakfa83b9c2020-11-06 19:33:47 +0100115helm-repo-update:
116ifeq "$(findstring v3,$(HELM_VER))" "v3"
Bartek Grzybowski380f9b82020-11-24 14:13:48 +0100117 @$(HELM_BIN) repo update
Krzysztof Opasiakfa83b9c2020-11-06 19:33:47 +0100118endif
119
Mike Elliottae51de82018-02-16 10:48:59 -0500120%:
Mike Elliott13fed112018-02-28 08:33:33 -0500121 @: