Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add offline flag for epicli #510

Merged
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
9 changes: 9 additions & 0 deletions core/src/epicli/cli/engine/ansible/AnsibleVarsGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def populate_group_vars(self, ansible_dir):
main_vars = self.add_validate_certs(main_vars)
main_vars = self.add_dependencies_info(main_vars)
main_vars = self.add_shared_config(main_vars)
main_vars = self.add_offline_mode(main_vars)

vars_dir = os.path.join(ansible_dir, 'group_vars')
if not os.path.exists(vars_dir):
Expand All @@ -79,6 +80,14 @@ def add_validate_certs(self, document):

return document

def add_offline_mode(self, document):
if document is None:
raise Exception('Config is empty for: ' + 'group_vars/all.yml')

document['offline_mode'] = Config().offline_mode

return document

def add_dependencies_info(self, document):
if document is None:
raise Exception('Config is empty for: ' + 'group_vars/all.yml')
Expand Down
3 changes: 3 additions & 0 deletions core/src/epicli/cli/epicli.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def main():
config.log_type = args.log_type
config.log_count = args.log_count
config.validate_certs = True if args.validate_certs == 'true' else False
config.offline_mode = args.offline_mode
config.debug = args.debug
config.auto_approve = args.auto_approve

Expand Down Expand Up @@ -114,6 +115,8 @@ def apply_parser(subparsers):
help='File with infrastructure/configuration definitions to use.')
sub_parser.add_argument('--no-infra', dest='no_infra', action="store_true",
help='Skip infrastructure provisioning.')
sub_parser.add_argument('--offline-mode', dest='offline_mode', action="store_true",
help='Should Epiphany run with offline packages.')

def run_apply(args):
adjust_paths_from_file(args)
Expand Down
19 changes: 15 additions & 4 deletions core/src/epicli/cli/helpers/Config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os


class Config:
class __ConfigBase:
def __init__(self):
Expand All @@ -18,6 +19,7 @@ def __init__(self):
self._validate_certs = True
self._debug = False
self._auto_approve = False
self._offline_mode = False

@property
def docker_cli(self):
Expand Down Expand Up @@ -93,17 +95,26 @@ def debug(self):
@debug.setter
def debug(self, debug):
if not debug is None:
self._debug = debug
self._debug = debug

@property
def auto_approve(self):
return self._auto_approve

@auto_approve.setter
def auto_approve(self, auto_approve):
if not auto_approve is None:
self._auto_approve = auto_approve

self._auto_approve = auto_approve

@property
def offline_mode(self):
return self._offline_mode

@offline_mode.setter
def offline_mode(self, offline_mode):
if not offline_mode is None:
self._offline_mode = offline_mode

instance = None

def __new__(cls):
Expand Down