Coverage for appr/commands/plugins.py : 37%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
version = plugin['name'] tarball_src = ("https://github.com/%s/releases/download/%s/registry-helm-plugin.tar.gz" % (plugin_info['repo'], version)) helm_home = os.getenv("HELM_HOME", os.path.join(expanduser("~"), ".helm")) plugin_path = os.getenv("HELM_PLUGIN_DIR", os.path.join(helm_home, "plugins")) mkdir_p(plugin_path) tardest = os.path.join(plugin_path, "appr-helm-plugin-%s.tar.gz" % version) res = requests.get(tarball_src) res.raise_for_status() with open(tardest, "wb") as f: f.write(res.content) tar = tarfile.open(tardest, 'r:gz') tar.extractall(plugin_path) bin_path = os.path.join(plugin_path, "registry/appr") if os.path.exists(bin_path): os.remove(bin_path) execscript = get_current_script_path() os.symlink(get_current_script_path(), bin_path) return { 'plugin-version': version, 'status': 'installed', 'path': os.path.join(plugin_path, 'registry'), 'symlink': execscript }
'helm': {'repo': 'app-registry/appr-helm-plugin', 'install_method': install_helm_plugin} }
super(PluginsCmd, self).__init__(options) self.plugin = options.plugin self.status = ""
def get_latest_plugin(cls, plugin_name): path = "https://api.github.com/repos/%s/tags" % cls.plugins[plugin_name]['repo'] resp = requests.get(path) resp.raise_for_status() json_resp = resp.json() return json_resp[0]
def _init_args(cls, subcmd): subcmd.add_argument("plugin", choices=['helm'], help='plugin')
plugin_name = options.plugin plugin = cls.get_latest_plugin(plugin_name) cmd = cls(options) cmd.status = cls.plugins[plugin_name]['install_method'](plugin, cls.plugins[plugin_name]) cmd.render()
def _add_arguments(cls, parser): sub = parser.add_subparsers() install_cmd = sub.add_parser('install') cls._init_args(install_cmd) install_cmd.set_defaults(func=cls._install)
return self.status
return self.status |