def install(apps): """Ensures the named applications are installed at their current prevailing versions.""" config = load_config() for app_name in apps: if app_name not in config['apps']: raise OzyError(f"App '{app_name}' was not found") app = App(app_name, config) app.ensure_installed()
def info(): """Print information about the installation and configuration.""" _LOGGER.info(f"ozy v{__version__}") ozy_bin_dir = get_ozy_bin_dir() path_ok = check_path(ozy_bin_dir) if not path_ok: show_path_warning(ozy_bin_dir) user_config = load_ozy_user_conf() _LOGGER.info("Team URL: %s", user_config.get("url", "(unset)")) config = load_config() _LOGGER.info("Team config name: %s", config.get("name", "(unset)")) for app_name in config['apps']: app = App(app_name, config) _LOGGER.info(" %s: %s", app_name, app) if path_ok: found_app = shutil.which(app_name) if not found_app: _LOGGER.warning( " %s not found on path: perhaps an 'ozy sync' is needed?", app_name) else: if os.path.realpath(found_app) != os.path.realpath( os.path.join(ozy_bin_dir, app_name)): _LOGGER.warning( " %s is not under ozy control! It was found on your PATH earlier than ozy at %s", app_name, found_app)
def test_unsupported_installer(): sample_config_file = "conf/sample-team-conf.yaml" ozy_conf = parse_ozy_conf(sample_config_file) ozy_conf['templates']['hashicorp'][ 'type'] = 'triple_binary_star' # not a supported installer with pytest.raises(OzyError): App("nomad", ozy_conf)
def test_app(): sample_config_file = "conf/sample-team-conf.yaml" ozy_conf = parse_ozy_conf(sample_config_file) app = App("nomad", ozy_conf) assert app.name == "nomad" assert app.config['template'] == 'hashicorp' assert app.config['url'] assert app.config['type'] == 'single_binary_zip' assert app.config['sha256_gpg_key'] == ozy_conf['templates']['hashicorp'][ 'sha256_gpg_key'] assert app.config['sha256'] assert app.config['sha256_signature']
def makefile_config(makefile_var, required_apps, all_apps): """ Checks apps, and prints a single-line Makefile variable. Use as an argument to $(eval). Errors will are output as $(error) directives to report in make. The given variable is defined to be the ozy binary directory, so any app will be $(VAR)/app_name. If undefined, you know ozy isn't installed. Example: \b $ cat Makefile $(eval $(shell ozy makefile-config OZY_BIN_DIR terraform)) ifndef OZY_BIN_DIR $(error please install ozy) endif \b install: $(OZY_BIN_DIR)/terraform apply """ config = load_config() ozy_bin_dir = get_ozy_bin_dir() path_ok = check_path(ozy_bin_dir) if not path_ok: _makefile_error("ozy is not on the path") if all_apps: required_apps = config['apps'].keys() if not required_apps: _makefile_error("no ozy apps found to configure") for app_name in required_apps: if app_name not in config['apps']: _makefile_error(f"Missing ozy app '{app_name}'") app = App(app_name, config) found_app = shutil.which(app_name) app_in_bin = os.path.join(ozy_bin_dir, app_name) if os.path.realpath(found_app) != os.path.realpath(app_in_bin): _makefile_error( f"{found_app} found in PATH earlier than ozy: " f"results could be inconsistent (found at {found_app})") print(f"{makefile_var}:={ozy_bin_dir}")
def install_all(): """Ensures all applications are installed at their current prevailing versions.""" config = load_config() for app_name in config['apps']: app = App(app_name, config) app.ensure_installed()