def k8s_copy_config(context, destination_namespace, name=None): source_configmap = ConfigMap(context, name=name) destination_configmap = ConfigMap(context, name=name, namespace=destination_namespace) source_configmap.load() destination_configmap.struct['data'] = source_configmap.struct['data'] destination_configmap.save()
def set_env(context, environment, namespace=None): configmap = ConfigMap(context, namespace=namespace) configmap.load() for s in environment: if '=' not in s: raise HokusaiError("Error: environment variables must be of the form 'KEY=VALUE'") split = s.split('=', 1) configmap.update(split[0], split[1]) configmap.save()
def get_env(context, environment, namespace=None): configmap = ConfigMap(context, namespace=namespace) configmap.load() if environment: for k, v in configmap.all(): if k in environment: print("%s=%s" % (k, v)) else: for k, v in configmap.all(): print("%s=%s" % (k, v))
def unset_env(context, environment, namespace=None): configmap = ConfigMap(context, namespace=namespace) configmap.load() for s in environment: configmap.delete(s) configmap.save()
def unset_env(context, environment): configmap = ConfigMap(context) configmap.load() for s in environment: configmap.delete(s) configmap.save()
def get_env(context, environment, namespace=None): configmap = ConfigMap(context, namespace=namespace) configmap.load() for k, v in sorted(configmap.all().items()): if not environment or (environment and k in environment): print_smart("%s=%s" % (k, v))