Coverage for appr/commands/deploy.py: 30%

# Coverage for appr/commands/deploy.py : 30%

## 46 statements 14 run 32 missing 0 excluded

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | from __future__ import absolute_import, division, print_function import os from appr.formats.utils import kub_factory from appr.commands.command_base import CommandBase, LoadVariables class DeployCmd(CommandBase): name = 'deploy' help_message = "deploy a package on kubernetes" default_media_type = "kpm" def __init__(self, options): super(DeployCmd, self).__init__(options) self.package = options.package self.registry_host = options.registry_host self.force = options.force self.dry_run = options.dry_run self.namespace = options.namespace self.api_proxy = options.api_proxy self.version = options.version self.version_parts = options.version_parts self.tmpdir = options.tmpdir self.variables = options.variables self.format = options.media_type if options.media_type is self.default_media_type: self.format = os.getenv("APPR_DEFAULT_MEDIA_TYPE", self.default_media_type) self.status = None self._kub = None @classmethod def _add_arguments(cls, parser): cls._add_registryhost_option(parser) cls._add_mediatype_option(parser, default=cls.default_media_type) cls._add_packagename_option(parser) cls._add_packageversion_option(parser) parser.add_argument("--tmpdir", default="/tmp/", help="directory used to extract resources") parser.add_argument("--dry-run", action='store_true', default=False, help="do not create the resources on kubernetes") parser.add_argument("-n", "--namespace", help="kubernetes namespace", default=None) parser.add_argument("--api-proxy", help="kubectl proxy url", nargs="?", const="http://localhost:8001") parser.add_argument("-x", "--variables", help="variables", default={}, action=LoadVariables) parser.add_argument("--force", action='store_true', default=False, help="force upgrade, delete and recreate resources") def kub(self): if self._kub is None: self._kub = kub_factory(self.format, self.package, endpoint=self.registry_host, variables=self.variables, namespace=self.namespace, version=self.version_parts) return self._kub def _call(self): self.status = self.kub().deploy(dest=self.tmpdir, force=self.force, dry=self.dry_run, proxy=self.api_proxy, fmt=self.output) def _render_dict(self): return self.status def _render_console(self): """ Handled by deploy """ return ''