(self, args, **kwargs)
| 522 | |
| 523 | @add_auth_token_to_kwargs_from_cli |
| 524 | def run(self, args, **kwargs): |
| 525 | schema = self.app.client.managers["ConfigSchema"].get_by_ref_or_id( |
| 526 | args.name, **kwargs |
| 527 | ) |
| 528 | |
| 529 | if not schema: |
| 530 | msg = "%s \"%s\" doesn't exist or doesn't have a config schema defined." |
| 531 | raise resource.ResourceNotFoundError( |
| 532 | msg % (self.resource.get_display_name(), args.name) |
| 533 | ) |
| 534 | |
| 535 | config = interactive.InteractiveForm(schema.attributes).initiate_dialog() |
| 536 | |
| 537 | message = "---\nDo you want to preview the config in an editor before saving?" |
| 538 | description = "Secrets will be shown in plain text." |
| 539 | preview_dialog = interactive.Question( |
| 540 | message, {"default": "y", "description": description} |
| 541 | ) |
| 542 | if preview_dialog.read() == "y": |
| 543 | contents = yaml.safe_dump(config, indent=4, default_flow_style=False) |
| 544 | modified = editor.editor(text=contents) |
| 545 | config = yaml.safe_load(modified) |
| 546 | |
| 547 | message = "---\nDo you want me to save it?" |
| 548 | save_dialog = interactive.Question(message, {"default": "y"}) |
| 549 | if save_dialog.read() == "n": |
| 550 | raise OperationFailureException("Interrupted") |
| 551 | |
| 552 | config_item = Config(pack=args.name, values=config) |
| 553 | result = self.app.client.managers["Config"].update(config_item, **kwargs) |
| 554 | |
| 555 | return result |
| 556 | |
| 557 | def run_and_print(self, args, **kwargs): |
| 558 | try: |
no test coverage detected