def foldLeft[A, B](list: List[A], z: B)(op: (B, A) => B): B = {
def loop(currentList: List[A], acc: B): B = {
currentList match {
case Nil => acc
case head :: next => loop(next, op(acc, head))
}
}
loop(list, z)
To merge existing kubectl config with a new one we can use following script:
cp ~/.kube/config ~/.kube/config.old && \
KUBECONFIG=~/.kube/config:/path_to_new_config kubectl config view --flatten > /tmp_config && \
mv /tmp_config ~/.kube/config
/tmp_config
and /path_to_new_config
are just random names which could be changed. The script will create a file ~/.kube/config.old
with old version of kubectl config
KUBECONFIG
is an env variable that could be used to set the config file for kubectl
, kubectl
looks into this env variable and if not found uses the default config from ~/.kube/config
. Elements in KUBECONFIG
should be divided by :
for UNIX based systems where each element is a path to a file with kubectl config