Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions bin/k8comp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,24 @@ usage() {
variable in the yaml|yml|json template.
Available only in hiera

-d | --product <product> : The product will be checked from hiera. If no values are
found in hiera the variables will not be replaced.
NOT PART OF projects FILE STRUCTURE but can be added as
variable in the yaml|yml|json template.
Available only in hiera

-r | --role <role> : The role will be checked from hiera. If no values are
found in hiera the variables will not be replaced.
NOT PART OF projects FILE STRUCTURE but can be added as
variable in the yaml|yml|json template.
Available only in hiera

-n | --namespace <namespace> : The namespace will be checked from hiera. If no values are
found in hiera the variables will not be replaced.
NOT PART OF projects FILE STRUCTURE but can be added as
variable in the yaml|yml|json template.
Available only in hiera

-t | --template <template> : The templates folder can be configured on the k8comp.conf.
The base location is on the projects folder.
Can be used in conjunction with any of the main variables.
Expand Down Expand Up @@ -209,6 +227,30 @@ while [ $# -gt 0 ]; do
shift
fi
;;
-d|--product|product)
if [ -n "$2" ]; then
product=$2
hrd="product=${2}"
hrall+="${hrd} "
shift
fi
;;
-r|--role|role)
if [ -n "$2" ]; then
role=$2
hrr="role=${2}"
hrall+="${hrr} "
shift
fi
;;
-n|--namespace|namespace)
if [ -n "$2" ]; then
namespace=$2
hrm="namespace=${2}"
hrall+="${hrm} "
shift
fi
;;
-l|--location|location)
if [ -n "$2" ]; then
location=$2
Expand Down Expand Up @@ -342,6 +384,33 @@ kube_vars(){
evar=$find_var
h_environment=${evar##*=}
fi
elif [[ "${i%%=*}" == "product" ]]
then
if [ -z $find_var ]
then
h_product=$product
else
evar=$find_var
h_product=${evar##*=}
fi
elif [[ "${i%%=*}" == "role" ]]
then
if [ -z $find_var ]
then
h_role=$role
else
evar=$find_var
h_role=${evar##*=}
fi
elif [[ "${i%%=*}" == "namespace" ]]
then
if [ -z $find_var ]
then
h_namespace=$namespace
else
evar=$find_var
h_namespace=${evar##*=}
fi
elif [[ "${i%%=*}" == "location" ]]
then
if [ -z $find_var ]
Expand Down Expand Up @@ -440,6 +509,9 @@ replace_var() {
sed -i "s|%{project}|${h_project}|g" ${tmp_file}
sed -i "s|%{application}|${h_application}|g" ${tmp_file}
sed -i "s|%{environment}|${h_environment}|g" ${tmp_file}
sed -i "s|%{product}|${h_product}|g" ${tmp_file}
sed -i "s|%{role}|${h_role}|g" ${tmp_file}
sed -i "s|%{namespace}|${h_namespace}|g" ${tmp_file}
sed -i "s|%{location}|${h_location}|g" ${tmp_file}
}

Expand Down