Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:__
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/pybritive/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '2.1.4'
__version__ = '2.2.0'
9 changes: 7 additions & 2 deletions src/pybritive/britive_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/pybritive/cli_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""


Expand Down
20 changes: 20 additions & 0 deletions src/pybritive/commands/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
13 changes: 11 additions & 2 deletions src/pybritive/helpers/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -234,9 +233,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.')
Expand Down