Near RT RIC Platform new-installer initial release
[ric-plt/ric-dep.git] / new-installer / helm / charts / nearrtric / Makefile
1 # Copyright © 2017 Amdocs, Bell Canada
2 #
3 # Copyright (c) 2023 Abhijit Gadgil
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #       http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 PARENT_CHART := nearrtric
18 COMMON_CHARTS = nearrt-ric-common
19 # FIXME OOM-765
20 ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
21 OUTPUT_DIR := $(ROOT_DIR)/dist
22 PACKAGE_DIR := $(OUTPUT_DIR)/packages
23 SECRET_DIR := $(OUTPUT_DIR)/secrets
24 HELM_BIN := helm
25
26 # Helm v2 and helm v3 uses different version format so we first try in helm v3 format
27 # and if it fails then we fallback to helm v2 one
28 HELM_VER := $(shell $(HELM_BIN) version --template "{{.Version}}" 2>/dev/null)
29 ifneq "$(findstring v3,$(HELM_VER))" "v3"
30         HELM_VER := $(shell $(HELM_BIN) version -c --template "{{.Client.SemVer}}")
31 endif
32
33 # use this if you would like to cm-push onap charts to repo with other name
34 # WARNING: Helm v3+ only
35 # WARNING: Make sure to edit also requirements files
36 HELM_REPO := local
37
38 ifneq ($(SKIP_LINT),TRUE)
39         HELM_LINT_CMD := $(HELM_BIN) lint
40 else
41         HELM_LINT_CMD := echo "Skipping linting of"
42 endif
43
44 #SUBMODS := robot
45 #EXCLUDES := config oneclick readiness test dist helm $(PARENT_CHART) dcae $(SUBMODS)
46 EXCLUDES := config test dist helm $(COMMON_CHARTS) $(PARENT_CHART)
47 HELM_CHARTS := $(filter-out $(EXCLUDES), $(sort $(patsubst %/.,%,$(wildcard */.)))) $(PARENT_CHART)
48 HELM_CHARTS_CLEAN := $(sort $(patsubst %,clean-%, $(HELM_CHARTS)))
49
50 .PHONY: $(COMMON_CHARTS) $(HELM_CHARTS) helm-repo-update
51
52 all: print_helm_bin $(COMMON_CHARTS) helm-repo-update $(HELM_CHARTS)
53
54 $(HELM_CHARTS):
55         @echo "\n[$@]"
56         @make package-$@
57
58 $(COMMON_CHARTS):
59         @echo "\n[$@]"
60         @make package-$@
61
62 $(HELM_CHARTS_CLEAN):
63         @echo "\n[clean $(patsubst clean-%,%,$@)]"
64         @rm -f $(patsubst clean-%,%,$@)/Chart.lock;
65         @rm -rf $(patsubst clean-%,%,$@)/charts;
66
67 print_helm_bin:
68         $(info Using Helm binary ${HELM_BIN} which is helm version ${HELM_VER})
69
70 make-%:
71         @if [ -f $*/Makefile ]; then make -C $*; fi
72
73 dep-%: make-%
74         @echo $(HELM_BIN) dep up --skip-refresh $*
75         @if [ -f $*/Chart.yaml ]; then $(HELM_BIN) dep up --skip-refresh $*; fi
76
77 lint-%: dep-%
78         @if [ -f $*/Chart.yaml ]; then $(HELM_LINT_CMD) $*; fi
79
80 package-%: lint-%
81         @mkdir -p $(PACKAGE_DIR)
82 ifeq "$(findstring v3,$(HELM_VER))" "v3"
83         @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 else
85         @if [ -f $*/Chart.yaml ]; then $(HELM_BIN) package -d $(PACKAGE_DIR) $*; fi
86         @$(HELM_BIN) repo index $(PACKAGE_DIR)
87 endif
88
89 clean: $(HELM_CHARTS_CLEAN)
90         @rm -f */Chart.lock
91         @find . -type f -name '*.tgz' -delete
92         @rm -rf $(PACKAGE_DIR)/*
93
94 distclean: clean
95         @rm -rf $(OUTPUT_DIR)
96
97 helm-repo-update:
98         @$(HELM_BIN) repo update
99
100 %:
101         @: