blob: 08b028afe14cab95ee05517fe6a06562de3317b1 [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
23HELM_VER := $(shell $(HELM_BIN) version --template "{{.Version}}")
Krzysztof Opasiakfa83b9c2020-11-06 19:33:47 +010024# use this if you would like to push onap charts to repo with other name
25# WARNING: Helm v3+ only
26# WARNING: Make sure to edit also requirements files
27HELM_REPO := local
Mike Elliottae51de82018-02-16 10:48:59 -050028
Krzysztof Opasiak2d35b232020-02-21 13:50:42 +010029ifneq ($(SKIP_LINT),TRUE)
Jakub Latusekdb52a6d2020-10-15 15:02:47 +020030 HELM_LINT_CMD := $(HELM_BIN) lint
Krzysztof Opasiak2d35b232020-02-21 13:50:42 +010031else
32 HELM_LINT_CMD := echo "Skipping linting of"
33endif
34
Ubuntu5e0f3402019-12-12 23:01:28 +000035SUBMODS := robot aai
36EXCLUDES := config oneclick readiness test dist helm $(PARENT_CHART) dcae $(SUBMODS)
Mateusz Pilat613343a2020-05-15 12:19:48 +020037HELM_CHARTS := $(filter-out $(EXCLUDES), $(sort $(patsubst %/.,%,$(wildcard */.)))) $(PARENT_CHART)
Mike Elliottae51de82018-02-16 10:48:59 -050038
Jakub Latusek4b4412c2020-10-30 10:32:01 +010039.PHONY: $(EXCLUDES) $(HELM_CHARTS) check-for-staging-images
Mike Elliottae51de82018-02-16 10:48:59 -050040
Krzysztof Opasiakfa83b9c2020-11-06 19:33:47 +010041all: $(COMMON_CHARTS_DIR) $(SUBMODS) $(HELM_CHARTS) helm-repo-update plugins
Mandeep Khindaa57d8dd2018-03-09 14:29:37 +000042
Mike Elliott003d7292018-03-26 12:28:53 -040043$(COMMON_CHARTS):
Mandeep Khindaa57d8dd2018-03-09 14:29:37 +000044 @echo "\n[$@]"
45 @make package-$@
46
Mike Elliottae51de82018-02-16 10:48:59 -050047$(HELM_CHARTS):
48 @echo "\n[$@]"
49 @make package-$@
50
Ubuntu5e0f3402019-12-12 23:01:28 +000051$(SUBMODS):
52 @echo "\n[$@]"
53 @make submod-$@
54 @make package-$@
55
56submod-%:
57 @make $*/requirements.yaml
58
59%/requirements.yaml:
60 $(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
61
62
Mike Elliottae51de82018-02-16 10:48:59 -050063make-%:
64 @if [ -f $*/Makefile ]; then make -C $*; fi
65
66dep-%: make-%
Jakub Latusekdb52a6d2020-10-15 15:02:47 +020067 @if [ -f $*/requirements.yaml ]; then $(HELM_BIN) dep up $*; fi
Mike Elliottae51de82018-02-16 10:48:59 -050068
69lint-%: dep-%
Krzysztof Opasiak2d35b232020-02-21 13:50:42 +010070 @if [ -f $*/Chart.yaml ]; then $(HELM_LINT_CMD) $*; fi
Mike Elliottae51de82018-02-16 10:48:59 -050071
72package-%: lint-%
73 @mkdir -p $(PACKAGE_DIR)
Jakub Latusek6a74e0d2020-10-12 11:55:56 +000074ifeq "$(findstring v3,$(HELM_VER))" "v3"
Krzysztof Opasiakfa83b9c2020-11-06 19:33:47 +010075 @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 +000076else
Jakub Latusekdb52a6d2020-10-15 15:02:47 +020077 @if [ -f $*/Chart.yaml ]; then $(HELM_BIN) package -d $(PACKAGE_DIR) $*; fi
Jakub Latusekdb52a6d2020-10-15 15:02:47 +020078 @$(HELM_BIN) repo index $(PACKAGE_DIR)
Krzysztof Opasiakfa83b9c2020-11-06 19:33:47 +010079endif
Mike Elliottae51de82018-02-16 10:48:59 -050080
81clean:
82 @rm -f */requirements.lock
Dominic Lunanuovae825fee2018-04-12 14:40:34 +000083 @find . -type f -name '*.tgz' -delete
Mike Elliottcb047cb2018-03-27 12:34:57 -040084 @rm -rf $(PACKAGE_DIR)/*
Mike Elliott6a84df32018-03-26 09:37:37 -040085
Mike Elliott2034ea72018-11-26 16:41:54 -050086# publish helm plugins via distrubtion directory
87plugins:
Jakub Latusekdb52a6d2020-10-15 15:02:47 +020088 @cp -R $(HELM_BIN) $(PACKAGE_DIR)/
Mike Elliott2034ea72018-11-26 16:41:54 -050089
Mike Elliottcb047cb2018-03-27 12:34:57 -040090# start up a local helm repo to serve up helm chart packages
Krzysztof Opasiakfa83b9c2020-11-06 19:33:47 +010091# WARNING: Only helm < v3 supported
Mike Elliott6a84df32018-03-26 09:37:37 -040092repo:
93 @mkdir -p $(PACKAGE_DIR)
Jakub Latusekdb52a6d2020-10-15 15:02:47 +020094 @$(HELM_BIN) serve --repo-path $(PACKAGE_DIR) &
Krzysztof Opasiak21731c92020-07-22 14:02:03 +020095 @sleep 3
Jakub Latusekdb52a6d2020-10-15 15:02:47 +020096 @$(HELM_BIN) repo index $(PACKAGE_DIR)
97 @$(HELM_BIN) repo add local http://127.0.0.1:8879
Mike Elliottcb047cb2018-03-27 12:34:57 -040098
99# stop local helm repo
Krzysztof Opasiakfa83b9c2020-11-06 19:33:47 +0100100# WARNING: Only helm < v3 supported
Mike Elliottcb047cb2018-03-27 12:34:57 -0400101repo-stop:
Jakub Latusekdb52a6d2020-10-15 15:02:47 +0200102 @pkill $(HELM_BIN)
103 @$(HELM_BIN) repo remove local
Jakub Latusek4b4412c2020-10-30 10:32:01 +0100104
105check-for-staging-images:
106 $(ROOT_DIR)/contrib/tools/check-for-staging-images.sh
107
Krzysztof Opasiakfa83b9c2020-11-06 19:33:47 +0100108helm-repo-update:
109ifeq "$(findstring v3,$(HELM_VER))" "v3"
Bartek Grzybowski380f9b82020-11-24 14:13:48 +0100110 @$(HELM_BIN) repo update
Krzysztof Opasiakfa83b9c2020-11-06 19:33:47 +0100111endif
112
Mike Elliottae51de82018-02-16 10:48:59 -0500113%:
Mike Elliott13fed112018-02-28 08:33:33 -0500114 @: