コード例 #1
0
ファイル: helm_client.py プロジェクト: telukir/cloudman
 def get_values(self, namespace, release_name, get_all=True):
     """
     get_all=True will also dump chart default values.
     get_all=False will only return user overridden values.
     """
     cmd = ["helm", "get", "values", "--namespace", namespace, release_name]
     if get_all:
         cmd += ["--all"]
     return yaml.safe_load(helpers.run_command(cmd))
コード例 #2
0
ファイル: helm_client.py プロジェクト: telukir/cloudman
 def rollback(self, namespace, release_name, revision=None):
     if not revision:
         history = self.history(namespace, release_name)
         if history and len(history) > 1:
             # Rollback to previous
             revision = history[-2].get('REVISION')
         else:
             return
     return helpers.run_command(
         ["helm", "rollback", "--namespace", namespace,
          release_name, revision])
コード例 #3
0
ファイル: helm_client.py プロジェクト: telukir/cloudman
 def _set_values_and_run_command(self, cmd, values):
     """
     Handles helm values by writing values to a temporary file,
     after which the command is run. The temporary file is cleaned
     up on exit from this method. This allows special values like braces
     to be handled without complex escaping, which the helm --set flag
     can't handle.
     """
     with tempfile.NamedTemporaryFile(mode="w", prefix="helmsman") as f:
         yaml.dump(values, stream=f, default_flow_style=False)
         cmd += ["-f", f.name]
         return helpers.run_command(cmd)
コード例 #4
0
    def _set_values_and_run_command(self, cmd, values_list):
        """
        Handles helm values by writing values to a temporary file,
        after which the command is run. The temporary file is cleaned
        up on exit from this method. This allows special values like braces
        to be handled without complex escaping, which the helm --set flag
        can't handle.

        The values can be a list of values files, in which case they will
        all be written to multiple temp files and passed to helm.
        """
        if not isinstance(values_list, list):
            values_list = [values_list]
        # contextlib.exitstack allows multiple temp files to be cleaned up
        # on exit. ref: https://stackoverflow.com/a/19412700
        with contextlib.ExitStack() as stack:
            files = [
                stack.enter_context(hm_helpers.TempValuesFile(values))
                for values in values_list
            ]
            for file in files:
                cmd += ["-f", file.name]
            return helpers.run_command(cmd)
コード例 #5
0
 def delete(self, repo_name):
     return helpers.run_command(["helm", "repo", "remove", repo_name])
コード例 #6
0
 def create(self, repo_name, url):
     return helpers.run_command(["helm", "repo", "add", repo_name, url])
コード例 #7
0
 def update(self):
     return helpers.run_command(["helm", "repo", "update"])
コード例 #8
0
 def delete(self, namespace, release_name):
     return helpers.run_command(
         ["helm", "delete", "--namespace", namespace, release_name])