Skip to content

Commit

Permalink
Add optional secret loading, and disable for bump
Browse files Browse the repository at this point in the history
  • Loading branch information
Sticky-Bits committed Apr 16, 2020
1 parent 1cb2c26 commit d908dfc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
3 changes: 2 additions & 1 deletion gitops/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ def bump(ctx, filter, exclude='', image_tag=None, prefix=None, autoexclude_inact
filter=filter,
exclude=exclude,
autoexclude_inactive=autoexclude_inactive,
message=f"{prompt_message}{colourise(':', Fore.LIGHTBLUE_EX)}"
message=f"{prompt_message}{colourise(':', Fore.LIGHTBLUE_EX)}",
load_secrets=False,
)
except AppOperationAborted:
print(success_negative('Aborted.'))
Expand Down
8 changes: 4 additions & 4 deletions gitops/utils/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
from .tags import colour_tags, validate_tags


def get_app_details(app_name):
def get_app_details(app_name, load_secrets=True):
try:
ns = Namespace(app_name, path=f'apps/{app_name}')
ns = Namespace(app_name, path=f'apps/{app_name}', load_secrets=load_secrets)
except FileNotFoundError:
# Check if apps dir doesn't exist, or just that one app
if os.path.exists("apps"):
Expand All @@ -40,7 +40,7 @@ def update_app(app_name, **kwargs):
yaml.dump(data, f, default_flow_style=False)


def get_apps(filter=[], exclude=[], mode='PROMPT', autoexclude_inactive=True, message=None):
def get_apps(filter=[], exclude=[], mode='PROMPT', autoexclude_inactive=True, message=None, load_secrets=True):
""" Return apps that contain ALL of the tags listed in `filter` and NONE of the tags listed in
`exclude`. The incoming filter and exclude params may come in as a list or commastring.
For the purpose of this filtering, app names and image tag prefixes are also considered as
Expand Down Expand Up @@ -68,7 +68,7 @@ def get_apps(filter=[], exclude=[], mode='PROMPT', autoexclude_inactive=True, me
for entry in directory:
if not entry.is_dir():
continue
app = get_app_details(entry.name)
app = get_app_details(entry.name, load_secrets=load_secrets)
pseudotags = [
app['name'],
app['image'].split(':')[-1].split('-')[0],
Expand Down
7 changes: 5 additions & 2 deletions gitops_server/namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@


class Namespace:
def __init__(self, name, path=None, deployments={}, secrets={}):
def __init__(self, name, path=None, deployments={}, secrets={}, load_secrets=True):
self.name = name
self.path = path
if path:
self.deployments = load_yaml(os.path.join(path, 'deployment.yml'))
self.secrets = load_yaml(os.path.join(path, 'secrets.yml')).get('secrets', {})
if load_secrets:
self.secrets = load_yaml(os.path.join(path, 'secrets.yml')).get('secrets', {})
else:
self.secrets = secrets
else:
self.deployments = deployments
self.secrets = secrets
Expand Down

0 comments on commit d908dfc

Please sign in to comment.