diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2016-05-18 21:19:01 +0300 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2016-05-18 21:19:01 +0300 |
commit | 08fddae7441ce9ac61bc80e5b93a2eafb8441430 (patch) | |
tree | 3921871fc9363f9ef869e6b6b36963e91446bd9e /app/models/project.rb | |
parent | b7d83acf5b03e08dc9e387e1abb83c5e3c80444c (diff) | |
parent | 2bea20b8ef4bb4c0577bfe68bb77f96958e164d2 (diff) |
Merge branch 'docker-registry-view' into 'master'
Add container registry support
Tasks:
- [x] Merge docker/distribution authentication service: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/3787
- [x] Implement Docker Registry API
- [x] Show a list of docker images in GitLab
- [x] Remove registry repository on project deletion
- [x] Support project rename, move and namespace rename
- [x] Use token when connecting the registry
- [x] Allow to delete images from GitLab
- [x] Support pushing from GitLab CI (gitlab-ci-token / $CI_BUILD_TOKEN)
- [x] Support GitLab Runner pulling for public repositories
- [ ] Support GitLab Runner pulling for private repositories
- [x] Add tests for Docker Registry API
- [x] Add tests for a views
- [x] Make texts nicer
- [x] Implement a backup support
- [ ] Create administration documentation https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/4141
- [ ] Create user documentation
See merge request !4040
Diffstat (limited to 'app/models/project.rb')
-rw-r--r-- | app/models/project.rb | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index b7ae34c95c6..2a6b0839b64 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -329,12 +329,30 @@ class Project < ActiveRecord::Base @repository ||= Repository.new(path_with_namespace, self) end - def container_registry_url - if container_registry_enabled? && Gitlab.config.registry.enabled - "#{Gitlab.config.registry.host_with_port}/#{path_with_namespace}" + def container_registry_repository + return unless Gitlab.config.registry.enabled + + @container_registry_repository ||= begin + token = Auth::ContainerRegistryAuthenticationService.full_access_token(path_with_namespace) + url = Gitlab.config.registry.api_url + host_port = Gitlab.config.registry.host_port + registry = ContainerRegistry::Registry.new(url, token: token, path: host_port) + registry.repository(path_with_namespace) end end + def container_registry_repository_url + if Gitlab.config.registry.enabled + "#{Gitlab.config.registry.host_port}/#{path_with_namespace}" + end + end + + def has_container_registry_tags? + return unless container_registry_repository + + container_registry_repository.tags.any? + end + def commit(id = 'HEAD') repository.commit(id) end @@ -746,6 +764,11 @@ class Project < ActiveRecord::Base expire_caches_before_rename(old_path_with_namespace) + if has_container_registry_tags? + # we currently doesn't support renaming repository if it contains tags in container registry + raise Exception.new('Project cannot be renamed, because tags are present in its container registry') + end + if gitlab_shell.mv_repository(old_path_with_namespace, new_path_with_namespace) # If repository moved successfully we need to send update instructions to users. # However we cannot allow rollback since we moved repository |