def write_kubeconfig(self, config): """ Write config to disk. OK if the file doesn't exist. :param config: The kubeconfig to write :type config: Kubeconfig :raises KubeconfigInaccessableError: if the kubeconfig can't be opened for writing """ directory = os.path.dirname(config.path) try: os.makedirs(directory) except OSError as e: if e.errno != errno.EEXIST: raise KubeconfigInaccessableError( "Can't create directory for writing: {0}".format(e)) try: with open(config.path, "w+") as stream: ordered_yaml_dump(config.content, stream) except IOError as e: raise KubeconfigInaccessableError( "Can't open kubeconfig for writing: {0}".format(e))
def _display_entries(self, entries): """ Display entries in yaml format :param entries: a list of OrderedDicts to be printed :type entries: list """ uni_print("Entries:\n\n") for entry in entries: uni_print(ordered_yaml_dump(entry)) uni_print("\n")
def dump_content(self): """ Return the stored content in yaml format. """ return ordered_yaml_dump(self.content)