Skip to content

Commit be2a463

Browse files
authored
Merge pull request #6 from socialchorus/extended_k8
extending k8comp to include namespace,product and role from heira
2 parents f5b8bff + 215a394 commit be2a463

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

bin/k8comp

+72
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,24 @@ usage() {
101101
variable in the yaml|yml|json template.
102102
Available only in hiera
103103
104+
-d | --product <product> : The product will be checked from hiera. If no values are
105+
found in hiera the variables will not be replaced.
106+
NOT PART OF projects FILE STRUCTURE but can be added as
107+
variable in the yaml|yml|json template.
108+
Available only in hiera
109+
110+
-r | --role <role> : The role will be checked from hiera. If no values are
111+
found in hiera the variables will not be replaced.
112+
NOT PART OF projects FILE STRUCTURE but can be added as
113+
variable in the yaml|yml|json template.
114+
Available only in hiera
115+
116+
-n | --namespace <namespace> : The namespace will be checked from hiera. If no values are
117+
found in hiera the variables will not be replaced.
118+
NOT PART OF projects FILE STRUCTURE but can be added as
119+
variable in the yaml|yml|json template.
120+
Available only in hiera
121+
104122
-t | --template <template> : The templates folder can be configured on the k8comp.conf.
105123
The base location is on the projects folder.
106124
Can be used in conjunction with any of the main variables.
@@ -209,6 +227,30 @@ while [ $# -gt 0 ]; do
209227
shift
210228
fi
211229
;;
230+
-d|--product|product)
231+
if [ -n "$2" ]; then
232+
product=$2
233+
hrd="product=${2}"
234+
hrall+="${hrd} "
235+
shift
236+
fi
237+
;;
238+
-r|--role|role)
239+
if [ -n "$2" ]; then
240+
role=$2
241+
hrr="role=${2}"
242+
hrall+="${hrr} "
243+
shift
244+
fi
245+
;;
246+
-n|--namespace|namespace)
247+
if [ -n "$2" ]; then
248+
namespace=$2
249+
hrm="namespace=${2}"
250+
hrall+="${hrm} "
251+
shift
252+
fi
253+
;;
212254
-l|--location|location)
213255
if [ -n "$2" ]; then
214256
location=$2
@@ -342,6 +384,33 @@ kube_vars(){
342384
evar=$find_var
343385
h_environment=${evar##*=}
344386
fi
387+
elif [[ "${i%%=*}" == "product" ]]
388+
then
389+
if [ -z $find_var ]
390+
then
391+
h_product=$product
392+
else
393+
evar=$find_var
394+
h_product=${evar##*=}
395+
fi
396+
elif [[ "${i%%=*}" == "role" ]]
397+
then
398+
if [ -z $find_var ]
399+
then
400+
h_role=$role
401+
else
402+
evar=$find_var
403+
h_role=${evar##*=}
404+
fi
405+
elif [[ "${i%%=*}" == "namespace" ]]
406+
then
407+
if [ -z $find_var ]
408+
then
409+
h_namespace=$namespace
410+
else
411+
evar=$find_var
412+
h_namespace=${evar##*=}
413+
fi
345414
elif [[ "${i%%=*}" == "location" ]]
346415
then
347416
if [ -z $find_var ]
@@ -440,6 +509,9 @@ replace_var() {
440509
sed -i "s|%{project}|${h_project}|g" ${tmp_file}
441510
sed -i "s|%{application}|${h_application}|g" ${tmp_file}
442511
sed -i "s|%{environment}|${h_environment}|g" ${tmp_file}
512+
sed -i "s|%{product}|${h_product}|g" ${tmp_file}
513+
sed -i "s|%{role}|${h_role}|g" ${tmp_file}
514+
sed -i "s|%{namespace}|${h_namespace}|g" ${tmp_file}
443515
sed -i "s|%{location}|${h_location}|g" ${tmp_file}
444516
}
445517

0 commit comments

Comments
 (0)