|
2 | 2 | from britive.britive import Britive |
3 | 3 | from .helpers.config import ConfigManager |
4 | 4 | from .helpers.credentials import FileCredentialManager, EncryptedFileCredentialManager |
| 5 | +from .helpers.split import profile_split |
5 | 6 | import json |
6 | 7 | import click |
7 | 8 | import csv |
@@ -143,7 +144,7 @@ def print(self, data: object, ignore_silent: bool = False): |
143 | 144 | click.echo(json.dumps(data, indent=2, default=str)) |
144 | 145 | elif self.output_format == 'list': |
145 | 146 | for row in data: |
146 | | - click.echo(self.list_separator.join(row.values())) |
| 147 | + click.echo(self.list_separator.join([self.escape_profile_element(x) for x in row.values()])) |
147 | 148 | elif self.output_format == 'csv': |
148 | 149 | fields = list(data[0].keys()) |
149 | 150 | output = io.StringIO() |
@@ -359,7 +360,7 @@ def _should_check_force_renew(app, force_renew, console): |
359 | 360 |
|
360 | 361 | def _split_profile_into_parts(self, profile): |
361 | 362 | profile_real = self.config.profile_aliases.get(profile, profile) |
362 | | - parts = profile_real.split('/') |
| 363 | + parts = profile_split(profile_real) |
363 | 364 | if len(parts) != 3: |
364 | 365 | raise click.ClickException('Provided profile string does not have the required 3 parts.') |
365 | 366 | parts_dict = { |
@@ -551,9 +552,18 @@ def cache_profiles(self, load=True): |
551 | 552 | self._set_available_profiles() |
552 | 553 | profiles = [] |
553 | 554 | for p in self.available_profiles: |
554 | | - profiles.append(f"{p['app_name']}/{p['env_name']}/{p['profile_name']}") |
| 555 | + profile = self.escape_profile_element(p['app_name']) |
| 556 | + profile += '/' |
| 557 | + profile += self.escape_profile_element(p['env_name']) |
| 558 | + profile += '/' |
| 559 | + profile += self.escape_profile_element(p['profile_name']) |
| 560 | + profiles.append(profile) |
555 | 561 | Cache().save_profiles(profiles) |
556 | 562 |
|
| 563 | + @staticmethod |
| 564 | + def escape_profile_element(element): |
| 565 | + return element.replace('/', '\\/') |
| 566 | + |
557 | 567 | @staticmethod |
558 | 568 | def cache_clear(): |
559 | 569 | Cache().clear() |
|
0 commit comments