diff --git a/armada/cli/apply.py b/armada/cli/apply.py index fef068ba..4aa3bef1 100644 --- a/armada/cli/apply.py +++ b/armada/cli/apply.py @@ -85,6 +85,9 @@ SHORT_DESC = "Command installs manifest charts." @click.option('--enable-chart-cleanup', help="Clean up unmanaged charts.", is_flag=True) +@click.option('--use-doc-ref', + help="Use armada manifest file reference.", + is_flag=True) @click.option('--set', help=("Use to override Armada Manifest values. Accepts " "overrides that adhere to the format " @@ -130,13 +133,13 @@ SHORT_DESC = "Command installs manifest charts." is_flag=True) @click.pass_context def apply_create(ctx, locations, api, disable_update_post, disable_update_pre, - dry_run, enable_chart_cleanup, set, tiller_host, tiller_port, - tiller_namespace, timeout, values, wait, target_manifest, - debug): + dry_run, enable_chart_cleanup, use_doc_ref, set, tiller_host, + tiller_port, tiller_namespace, timeout, values, wait, + target_manifest, debug): CONF.debug = debug ApplyManifest(ctx, locations, api, disable_update_post, disable_update_pre, - dry_run, enable_chart_cleanup, set, tiller_host, tiller_port, - tiller_namespace, timeout, values, wait, + dry_run, enable_chart_cleanup, use_doc_ref, set, tiller_host, + tiller_port, tiller_namespace, timeout, values, wait, target_manifest).safe_invoke() @@ -149,6 +152,7 @@ class ApplyManifest(CliAction): disable_update_pre, dry_run, enable_chart_cleanup, + use_doc_ref, set, tiller_host, tiller_port, @@ -166,6 +170,7 @@ class ApplyManifest(CliAction): self.disable_update_pre = disable_update_pre self.dry_run = dry_run self.enable_chart_cleanup = enable_chart_cleanup + self.use_doc_ref = use_doc_ref self.set = set self.tiller_host = tiller_host self.tiller_port = tiller_port @@ -190,19 +195,19 @@ class ApplyManifest(CliAction): self.logger.info('Chart/values diff: %s', ch) def invoke(self): - if not self.ctx.obj.get('api', False): - try: - doc_data = ReferenceResolver.resolve_reference(self.locations) - documents = list() - for d in doc_data: - documents.extend(list(yaml.safe_load_all(d.decode()))) - except InvalidPathException as ex: - self.logger.error(str(ex)) - return - except yaml.YAMLError as yex: - self.logger.error("Invalid YAML found: %s" % str(yex)) - return + try: + doc_data = ReferenceResolver.resolve_reference(self.locations) + documents = list() + for d in doc_data: + documents.extend(list(yaml.safe_load_all(d.decode()))) + except InvalidPathException as ex: + self.logger.error(str(ex)) + return + except yaml.YAMLError as yex: + self.logger.error("Invalid YAML found: %s" % str(yex)) + return + if not self.ctx.obj.get('api', False): armada = Armada( documents, disable_update_pre=self.disable_update_pre, @@ -239,7 +244,10 @@ class ApplyManifest(CliAction): } client = self.ctx.obj.get('CLIENT') - - resp = client.post_apply( - manifest_ref=self.locations, set=self.set, query=query) + if self.use_doc_ref: + resp = client.post_apply( + manifest_ref=self.locations, set=self.set, query=query) + else: + resp = client.post_apply( + manifest=documents, set=self.set, query=query) self.output(resp.get('message')) diff --git a/armada/common/client.py b/armada/common/client.py index a8c5ef63..01945f05 100644 --- a/armada/common/client.py +++ b/armada/common/client.py @@ -100,9 +100,8 @@ class ArmadaClient(object): if manifest: if values or set: - document = list(yaml.safe_load_all(manifest)) override = Override( - document, overrides=set, values=values).update_manifests() + manifest, overrides=set, values=values).update_manifests() manifest = yaml.dump(override) resp = self.session.post( endpoint,