From 1e024a517434eec290cd30ede9cb1394eb8ff83f Mon Sep 17 00:00:00 2001 From: theborch Date: Thu, 8 May 2025 12:46:48 -0500 Subject: [PATCH 1/5] feat:add configure list command --- src/pybritive/britive_cli.py | 5 +++++ src/pybritive/commands/configure.py | 20 ++++++++++++++++++++ src/pybritive/helpers/config.py | 12 +++++++++++- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/pybritive/britive_cli.py b/src/pybritive/britive_cli.py index f0b7b96..6118749 100644 --- a/src/pybritive/britive_cli.py +++ b/src/pybritive/britive_cli.py @@ -1116,6 +1116,11 @@ def clear_kubeconfig(): def configure_update(self, section, field, value): self.config.update(section=section, field=field, value=value) + def configure_list(self, section, field): + import toml + + click.echo(toml.dumps(self.config.list(section=section, field=field))) + def request_submit(self, profile, justification, ticket_id, ticket_type): self._validate_justification(justification) self.login() diff --git a/src/pybritive/commands/configure.py b/src/pybritive/commands/configure.py index ba9baaf..c00d009 100644 --- a/src/pybritive/commands/configure.py +++ b/src/pybritive/commands/configure.py @@ -101,3 +101,23 @@ def update(ctx, silent, section, field, value): # silent is handled by @build_b field = field.lower().strip() value = value.lower().strip() ctx.obj.britive.configure_update(section=section, field=field, value=value) + + +@configure.command() +@build_britive +@click.argument('section', default='') +@click.argument('field', default='') +def list(ctx, section, field): + """Provides a mechanism to list the config or any section/field within it. + + All arguments provided will be converted to lowercase before being persisted. + + `SECTION`: The config section (example: global, tenant-foo) + + `FIELD`: The field within the section (example: default_tenant, name, output_format) + + Example: `pybritive configure list global output_format` + """ + section = section.lower().strip() + field = field.lower().strip() + ctx.obj.britive.configure_list(field=field, section=section) diff --git a/src/pybritive/helpers/config.py b/src/pybritive/helpers/config.py index ce1fbd6..2267da0 100644 --- a/src/pybritive/helpers/config.py +++ b/src/pybritive/helpers/config.py @@ -234,9 +234,19 @@ def update(self, section, field, value): self.config[section][field] = value self.save() + def list(self, section: str, field: str): + self.load() + try: + if field: + return {field: self.config[section][field]} + if section: + return {section: self.config[section]} + return self.config + except KeyError as e: + raise click.ClickException(f'{e} does not exist') from e + def validate(self): self.validation_error_messages = [] - for section, fields in self.config.items(): if section not in non_tenant_sections and not section.startswith('tenant-'): self.validation_error_messages.append(f'Invalid section {section} provided.') From 04b52822fe389c76a94f5409014718bf6cdce7c2 Mon Sep 17 00:00:00 2001 From: theborch Date: Thu, 8 May 2025 12:47:16 -0500 Subject: [PATCH 2/5] fix:add missing gcp standalone credential app type --- src/pybritive/britive_cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pybritive/britive_cli.py b/src/pybritive/britive_cli.py index 6118749..4f1fabf 100644 --- a/src/pybritive/britive_cli.py +++ b/src/pybritive/britive_cli.py @@ -632,7 +632,7 @@ def __get_cloud_credential_printer( return printer.AzureCloudCredentialPrinter( console=console, mode=mode, profile=profile, credentials=credentials, silent=silent, cli=self ) - if app_type in ['GCP']: + if app_type in ['GCP', 'GCP Standalone']: return printer.GcpCloudCredentialPrinter( console=console, mode=mode, From b882dc0f9ff7247308b8fd0b86d23e5773d7d55f Mon Sep 17 00:00:00 2001 From: theborch Date: Thu, 8 May 2025 12:47:58 -0500 Subject: [PATCH 3/5] chore:linting --- src/pybritive/britive_cli.py | 2 +- src/pybritive/helpers/config.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pybritive/britive_cli.py b/src/pybritive/britive_cli.py index 4f1fabf..94fada5 100644 --- a/src/pybritive/britive_cli.py +++ b/src/pybritive/britive_cli.py @@ -816,7 +816,7 @@ def _profile_is_for_resource(self, profile, profile_type): if profile_type == 'my-resources': return True real_profile_name = self.config.profile_aliases.get(profile.lower(), profile).lower() - return real_profile_name.startswith(f'{self.resource_profile_prefix}') + return real_profile_name.startswith(self.resource_profile_prefix) def _resource_checkout(self, blocktime, justification, maxpolltime, profile, ticket_id, ticket_type): try: diff --git a/src/pybritive/helpers/config.py b/src/pybritive/helpers/config.py index 2267da0..b53e831 100644 --- a/src/pybritive/helpers/config.py +++ b/src/pybritive/helpers/config.py @@ -108,7 +108,6 @@ def load(self, force=False): config.optionxform = str # maintain key case config.read(str(path)) config = json.loads(json.dumps(config._sections)) # TODO this is messy but works for now - self.config = lowercase(config) self.alias = None # will be set in self.get_tenant() self.default_tenant = self.config.get('global', {}).get('default_tenant') From ff39f2fd298d8c4b25d64098111b31016b208567 Mon Sep 17 00:00:00 2001 From: theborch Date: Thu, 8 May 2025 12:48:53 -0500 Subject: [PATCH 4/5] docs:verbiage update --- README.md | 4 ++-- docs/index.md | 2 +- src/pybritive/cli_interface.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2cea106..01cdfab 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# Britive CLI - Pure Python Implementation +# Britive CLI -PyBritive is intended to be used as a CLI application for communicating with the Britive Platform. +`pybritive` is the official CLI for communicating with the Britive Platform. ## Installation diff --git a/docs/index.md b/docs/index.md index be786ad..9e0542c 100644 --- a/docs/index.md +++ b/docs/index.md @@ -2,7 +2,7 @@ Full Britive documentation is available here: [docs.britive.com](https://docs.britive.com). -`pybritive` is intended to be used as a CLI application for interacting with the Britive Platform. +`pybritive` is the official CLI for communicating with the Britive Platform. ## Requirements diff --git a/src/pybritive/cli_interface.py b/src/pybritive/cli_interface.py index 56c68a4..25fd9f6 100644 --- a/src/pybritive/cli_interface.py +++ b/src/pybritive/cli_interface.py @@ -37,7 +37,7 @@ def safe_cli(): @britive_options(names='version') def cli(version): """ - PyBritive CLI - Pure Python Implementation for a Britive CLI + PyBritive - the official Britive CLI """ From 50dbba558784147ac251b5dc45a741677c95343f Mon Sep 17 00:00:00 2001 From: theborch Date: Thu, 8 May 2025 12:49:03 -0500 Subject: [PATCH 5/5] v2.2.0 --- CHANGELOG.md | 22 ++++++++++++++++++++++ src/pybritive/__init__.py | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab2e23d..689acb2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,28 @@ > As of v1.4.0, release candidates will be published in an effort to get new features out faster while still allowing > time for full QA testing before moving the release candidate to a full release. +## v2.2.0 [2025-05-08] + +__What's New:__ + +* None + +__Enhancements:__ + +* Users can now view configuration details through the `configure list` command. + +__Bug Fixes:__ + +* Fixed missing `GCP Standalone` credential handling. + +__Dependencies:__ + +* None + +__Other:__ + +* None + ## v2.1.4 [2025-04-02] __What's New:__ diff --git a/src/pybritive/__init__.py b/src/pybritive/__init__.py index 503eeb9..04188a1 100644 --- a/src/pybritive/__init__.py +++ b/src/pybritive/__init__.py @@ -1 +1 @@ -__version__ = '2.1.4' +__version__ = '2.2.0'