Beispiel #1
0
    def post_apply(self,
                   manifest=None,
                   manifest_ref=None,
                   values=None,
                   set=None,
                   query=None,
                   timeout=None):
        """Call the Armada API to apply a Manifest.

        If ``manifest`` is not None, then the request body will be a fully
        rendered set of YAML documents including overrides and
        values-files application.

        If ``manifest`` is None and ``manifest_ref`` is not, then the request
        body will be a JSON structure providing a list of references
        to Armada manifest documents and a list of overrides. Local
        values files are not supported when using the API with references.

        :param manifest: string of YAML formatted Armada manifests
        :param manifest_ref: valid file paths or URIs referring to Armada
                             manifests
        :param values: list of local files containing values.yaml overrides
        :param set: list of single-value overrides
        :param query: explicit query string parameters
        :param timeout: a tuple of connect, read timeout (x, y)
        """
        endpoint = self._set_endpoint('1.0', 'apply')

        if manifest:
            if values or set:
                document = list(yaml.safe_load_all(manifest))
                override = Override(
                    document, overrides=set, values=values).update_manifests()
                manifest = yaml.dump(override)
            resp = self.session.post(
                endpoint,
                body=manifest,
                query=query,
                headers={
                    'content-type': 'application/x-yaml'
                },
                timeout=timeout)
        elif manifest_ref:
            req_body = {
                'hrefs': manifest_ref,
                'overrides': set or [],
            }
            resp = self.session.post(
                endpoint,
                data=req_body,
                query=query,
                headers={
                    'content-type': 'application/json'
                },
                timeout=timeout)

        self._check_response(resp)

        return resp.json()
Beispiel #2
0
    def post_apply(self, manifest=None, values=None, set=None, query=None):

        if values or set:
            document = list(yaml.safe_load_all(manifest))
            override = Override(document, overrides=set,
                                values=values).update_manifests()
            manifest = yaml.dump(override)

        endpoint = self._set_endpoint('1.0', 'apply')
        resp = self.session.post(endpoint, body=manifest, query=query)

        self._check_response(resp)

        return resp.json()