blob: b92d41fe3f5d41dd535e7142a5a18d39a60c844b [file] [log] [blame]
Mike Elliott003d7292018-03-26 12:28:53 -04001# Copyright © 2017 Amdocs, Bell Canada
efiacor370c6dc2021-10-12 14:10:49 +01002# Modification copyright (C) 2021 Nordix Foundation
Mike Elliott003d7292018-03-26 12:28:53 -04003#
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
Mike Elliottae51de82018-02-16 10:48:59 -050016PARENT_CHART := onap
17COMMON_CHARTS_DIR := common
Mike Elliottae51de82018-02-16 10:48:59 -050018# FIXME OOM-765
19ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
20OUTPUT_DIR := $(ROOT_DIR)/dist
21PACKAGE_DIR := $(OUTPUT_DIR)/packages
22SECRET_DIR := $(OUTPUT_DIR)/secrets
Jakub Latusekdb52a6d2020-10-15 15:02:47 +020023HELM_BIN := helm
Krzysztof Opasiak2a4b47f2021-02-18 19:09:00 +010024
Krzysztof Opasiak2a4b47f2021-02-18 19:09:00 +010025HELM_VER := $(shell $(HELM_BIN) version --template "{{.Version}}" 2>/dev/null)
Krzysztof Opasiak2a4b47f2021-02-18 19:09:00 +010026
Andreas Geisslerf247bf62022-08-01 17:05:42 +020027# use this if you would like to cm-push onap charts to repo with other name
Krzysztof Opasiakfa83b9c2020-11-06 19:33:47 +010028# WARNING: Helm v3+ only
efiacor370c6dc2021-10-12 14:10:49 +010029# WARNING: Make sure to edit also Chart files
Krzysztof Opasiakfa83b9c2020-11-06 19:33:47 +010030HELM_REPO := local
Mike Elliottae51de82018-02-16 10:48:59 -050031
Krzysztof Opasiak2d35b232020-02-21 13:50:42 +010032ifneq ($(SKIP_LINT),TRUE)
Jakub Latusekdb52a6d2020-10-15 15:02:47 +020033 HELM_LINT_CMD := $(HELM_BIN) lint
Krzysztof Opasiak2d35b232020-02-21 13:50:42 +010034else
35 HELM_LINT_CMD := echo "Skipping linting of"
36endif
37
Sylvain Desbureaux70070412020-11-09 21:58:48 +010038SUBMODS := robot
Andreas Geisslerf247bf62022-08-01 17:05:42 +020039EXCLUDES := common config oneclick readiness test dist helm $(PARENT_CHART) dcae $(SUBMODS)
40HELM_CHARTS := $(filter-out $(EXCLUDES), $(sort $(patsubst %/.,%,$(wildcard */.))))
Mike Elliottae51de82018-02-16 10:48:59 -050041
Jakub Latusek4b4412c2020-10-30 10:32:01 +010042.PHONY: $(EXCLUDES) $(HELM_CHARTS) check-for-staging-images
Mike Elliottae51de82018-02-16 10:48:59 -050043
Andreas Geisslerf247bf62022-08-01 17:05:42 +020044all: print_helm_bin $(COMMON_CHARTS_DIR) $(SUBMODS) $(HELM_CHARTS) $(PARENT_CHART) helm-repo-update plugins
Mandeep Khindaa57d8dd2018-03-09 14:29:37 +000045
Andreas Geisslerf247bf62022-08-01 17:05:42 +020046$(COMMON_CHARTS_DIR):
Mandeep Khindaa57d8dd2018-03-09 14:29:37 +000047 @echo "\n[$@]"
48 @make package-$@
49
Andreas Geisslerf247bf62022-08-01 17:05:42 +020050$(HELM_CHARTS): $(COMMON_CHARTS_DIR)
Mike Elliottae51de82018-02-16 10:48:59 -050051 @echo "\n[$@]"
52 @make package-$@
53
Andreas Geisslerf247bf62022-08-01 17:05:42 +020054$(SUBMODS): $(COMMON_CHARTS_DIR)
Ubuntu5e0f3402019-12-12 23:01:28 +000055 @echo "\n[$@]"
56 @make submod-$@
57 @make package-$@
58
Andreas Geisslerf247bf62022-08-01 17:05:42 +020059$(PARENT_CHART): $(HELM_CHARTS)
60 @echo "\n[$@]"
61 @make package-$@
62
Ubuntu5e0f3402019-12-12 23:01:28 +000063submod-%:
efiacor370c6dc2021-10-12 14:10:49 +010064 @make $*/Chart.yaml
Ubuntu5e0f3402019-12-12 23:01:28 +000065
efiacor370c6dc2021-10-12 14:10:49 +010066%/Chart.yaml:
Ubuntu5e0f3402019-12-12 23:01:28 +000067 $(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-%
efiacor370c6dc2021-10-12 14:10:49 +010076 @if [ -f $*/Chart.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)
Andreas Geisslerf247bf62022-08-01 17:05:42 +020083 @if [ -f $*/Chart.yaml ]; then PACKAGE_NAME=$$($(HELM_BIN) package -d $(PACKAGE_DIR) $* | cut -d":" -f2) && $(HELM_BIN) cm-push -f $$PACKAGE_NAME $(HELM_REPO); fi
84 @sleep 3
Mike Elliottae51de82018-02-16 10:48:59 -050085
86clean:
efiacor370c6dc2021-10-12 14:10:49 +010087 @rm -f */Chart.lock
Dominic Lunanuovae825fee2018-04-12 14:40:34 +000088 @find . -type f -name '*.tgz' -delete
Mike Elliottcb047cb2018-03-27 12:34:57 -040089 @rm -rf $(PACKAGE_DIR)/*
Mike Elliott6a84df32018-03-26 09:37:37 -040090
Mike Elliott2034ea72018-11-26 16:41:54 -050091# publish helm plugins via distrubtion directory
92plugins:
Andreas Geisslerf247bf62022-08-01 17:05:42 +020093 @mkdir -p $(PACKAGE_DIR)
Sylvain Desbureauxa0b1fb12021-01-05 13:24:49 +010094 @cp -R helm $(PACKAGE_DIR)/
Mike Elliott2034ea72018-11-26 16:41:54 -050095
Jakub Latusek4b4412c2020-10-30 10:32:01 +010096check-for-staging-images:
Sylvain Desbureauxd035a0a2021-12-08 12:59:32 +010097 $(ROOT_DIR)/../.ci/check-for-staging-images.sh
Jakub Latusek4b4412c2020-10-30 10:32:01 +010098
Andreas Geisslerf247bf62022-08-01 17:05:42 +020099helm-repo-update: $(PARENT_CHART)
Bartek Grzybowski380f9b82020-11-24 14:13:48 +0100100 @$(HELM_BIN) repo update
Krzysztof Opasiakfa83b9c2020-11-06 19:33:47 +0100101
Mike Elliottae51de82018-02-16 10:48:59 -0500102%:
Andreas Geisslerf247bf62022-08-01 17:05:42 +0200103 @: