Esempio n. 1
0
 def __init__(self, conf_directory=DEFAULT_CONF_DIR):
     self.conf_directory = conf_directory
     home = os.path.expanduser("~")
     mkdir_p(os.path.join(home, conf_directory))
     path = "%s/%s/config.yaml" % (home, conf_directory)
     self.configfile = os.path.join(home, path)
     self._config = None
Esempio n. 2
0
 def __init__(self, conf_directory=DEFAULT_CONF_DIR):
     self.conf_directory = conf_directory
     home = os.path.expanduser("~")
     old_path = "%s/%s/auth_token" % (home, conf_directory)
     path = "%s/%s/auths.yaml" % (home, conf_directory)
     mkdir_p(os.path.join(home, conf_directory))
     self.tokenfile = os.path.join(home, path)
     self._tokens = None
     self._retro_compat(old_path)
Esempio n. 3
0
    def _helm(self):
        default_path = os.getenv("HELM_HOME", "~/.helm")
        home = os.path.expanduser(default_path) + "/plugins/cnr"
        mkdir_p(home)
        source = os.path.join(LOCAL_DIR, "plugins/helm")
        files = [os.path.join(source, "plugin.yaml"),
                 os.path.join(source, "cnr.sh")]

        for f in files:
            shutil.copy(f, home)

        self.status = "helm plugin installed"
Esempio n. 4
0
    def download_appr_deps(self, deps, dest=DEFAULT_CHARTS, tarball=False):
        """
            Creates a directory 'dep_charts' to download and extract all dependencies
            fetched from the app-registry server.
            returns a helm dependency list
        """
        mkdir_p(dest)
        helm_deps = {}
        for dep in deps:
            package_parts = parse_package_name(dep['name'])
            name = package_parts['package']

            vparts = parse_version(dep['version'])
            client = CnrClient(package_parts['host'])
            package_name = '%s/%s' % (package_parts['namespace'], name)

            pullpack = client.pull_json(package_name,
                                        version_parts=vparts,
                                        media_type='helm')
            package = CnrPackage(pullpack['blob'], b64_encoded=True)
            release = pullpack['release']
            packagepath = os.path.join(dest, package_parts['namespace'])
            print('Pulled package: %s (%s) \n -> %s' %
                  (dep['name'], release, packagepath),
                  file=sys.stderr)
            if tarball:
                with open('%s-%s.tgz' % (name, release), 'wb') as tarfile:
                    tarfile.write(package.blob)
            package.extract(packagepath)

            helm_deps[name] = {
                'name': name,
                'version': release,
                'repository': 'file://%s/%s' % (packagepath, name)
            }
        return helm_deps