# The `common' part is automatically included (and possibly overriden by all
# other flavors)
common: &common
    # Default log level is info
    loglevel: _env:LOGLEVEL:info
    # By default, the registry acts standalone (eg: doesn't query the index)
    standalone: _env:STANDALONE:true
    # The default endpoint to use (if NOT standalone) is index.docker.io
    index_endpoint: _env:INDEX_ENDPOINT:https://index.docker.io
    # Storage redirect is disabled
    storage_redirect: _env:STORAGE_REDIRECT
    # Token auth is enabled (if NOT standalone)
    disable_token_auth: _env:DISABLE_TOKEN_AUTH
    # No priv key
    privileged_key: _env:PRIVILEGED_KEY
    # No search backend
    search_backend: _env:SEARCH_BACKEND
    # SQLite search backend
    sqlalchemy_index_database: _env:SQLALCHEMY_INDEX_DATABASE:sqlite:////tmp/docker-registry.db

    # Mirroring is not enabled
    mirroring:
        source: _env:MIRROR_SOURCE # https://registry-1.docker.io
        source_index: _env:MIRROR_SOURCE_INDEX # https://index.docker.io
        tags_cache_ttl: _env:MIRROR_TAGS_CACHE_TTL:172800 # seconds

    # cache:
    #     host: _env:CACHE_REDIS_HOST:localhost
    #     port: _env:CACHE_REDIS_PORT:6379
    #     db: 0
    #     password: _env:CACHE_REDIS_PASSWORD

    # Enabling LRU cache for small files
    # This speeds up read/write on small files
    # when using a remote storage backend (like S3).
    # cache_lru:
    #     host: _env:CACHE_LRU_REDIS_HOST:localhost
    #     port: _env:CACHE_LRU_REDIS_PORT:6379
    #     db: 0
    #     password: _env:CACHE_LRU_REDIS_PASSWORD

    # Enabling these options makes the Registry send an email on each code Exception
    email_exceptions:
        smtp_host: _env:SMTP_HOST
        smtp_port: _env:SMTP_PORT:25
        smtp_login: _env:SMTP_LOGIN
        smtp_password: _env:SMTP_PASSWORD
        smtp_secure: _env:SMTP_SECURE:false
        from_addr: _env:SMTP_FROM_ADDR:docker-registry@localdomain.local
        to_addr: _env:SMTP_TO_ADDR:noise+dockerregistry@localdomain.local

    # Enable bugsnag (set the API key)
    bugsnag: _env:BUGSNAG

# This is the default configuration when no flavor is specified
dev:
    <<: *common
    storage: local
    storage_path: /data

{{ if .deis_registry_s3accessKey }}
# To specify another flavor, set the environment variable SETTINGS_FLAVOR
# $ export SETTINGS_FLAVOR=prod
prod:
    storage: s3
    storage_path: /data
    # Amazon S3 Storage Configuration
    s3_access_key: {{ .deis_registry_s3accessKey }}
    s3_secret_key: {{ .deis_registry_s3secretKey }}
    s3_region: {{ .deis_registry_s3region }}
    s3_bucket: {{ .deis_registry_s3bucket }}
    boto_bucket: {{ .deis_registry_s3bucket }}
    s3_encrypt: bool({{ .deis_registry_s3encrypt }})
    s3_secure: bool({{ .deis_registry_s3secure }})
    storage_redirect: True
    # Enabling query cache on Redis
    cache:
        host: {{ .deis_cache_host }}
        port: {{ .deis_cache_port }}
        db: 1
    # Enabling these options makes the Registry send an email on each code Exception
    email_exceptions:
        smtp_host: {{ .deis_registry_smtpHost }}
        smtp_port: {{ .deis_registry_smtpPort }}
        smtp_login: {{ .deis_registry_smtpLogin }}
        smtp_password: {{ .deis_registry_smtpPassword }}
        smtp_secure: {{ .deis_registry_smtpSecure }}
        from_addr: {{ .deis_registry_smtpFrom }}
        to_addr: {{ .deis_registry_smtpTo }}
    # Enable bugsnag (set the API key)
    bugsnag: REPLACEME
{{ end }}

# This flavor is automatically used by unit tests
test:
    storage: local
    storage_path: /tmp/test

# This flavor is for storing images in Openstack Swift
{{ if .deis_registry_swiftAuthURL }}
swift:
    storage: swift
    storage_path: "_env:STORAGE_PATH:/registry"
    swift_authurl: {{ .deis_registry_swiftAuthURL }}
    swift_container: {{ .deis_registry_swiftContainer }}
    swift_user: {{ .deis_registry_swiftUser }}
    swift_password: {{ .deis_registry_swiftPassword }}
    swift_tenant_name: {{ .deis_registry_swiftTenantName }}
    swift_region_name: {{ .deis_registry_swiftRegionName }}
{{ end }}

# This flavor stores the images in Glance (to integrate with openstack)
# See also: https://github.com/dotcloud/openstack-docker
openstack:
    storage: glance
    storage_alternate: local
    storage_path: /tmp/registry
    loglevel: debug

# This flavor stores the images in Glance (to integrate with openstack)
# and tags in Swift.
{{ if .deis_registry_swiftAuthURL }}
openstack-swift:
    storage: glance
    storage_path: /registry
    storage_alternate: swift
    # keystone authorization
    swift_authurl: {{ .deis_registry_swiftAuthURL }}
    swift_container: {{ .deis_registry_swiftContainer }}
    swift_user: {{ .deis_registry_swiftUser }}
    swift_password: {{ .deis_registry_swiftPassword }}
    swift_tenant_name: {{ .deis_registry_swiftTenantName }}
    swift_region_name: {{ .deis_registry_swiftRegionName }}
{{ end }}
