def action(self): skip_crd_check = self.args['--skip-crd-check'] if not skip_crd_check: kubernetes_helpers.check_crds(exit_on_failure=True) if self.args['--no-push']: print("Skipping image push") else: self._push() self._deploy_new_container()
def action(self): """Creates a new git repository based on an mlt template in the current working directory. """ template_name = self.args["--template"] template_repo = self.args["--template-repo"] skip_crd_check = self.args["--skip-crd-check"] with git_helpers.clone_repo(template_repo) as temp_clone: templates_directory = os.path.join(temp_clone, constants.TEMPLATES_DIR, template_name) try: # The template configs get pulled into the mlt.json file, so # don't grab a copy of that in the app directory copytree(templates_directory, self.app_name, ignore=ignore_patterns(constants.TEMPLATE_CONFIG)) # Get the template configs from the template and include them # when building the mlt json file param_file = os.path.join(templates_directory, constants.TEMPLATE_CONFIG) template_params = config_helpers.\ get_template_parameters_from_file(param_file) if not skip_crd_check: kubernetes_helpers.check_crds(app_name=self.app_name) data = self._build_mlt_json(template_params) with open(os.path.join(self.app_name, constants.MLT_CONFIG), 'w') as f: json.dump(data, f, indent=2) self._init_git_repo() except OSError as exc: if exc.errno == 17: print( "Directory '{}' already exists: delete before trying " "to initialize new application".format(self.app_name)) else: traceback.print_exc() sys.exit(1)
def action(self): schema.validate() if sync_helpers.get_sync_spec() is not None: print(colored("This folder is currently being synced, please run " "`mlt sync delete {}` to delete sync spec " "manually".format(sync_helpers.get_sync_spec()), 'yellow')) skip_crd_check = self.args['--skip-crd-check'] if not skip_crd_check: kubernetes_helpers.check_crds(exit_on_failure=True) if self.args['--no-push']: print("Skipping image push") else: self._push() self._deploy_new_container() if self.args["--logs"]: self._tail_logs()
def action(self): """Creates a new git repository based on an mlt template in the current working directory. """ template_name = self.args["--template"] template_repo = self.args["--template-repo"] skip_crd_check = self.args["--skip-crd-check"] with git_helpers.clone_repo(template_repo) as temp_clone: templates_directory = os.path.join(temp_clone, constants.TEMPLATES_DIR, template_name) try: # The template configs get pulled into the mlt.json file, so # don't grab a copy of that in this app's directory copytree(templates_directory, self.app_name, ignore=ignore_patterns(constants.TEMPLATE_CONFIG)) # Get the template configs from the template and include them # when building the mlt json file param_file = os.path.join(templates_directory, constants.TEMPLATE_CONFIG) template_params = config_helpers.\ get_template_parameters_from_file(param_file) template_git_sha = git_helpers.get_latest_sha( os.path.join(temp_clone, constants.TEMPLATES_DIR, template_name)) if not skip_crd_check: kubernetes_helpers.check_crds(app_name=self.app_name) if self.args["--enable-sync"]: if localhost_helpers.binary_path('ksync'): # Syncthing uses '.stignore' to ignore files during # sync we also don't want to upload unneeded local data app_ignore_file = os.path.join(self.app_name, ".gitignore") ksync_ignore_file = os.path.join( self.app_name, ".stignore") if self._check_update_yaml_for_sync(): copyfile(app_ignore_file, ksync_ignore_file) with open(ksync_ignore_file, 'a+') as f: f.write("\n.git/**") else: error_handling.throw_error( "This app doesn't support syncing", 'yellow') else: error_handling.throw_error( "ksync is not installed on localhost.", 'red') data = self._build_mlt_json(template_params, template_git_sha) # If the app has option for debugging failures, grab the # Kubernetes debug wrapper file and put it in the app directory if any(param["name"] == "debug_on_fail" for param in template_params): self._enable_debug_on_fail(temp_clone) with open(os.path.join(self.app_name, constants.MLT_CONFIG), 'w') as f: json.dump(data, f, indent=2) self._init_git_repo() except OSError as exc: if exc.errno == 17: error_msg = "Directory '{}' already exists: ".format( self.app_name) + \ "delete before trying to initialize new application" color = 'red' else: error_msg = traceback.format_exc() color = None error_handling.throw_error(error_msg, color)