Navigation Menu

Skip to content
This repository has been archived by the owner on Dec 7, 2022. It is now read-only.

Commit

Permalink
Add support for publishing Docker v2 content.
Browse files Browse the repository at this point in the history
This commit adds support for publishing Docker v2 content.

https://pulp.plan.io/issues/1051

closes #1051
  • Loading branch information
Randy Barlow committed Aug 18, 2015
1 parent 6de0ca7 commit 4d3a7dd
Show file tree
Hide file tree
Showing 8 changed files with 335 additions and 129 deletions.
3 changes: 3 additions & 0 deletions common/pulp_docker/common/constants.py
Expand Up @@ -35,7 +35,10 @@
# Keys that are specified on the repo config
PUBLISH_STEP_WEB_PUBLISHER = 'publish_to_web'
PUBLISH_STEP_EXPORT_PUBLISHER = 'export_to_tar'
PUBLISH_STEP_BLOBS = 'publish_blobs'
PUBLISH_STEP_IMAGES = 'publish_images'
PUBLISH_STEP_MANIFESTS = 'publish_manifests'
PUBLISH_STEP_TAGS = 'publish_tags'
PUBLISH_STEP_OVER_HTTP = 'publish_images_over_http'
PUBLISH_STEP_DIRECTORY = 'publish_directory'
PUBLISH_STEP_TAR = 'save_tar'
Expand Down
14 changes: 12 additions & 2 deletions plugins/etc/httpd/conf.d/pulp_docker.conf
Expand Up @@ -4,9 +4,19 @@

# -- HTTPS Repositories ---------

Alias /pulp/docker /var/www/pub/docker/web
# Docker v2

<Directory /var/www/pub/docker/web>
Alias /v2 /var/www/pub/docker/v2/web

<Directory /var/www/pub/docker/v2/web>
Options FollowSymlinks Indexes
</Directory>

# Docker v1

Alias /pulp/docker /var/www/pub/docker/v1/web

<Directory /var/www/pub/docker/v1/web>
SSLRequireSSL
SSLVerifyClient optional_no_ca
SSLVerifyDepth 2
Expand Down
94 changes: 53 additions & 41 deletions plugins/pulp_docker/plugins/distributors/configuration.py
Expand Up @@ -62,64 +62,72 @@ def validate_config(config, repo):
return True, None


def get_root_publish_directory(config):
def get_root_publish_directory(config, docker_api_version):
"""
The publish directory for the docker plugin
:param config: Pulp configuration for the distributor
:type config: pulp.plugins.config.PluginCallConfiguration
:return: The publish directory for the docker plugin
:rtype: str
:param config: Pulp configuration for the distributor
:type config: pulp.plugins.config.PluginCallConfiguration
:param docker_api_version: The Docker API version that is being published ('v1' or 'v2')
:type docker_api_version: basestring
:return: The publish directory for the docker plugin
:rtype: str
"""
return config.get(constants.CONFIG_KEY_DOCKER_PUBLISH_DIRECTORY)
return os.path.join(config.get(constants.CONFIG_KEY_DOCKER_PUBLISH_DIRECTORY),
docker_api_version)


def get_master_publish_dir(repo, config):
def get_master_publish_dir(repo, config, docker_api_version):
"""
Get the master publishing directory for the given repository.
This is the directory that links/files are actually published to
and linked from the directory published by the web server in an atomic action.
:param repo: repository to get the master publishing directory for
:type repo: pulp.plugins.model.Repository
:param config: configuration instance
:type config: pulp.plugins.config.PluginCallConfiguration or None
:return: master publishing directory for the given repository
:rtype: str
:param repo: repository to get the master publishing directory for
:type repo: pulp.plugins.model.Repository
:param config: configuration instance
:type config: pulp.plugins.config.PluginCallConfiguration or None
:param docker_api_version: The Docker API version that is being published ('v1' or 'v2')
:type docker_api_version: basestring
:return: master publishing directory for the given repository
:rtype: str
"""
return os.path.join(get_root_publish_directory(config), 'master', repo.id)
return os.path.join(get_root_publish_directory(config, docker_api_version), 'master', repo.id)


def get_web_publish_dir(repo, config):
def get_web_publish_dir(repo, config, docker_api_version):
"""
Get the configured HTTP publication directory.
Returns the global default if not configured.
:param repo: repository to get relative path for
:type repo: pulp.plugins.model.Repository
:param config: configuration instance
:type config: pulp.plugins.config.PluginCallConfiguration or None
:param repo: repository to get relative path for
:type repo: pulp.plugins.model.Repository
:param config: configuration instance
:type config: pulp.plugins.config.PluginCallConfiguration or None
:param docker_api_version: The Docker API version that is being published ('v1' or 'v2')
:type docker_api_version: basestring
:return: the HTTP publication directory
:rtype: str
"""

return os.path.join(get_root_publish_directory(config),
'web',
return os.path.join(get_root_publish_directory(config, docker_api_version), 'web',
get_repo_relative_path(repo, config))


def get_app_publish_dir(config):
def get_app_publish_dir(config, docker_api_version):
"""
Get the configured directory where the application redirect files should be stored
:param config: configuration instance
:type config: pulp.plugins.config.PluginCallConfiguration or None
:param config: configuration instance
:type config: pulp.plugins.config.PluginCallConfiguration or None
:param docker_api_version: The Docker API version that is being published ('v1' or 'v2')
:type docker_api_version: basestring
:returns: the name to use for the redirect file
:rtype: str
:returns: the name to use for the redirect file
:rtype: str
"""
return os.path.join(get_root_publish_directory(config), 'app',)
return os.path.join(get_root_publish_directory(config, docker_api_version), 'app',)


def get_redirect_file_name(repo):
Expand Down Expand Up @@ -171,16 +179,18 @@ def get_repo_relative_path(repo, config):
return repo.id


def get_export_repo_directory(config):
def get_export_repo_directory(config, docker_api_version):
"""
Get the directory where the export publisher will publish repositories.
:param config: configuration instance
:type config: pulp.plugins.config.PluginCallConfiguration or NoneType
:return: directory where export files are saved
:rtype: str
:param config: configuration instance
:type config: pulp.plugins.config.PluginCallConfiguration or NoneType
:param docker_api_version: The Docker API version that is being published ('v1' or 'v2')
:type docker_api_version: basestring
:return: directory where export files are saved
:rtype: str
"""
return os.path.join(get_root_publish_directory(config), 'export', 'repo')
return os.path.join(get_root_publish_directory(config, docker_api_version), 'export', 'repo')


def get_export_repo_filename(repo, config):
Expand All @@ -197,20 +207,22 @@ def get_export_repo_filename(repo, config):
return '%s.tar' % repo.id


def get_export_repo_file_with_path(repo, config):
def get_export_repo_file_with_path(repo, config, docker_api_version):
"""
Get the file name to use when exporting a docker repo as a tar file
:param repo: repository being exported
:type repo: pulp.plugins.model.Repository
:param config: configuration instance
:type config: pulp.plugins.config.PluginCallConfiguration or NoneType
:return: The absolute file name for the tar file that will be exported
:rtype: str
:param repo: repository being exported
:type repo: pulp.plugins.model.Repository
:param config: configuration instance
:type config: pulp.plugins.config.PluginCallConfiguration or NoneType
:param docker_api_version: The Docker API version that is being published ('v1' or 'v2')
:type docker_api_version: basestring
:return: The absolute file name for the tar file that will be exported
:rtype: str
"""
file_name = config.get(constants.CONFIG_KEY_EXPORT_FILE)
if not file_name:
file_name = os.path.join(get_export_repo_directory(config),
file_name = os.path.join(get_export_repo_directory(config, docker_api_version),
get_export_repo_filename(repo, config))
return file_name

Expand Down
Expand Up @@ -8,7 +8,7 @@
from pulp.plugins.distributor import Distributor

from pulp_docker.common import constants
from pulp_docker.plugins.distributors.publish_steps import ExportPublisher
from pulp_docker.plugins.distributors.v1_publish_steps import ExportPublisher
from pulp_docker.plugins.distributors import configuration


Expand Down

0 comments on commit 4d3a7dd

Please sign in to comment.