from django.utils.translation import gettext_lazy as _

from mayan.apps.platforms.platform_templates import PlatformTemplate
from mayan.literals import (
    DEFAULT_DATABASE_NAME, DEFAULT_DATABASE_PASSWORD, DEFAULT_DATABASE_USER,
    DOCKER_CLI_IMAGE_VERSION, DOCKER_DIND_IMAGE_VERSION,
    DOCKER_LINUX_IMAGE_NAME, DOCKER_LINUX_IMAGE_TAG,
    DOCKER_POSTGRESQL_IMAGE_NAME, DOCKER_POSTGRESQL_IMAGE_TAG,
    GITLAB_CI_BRANCH_BUILDS_DOCKER_ALL, GITLAB_CI_BRANCH_BUILDS_DOCKER_AMD64,
    GITLAB_CI_BRANCH_BUILDS_DOCKER_ARM64,
    GITLAB_CI_BRANCH_BUILDS_DOCUMENTATION, GITLAB_CI_BRANCH_BUILDS_PYTHON,
    GITLAB_CI_BRANCH_DEPLOYMENTS_DEMO,
    GITLAB_CI_BRANCH_DEPLOYMENTS_STAGING_ALL,
    GITLAB_CI_BRANCH_DEPLOYMENTS_STAGING_AMD64,
    GITLAB_CI_BRANCH_DEPLOYMENTS_STAGING_ARM64,
    GITLAB_CI_BRANCH_RELEASES_ALL_MAJOR, GITLAB_CI_BRANCH_RELEASES_ALL_MINOR,
    GITLAB_CI_BRANCH_RELEASES_DOCKER_MAJOR,
    GITLAB_CI_BRANCH_RELEASES_DOCKER_MINOR,
    GITLAB_CI_BRANCH_RELEASES_DOCUMENTATION,
    GITLAB_CI_BRANCH_RELEASES_NIGHTLY, GITLAB_CI_BRANCH_RELEASES_PYTHON_MAJOR,
    GITLAB_CI_BRANCH_RELEASES_PYTHON_MINOR,
    GITLAB_CI_BRANCH_RELEASES_STAGING_ALL,
    GITLAB_CI_BRANCH_RELEASES_STAGING_AMD64,
    GITLAB_CI_BRANCH_RELEASES_STAGING_ARM64,
    GITLAB_CI_BRANCH_RELEASES_TESTING, GITLAB_CI_BRANCH_TESTS_ALL,
    GITLAB_CI_BRANCH_TESTS_DOCKER, GITLAB_CI_BRANCH_TESTS_PYTHON,
    GITLAB_CI_BRANCH_TRY_STAGING_ALL, GITLAB_CI_BRANCH_TRY_STAGING_AMD64,
    GITLAB_CI_BRANCH_TRY_STAGING_ARM64, GITLAB_CI_RUNNER_TAG_AMD64,
    GITLAB_CI_RUNNER_TAG_ARM64, LINUX_PACKAGES_ALPINE_BUILD,
    LINUX_PACKAGES_ALPINE_ESSENTIAL, LINUX_PACKAGES_ALPINE_PYTHON,
    LINUX_PACKAGES_DEBIAN_BASE, LINUX_PACKAGES_DEBIAN_BUILD,
    LINUX_PACKAGES_DEBIAN_DOCUMENTATION, LINUX_PACKAGES_DEBIAN_ESSENTIAL,
    LINUX_PACKAGES_DEBIAN_POSTGRESQL, LINUX_PACKAGES_DEBIAN_PYTHON,
    LINUX_PACKAGES_DEBIAN_TEST, TEST_PARALLEL_PROCESSES
)


class PlatformTemplateGitLabCI(PlatformTemplate):
    label = _(message='Template that generates a GitLab CI config file.')
    name = 'gitlab-ci'
    template_name = 'platform/gitlab/gitlab-ci.tmpl'

    def get_context(self):
        return {
            'DEFAULT_DATABASE_NAME': DEFAULT_DATABASE_NAME,
            'DEFAULT_DATABASE_PASSWORD': DEFAULT_DATABASE_PASSWORD,
            'DEFAULT_DATABASE_USER': DEFAULT_DATABASE_USER,
            'DOCKER_CLI_IMAGE_VERSION': DOCKER_CLI_IMAGE_VERSION,
            'DOCKER_DIND_IMAGE_VERSION': DOCKER_DIND_IMAGE_VERSION,
            'DOCKER_LINUX_IMAGE_NAME': DOCKER_LINUX_IMAGE_NAME,
            'DOCKER_LINUX_IMAGE_TAG': DOCKER_LINUX_IMAGE_TAG,
            'DOCKER_POSTGRESQL_IMAGE_NAME': DOCKER_POSTGRESQL_IMAGE_NAME,
            'DOCKER_POSTGRESQL_IMAGE_TAG': DOCKER_POSTGRESQL_IMAGE_TAG,
            'GITLAB_CI_BRANCH_BUILDS_DOCKER_ALL': GITLAB_CI_BRANCH_BUILDS_DOCKER_ALL,
            'GITLAB_CI_BRANCH_BUILDS_DOCKER_AMD64': GITLAB_CI_BRANCH_BUILDS_DOCKER_AMD64,
            'GITLAB_CI_BRANCH_BUILDS_DOCKER_ARM64': GITLAB_CI_BRANCH_BUILDS_DOCKER_ARM64,
            'GITLAB_CI_BRANCH_BUILDS_DOCUMENTATION': GITLAB_CI_BRANCH_BUILDS_DOCUMENTATION,
            'GITLAB_CI_BRANCH_BUILDS_PYTHON': GITLAB_CI_BRANCH_BUILDS_PYTHON,
            'GITLAB_CI_BRANCH_DEPLOYMENTS_DEMO': GITLAB_CI_BRANCH_DEPLOYMENTS_DEMO,
            'GITLAB_CI_BRANCH_DEPLOYMENTS_STAGING_ALL': GITLAB_CI_BRANCH_DEPLOYMENTS_STAGING_ALL,
            'GITLAB_CI_BRANCH_DEPLOYMENTS_STAGING_AMD64': GITLAB_CI_BRANCH_DEPLOYMENTS_STAGING_AMD64,
            'GITLAB_CI_BRANCH_DEPLOYMENTS_STAGING_ARM64': GITLAB_CI_BRANCH_DEPLOYMENTS_STAGING_ARM64,
            'GITLAB_CI_BRANCH_RELEASES_ALL_MAJOR': GITLAB_CI_BRANCH_RELEASES_ALL_MAJOR,
            'GITLAB_CI_BRANCH_RELEASES_ALL_MINOR': GITLAB_CI_BRANCH_RELEASES_ALL_MINOR,
            'GITLAB_CI_BRANCH_RELEASES_DOCKER_MAJOR': GITLAB_CI_BRANCH_RELEASES_DOCKER_MAJOR,
            'GITLAB_CI_BRANCH_RELEASES_DOCKER_MINOR': GITLAB_CI_BRANCH_RELEASES_DOCKER_MINOR,
            'GITLAB_CI_BRANCH_RELEASES_DOCUMENTATION': GITLAB_CI_BRANCH_RELEASES_DOCUMENTATION,
            'GITLAB_CI_BRANCH_RELEASES_NIGHTLY': GITLAB_CI_BRANCH_RELEASES_NIGHTLY,
            'GITLAB_CI_BRANCH_RELEASES_PYTHON_MAJOR': GITLAB_CI_BRANCH_RELEASES_PYTHON_MAJOR,
            'GITLAB_CI_BRANCH_RELEASES_PYTHON_MINOR': GITLAB_CI_BRANCH_RELEASES_PYTHON_MINOR,
            'GITLAB_CI_BRANCH_RELEASES_STAGING_ALL': GITLAB_CI_BRANCH_RELEASES_STAGING_ALL,
            'GITLAB_CI_BRANCH_RELEASES_STAGING_AMD64': GITLAB_CI_BRANCH_RELEASES_STAGING_AMD64,
            'GITLAB_CI_BRANCH_RELEASES_STAGING_ARM64': GITLAB_CI_BRANCH_RELEASES_STAGING_ARM64,
            'GITLAB_CI_BRANCH_RELEASES_TESTING': GITLAB_CI_BRANCH_RELEASES_TESTING,
            'GITLAB_CI_BRANCH_TESTS_ALL': GITLAB_CI_BRANCH_TESTS_ALL,
            'GITLAB_CI_BRANCH_TESTS_DOCKER': GITLAB_CI_BRANCH_TESTS_DOCKER,
            'GITLAB_CI_BRANCH_TESTS_PYTHON': GITLAB_CI_BRANCH_TESTS_PYTHON,
            'GITLAB_CI_BRANCH_TRY_STAGING_ALL': GITLAB_CI_BRANCH_TRY_STAGING_ALL,
            'GITLAB_CI_BRANCH_TRY_STAGING_AMD64': GITLAB_CI_BRANCH_TRY_STAGING_AMD64,
            'GITLAB_CI_BRANCH_TRY_STAGING_ARM64': GITLAB_CI_BRANCH_TRY_STAGING_ARM64,
            'GITLAB_CI_RUNNER_TAG_AMD64': GITLAB_CI_RUNNER_TAG_AMD64,
            'GITLAB_CI_RUNNER_TAG_ARM64': GITLAB_CI_RUNNER_TAG_ARM64,
            'LINUX_PACKAGES_ALPINE_BUILD': LINUX_PACKAGES_ALPINE_BUILD,
            'LINUX_PACKAGES_ALPINE_ESSENTIAL': LINUX_PACKAGES_ALPINE_ESSENTIAL,
            'LINUX_PACKAGES_ALPINE_PYTHON': LINUX_PACKAGES_ALPINE_PYTHON,
            'LINUX_PACKAGES_DEBIAN_BASE': LINUX_PACKAGES_DEBIAN_BASE,
            'LINUX_PACKAGES_DEBIAN_BUILD': LINUX_PACKAGES_DEBIAN_BUILD,
            'LINUX_PACKAGES_DEBIAN_DOCUMENTATION': LINUX_PACKAGES_DEBIAN_DOCUMENTATION,
            'LINUX_PACKAGES_DEBIAN_ESSENTIAL': LINUX_PACKAGES_DEBIAN_ESSENTIAL,
            'LINUX_PACKAGES_DEBIAN_POSTGRESQL': LINUX_PACKAGES_DEBIAN_POSTGRESQL,
            'LINUX_PACKAGES_DEBIAN_PYTHON': LINUX_PACKAGES_DEBIAN_PYTHON,
            'LINUX_PACKAGES_DEBIAN_TEST': LINUX_PACKAGES_DEBIAN_TEST,
            'TEST_PARALLEL_PROCESSES': TEST_PARALLEL_PROCESSES
        }
