Browse Source

Support retrieving a specific profile

acm-debugging-and-enhancements
Drew Short 3 years ago
parent
commit
7f5f8a10a9
  1. 11
      acm.py
  2. 11
      acm/config.py

11
acm.py

@ -16,7 +16,7 @@ import click
from minio import Minio, InvalidResponseError from minio import Minio, InvalidResponseError
from minio.error import S3Error from minio.error import S3Error
from acm.config import VERSION, default_config
from acm.config import VERSION, get_default_config
from acm.logging import setup_basic_logging, update_logging_level from acm.logging import setup_basic_logging, update_logging_level
from acm.utility import get_string_sha256sum from acm.utility import get_string_sha256sum
@ -295,9 +295,14 @@ def print_default_config(ctx, profile):
Print the configuration Print the configuration
""" """
if profile == "all": if profile == "all":
print(default_config().json(exclude_none=True, indent=2, sort_keys=True))
print(get_default_config().json(exclude_none=True, indent=2, sort_keys=True))
else: else:
config = default_config()
config = get_default_config()
profile_names = config.get_profile_names()
if profile in profile_names:
print(config.get_profile(profile).json(exclude_none=True, indent=2, sort_keys=True))
else:
print(f"Profile \"{profile}\" is not in {profile_names}")
############################### ###############################
# S3 Storage Focused Commands # # S3 Storage Focused Commands #

11
acm/config.py

@ -107,8 +107,17 @@ class ACMConfig(BaseSettings):
env_prefix = 'ACM_' env_prefix = 'ACM_'
env_nested_delimiter = '__' env_nested_delimiter = '__'
def get_profile_names(self) -> typing.List[str]:
return [profile.name for profile in self.profiles]
def default_config():
def get_profile(self, name: str) -> typing.Optional[ACMProfile]:
for profile in self.profiles:
if name == profile.name:
return profile
return None
def get_default_config():
""" """
Returns the default ACM config Returns the default ACM config
""" """

Loading…
Cancel
Save