Пример #1
0
    def execute(self, context: ExecutionContext) -> bool:
        opts = ''

        if context.args['skip_existing']:
            opts += ' --skip-existing '

        if context.get_arg('--url'):
            if context.get_arg('--test'):
                raise Exception('Cannot use --url and --test switch at once')

            opts += ' --repository-url=%s' % context.get_arg('--url')

        if context.get_arg('--test'):
            opts += ' --repository-url https://test.pypi.org/legacy/ '

        self.sh('''
            %s upload \\
                --disable-progress-bar \\
                --verbose \\
                --username=%s \\
                --password=%s \\
                %s %s
        ''' % (context.get_env('TWINE_PATH'), context.get_arg('--username'),
               context.get_arg('--password'), opts, context.get_arg('--src')))

        return True
Пример #2
0
    def run(self, ctx: ExecutionContext) -> bool:
        self.io().h2('Validating NGINX configuration')
        self.containers(ctx).exec_in_container('gateway', 'nginx -t')

        self.io().h2('Reloading NGINX configuration')
        self.containers(ctx).exec_in_container('gateway', 'nginx -s reload')

        if ctx.get_env('DISABLE_SSL').lower() != 'true':
            self.io().h2('Reloading SSL configuration')
            self.make_sure_ssl_service_is_up(ctx)
            self.containers(ctx).exec_in_container('gateway_letsencrypt', '/app/signal_le_service')

        return True
Пример #3
0
    def run(self, ctx: ExecutionContext) -> bool:
        if ctx.get_env('DISABLE_SSL').lower() != 'true':
            self.make_sure_ssl_service_is_up(ctx)

            try:
                self.io().out(self.containers(ctx).exec_in_container('gateway_letsencrypt', '/app/force_renew'))

            except subprocess.CalledProcessError as err:
                self.io().error_msg(str(err))
                self.io().error('Output: ' + str(err.output))
                return False

        self.io().info_msg('SSL is disabled, not regenerating anything')
        return True
Пример #4
0
    def execute(self, context: ExecutionContext) -> bool:
        """Harbor's wrapper - adds Harbor specific behavior before each task - initialization of the context
        """

        if not self._validate_env_present():
            self.io().error_msg('Missing .env file')
            return False

        self.app_user, self.app_group_id = self.detect_repository_owning_user_and_group()
        self.is_dev_env = self.detect_dev_env(context)
        project_name = context.get_env('COMPOSE_PROJECT_NAME')

        # project directory has to have owner that will manage files, that should be a deployment user
        self.io().debug('Project owner: USER=%s, GID=%i' % (self.app_user, self.app_group_id))

        if not project_name:
            self.io().error_msg('COMPOSE_PROJECT_NAME environment variable is not defined, cannot proceed')
            return False

        return self.run(context)
Пример #5
0
    def run(self, ctx: ExecutionContext) -> bool:
        if ctx.get_env('DISABLE_SSL').lower() != 'true':
            self.make_sure_ssl_service_is_up(ctx)
            self.io().out(self.containers(ctx).exec_in_container('gateway_letsencrypt', '/app/cert_status'))

        return True
Пример #6
0
 def get_project_name(ctx: ExecutionContext) -> str:
     return ctx.get_env('COMPOSE_PROJECT_NAME')
Пример #7
0
 def get_data_path(ctx: ExecutionContext) -> str:
     return ctx.get_env('DATA_PATH')
Пример #8
0
 def get_hooks_dir(ctx: ExecutionContext) -> str:
     return ctx.get_env('HOOKS_PATH')
Пример #9
0
 def get_apps_path(ctx: ExecutionContext) -> str:
     return ctx.get_env('APPS_PATH')
Пример #10
0
    def detect_dev_env(context: ExecutionContext) -> bool:
        suffix = context.get_env('DOMAIN_SUFFIX')

        return suffix.endswith('.localhost') or suffix.endswith('.xip.io')