예제 #1
0
파일: helm.py 프로젝트: joejulian/appr
 def exec_helm_cmd(self, cmd, options, helm_opts):
     pull_cmd = PullCmd(options)
     pull_cmd.exec_cmd(render=False)
     helm_cli = Helm()
     output = helm_cli.action(cmd, pull_cmd.path, helm_opts)
     self.status = {'result': output}
     self.render()
예제 #2
0
def test_appr_dep(db_with_data1, tmpdir):
    version = '0.0.1'
    name = "titi/rocketchat"

    with requests_mock.mock() as m:
        response = pull(name, version, "helm", db_with_data1.Package,
                        db_with_data1.Blob)
        m.get(DEFAULT_REGISTRY + DEFAULT_PREFIX +
              "/api/v1/packages/%s/%s/helm/pull" % (name, version),
              content=json.dumps(response))
        hp = Helm()
        tempdir = str(tmpdir.mkdir("charts"))
        deps = hp.download_appr_deps(
            [{
                'name': "%s/%s" % (DEFAULT_REGISTRY, name),
                'version': version,
                'randomKey': 'oky'
            }], tempdir)
        sp = name.split("/")
        assert deps == [{
            "repository":
            "file://%s" % os.path.join(tempdir, sp[0], sp[1]),
            "version":
            '0.0.1',
            "name":
            'rocketchat',
            "randomKey":
            'oky'
        }]
예제 #3
0
def test_build_deps_with_empty_values(req, expected, db_with_data1, tmpdir,
                                      chhome):
    dest = str(tmpdir.mkdir("charts"))
    hp = Helm()
    if isinstance(expected, dict):
        for dep in expected['dependencies']:
            dep.update({
                'repository':
                "file://%s" %
                os.path.join(dest, dep['repository'][0], dep['repository'][1])
            })
        for dep in expected['appr']:
            dep.update({
                'repository':
                "file://%s" %
                os.path.join(dest, dep['repository'][0], dep['repository'][1])
            })
    print(expected)
    with requests_mock.mock() as m:
        for dep in req.get('appr', []):
            package = '/'.join(dep['name'].split("/")[-2:])
            response = pull(package, dep['version'], "helm",
                            db_with_data1.Package, db_with_data1.Blob)
            m.get(DEFAULT_REGISTRY + DEFAULT_PREFIX +
                  "/api/v1/packages/%s/%s/helm/pull" %
                  (package, dep['version']),
                  content=json.dumps(response))
        with open("requirements.yaml", 'wb') as f:
            f.write(yaml.dump(req))
        output = yaml.safe_load(hp.build_dep(dest))

        print(output)
        assert output == expected
예제 #4
0
파일: helm.py 프로젝트: steved/appr
 def _dep_pull(cls, options, unknown=None):
     cmd = cls(options)
     helm_cli = Helm()
     cmd.status = {
         'result':
         helm_cli.build_dep(dest=options.dest, overwrite=options.overwrite)
     }
     cmd.render()
예제 #5
0
파일: helm.py 프로젝트: steved/appr
 def exec_helm_cmd(self, cmd, options, helm_opts):
     pull_cmd = PullCmd(options)
     pull_cmd.exec_cmd(render=False)
     helm_cli = Helm()
     try:
         output = helm_cli.action(cmd, pull_cmd.path, helm_opts)
     except subprocess.CalledProcessError as exc:
         payload = {"message": str(exc.output)}
         self.render_error(payload)
         exit(exc.returncode)
     self.status = {'result': output}
     self.render()
예제 #6
0
def test_build_deps_no_requirements(tmpdir, chhome):
    dest = str(tmpdir.mkdir("charts"))
    hp = Helm()
    assert hp.build_dep(dest) == "No requirements.yaml found"