summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorAndre Guedes <andrebsguedes@gmail.com>2016-12-16 01:24:05 -0200
committerAndre Guedes <andrebsguedes@gmail.com>2017-02-22 11:30:11 -0300
commite4fa80f3b67f1ef30c262cd4df28516ccff6336a (patch)
tree225b64223d018ca259fcfabd6b725918dfe4d126 /app
parent246df2bd1151d39a04ef553064144eb75ee3e980 (diff)
downloadgitlab-ce-e4fa80f3b67f1ef30c262cd4df28516ccff6336a.tar.gz
Fixes broken and missing tests
Diffstat (limited to 'app')
-rw-r--r--app/assets/stylesheets/pages/container_registry.scss6
-rw-r--r--app/controllers/projects/container_registry_controller.rb1
-rw-r--r--app/models/container_image.rb4
-rw-r--r--app/models/namespace.rb8
-rw-r--r--app/models/project.rb18
-rw-r--r--app/services/auth/container_registry_authentication_service.rb3
-rw-r--r--app/services/container_images/destroy_service.rb1
-rw-r--r--app/services/projects/transfer_service.rb6
-rw-r--r--app/views/projects/container_registry/_image.html.haml2
-rw-r--r--app/views/projects/container_registry/_tag.html.haml2
-rw-r--r--app/views/projects/container_registry/index.html.haml4
11 files changed, 25 insertions, 30 deletions
diff --git a/app/assets/stylesheets/pages/container_registry.scss b/app/assets/stylesheets/pages/container_registry.scss
index 7d68eae3c97..92543d7d714 100644
--- a/app/assets/stylesheets/pages/container_registry.scss
+++ b/app/assets/stylesheets/pages/container_registry.scss
@@ -3,14 +3,14 @@
*/
.container-image {
- border-bottom: 1px solid #f0f0f0;
+ border-bottom: 1px solid $white-normal;
}
.container-image-head {
- padding: 0px 16px;
+ padding: 0 16px;
line-height: 4;
}
.table.tags {
- margin-bottom: 0px;
+ margin-bottom: 0;
}
diff --git a/app/controllers/projects/container_registry_controller.rb b/app/controllers/projects/container_registry_controller.rb
index 54bcb5f504a..f656f86fcdb 100644
--- a/app/controllers/projects/container_registry_controller.rb
+++ b/app/controllers/projects/container_registry_controller.rb
@@ -20,7 +20,6 @@ class Projects::ContainerRegistryController < Projects::ApplicationController
redirect_to url, alert: 'Failed to remove image'
end
end
-
end
private
diff --git a/app/models/container_image.rb b/app/models/container_image.rb
index 7721c53a6fc..583cb977910 100644
--- a/app/models/container_image.rb
+++ b/app/models/container_image.rb
@@ -22,7 +22,7 @@ class ContainerImage < ActiveRecord::Base
end
def name_with_namespace
- [container_registry_path_with_namespace, name].compact.join('/')
+ [container_registry_path_with_namespace, name].reject(&:blank?).join('/')
end
def tag(tag)
@@ -55,6 +55,8 @@ class ContainerImage < ActiveRecord::Base
end
end
+ # rubocop:disable RedundantReturn
+
def self.split_namespace(full_path)
image_name = full_path.split('/').last
namespace = full_path.gsub(/(.*)(#{Regexp.escape('/' + image_name)})/, '\1')
diff --git a/app/models/namespace.rb b/app/models/namespace.rb
index bd0336c984a..c8e329044e0 100644
--- a/app/models/namespace.rb
+++ b/app/models/namespace.rb
@@ -118,8 +118,8 @@ class Namespace < ActiveRecord::Base
end
def move_dir
- if any_project_has_container_registry_tags?
- raise Gitlab::UpdatePathError.new('Namespace cannot be moved, because at least one project has tags in container registry')
+ if any_project_has_container_registry_images?
+ raise Gitlab::UpdatePathError.new('Namespace cannot be moved, because at least one project has images in container registry')
end
# Move the namespace directory in all storages paths used by member projects
@@ -154,8 +154,8 @@ class Namespace < ActiveRecord::Base
end
end
- def any_project_has_container_registry_tags?
- projects.any?(&:has_container_registry_tags?)
+ def any_project_has_container_registry_images?
+ projects.any? { |project| project.container_images.present? }
end
def send_update_instructions
diff --git a/app/models/project.rb b/app/models/project.rb
index afaf2095a4c..d4f5584f53d 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -421,18 +421,12 @@ class Project < ActiveRecord::Base
end
end
- def container_registry_repository_url
+ def container_registry_url
if Gitlab.config.registry.enabled
"#{Gitlab.config.registry.host_port}/#{container_registry_path_with_namespace}"
end
end
- def has_container_registry_tags?
- return unless container_images
-
- container_images.first.tags.any?
- end
-
def commit(ref = 'HEAD')
repository.commit(ref)
end
@@ -913,11 +907,11 @@ class Project < ActiveRecord::Base
expire_caches_before_rename(old_path_with_namespace)
- if has_container_registry_tags?
- Rails.logger.error "Project #{old_path_with_namespace} cannot be renamed because container registry tags are present"
+ if container_images.present?
+ Rails.logger.error "Project #{old_path_with_namespace} cannot be renamed because container registry images are present"
- # we currently doesn't support renaming repository if it contains tags in container registry
- raise StandardError.new('Project cannot be renamed, because tags are present in its container registry')
+ # we currently doesn't support renaming repository if it contains images in container registry
+ raise StandardError.new('Project cannot be renamed, because images are present in its container registry')
end
if gitlab_shell.mv_repository(repository_storage_path, old_path_with_namespace, new_path_with_namespace)
@@ -1264,7 +1258,7 @@ class Project < ActiveRecord::Base
]
if container_registry_enabled?
- variables << { key: 'CI_REGISTRY_IMAGE', value: container_registry_repository_url, public: true }
+ variables << { key: 'CI_REGISTRY_IMAGE', value: container_registry_url, public: true }
end
variables
diff --git a/app/services/auth/container_registry_authentication_service.rb b/app/services/auth/container_registry_authentication_service.rb
index 6b83b38fa4d..5b2fcdf3b16 100644
--- a/app/services/auth/container_registry_authentication_service.rb
+++ b/app/services/auth/container_registry_authentication_service.rb
@@ -16,7 +16,8 @@ module Auth
{ token: authorized_token(scope).encoded }
end
- def self.full_access_token(names)
+ def self.full_access_token(*names)
+ names = names.flatten
registry = Gitlab.config.registry
token = JSONWebToken::RSAToken.new(registry.key)
token.issuer = registry.issuer
diff --git a/app/services/container_images/destroy_service.rb b/app/services/container_images/destroy_service.rb
index bc5b53fd055..c73b6cfefba 100644
--- a/app/services/container_images/destroy_service.rb
+++ b/app/services/container_images/destroy_service.rb
@@ -1,6 +1,5 @@
module ContainerImages
class DestroyService < BaseService
-
class DestroyError < StandardError; end
def execute(container_image)
diff --git a/app/services/projects/transfer_service.rb b/app/services/projects/transfer_service.rb
index 20dfbddc823..3e241b9e7c0 100644
--- a/app/services/projects/transfer_service.rb
+++ b/app/services/projects/transfer_service.rb
@@ -36,9 +36,9 @@ module Projects
raise TransferError.new("Project with same path in target namespace already exists")
end
- if project.has_container_registry_tags?
- # we currently doesn't support renaming repository if it contains tags in container registry
- raise TransferError.new('Project cannot be transferred, because tags are present in its container registry')
+ unless project.container_images.empty?
+ # we currently doesn't support renaming repository if it contains images in container registry
+ raise TransferError.new('Project cannot be transferred, because images are present in its container registry')
end
project.expire_caches_before_rename(old_path)
diff --git a/app/views/projects/container_registry/_image.html.haml b/app/views/projects/container_registry/_image.html.haml
index b1d62e34a97..5845efd345a 100644
--- a/app/views/projects/container_registry/_image.html.haml
+++ b/app/views/projects/container_registry/_image.html.haml
@@ -10,7 +10,7 @@
= escape_once(image.name)
= clipboard_button(clipboard_text: "docker pull #{image.path}")
.controls.hidden-xs.pull-right
- = link_to namespace_project_container_registry_path(@project.namespace, @project, image.id), class: 'btn btn-remove has-tooltip', title: "Remove", data: { confirm: "Are you sure?" }, method: :delete do
+ = link_to namespace_project_container_registry_path(@project.namespace, @project, image.id), class: 'btn btn-remove has-tooltip', title: "Remove image", data: { confirm: "Are you sure?" }, method: :delete do
= icon("trash cred")
diff --git a/app/views/projects/container_registry/_tag.html.haml b/app/views/projects/container_registry/_tag.html.haml
index 00345ec26de..b35a9cb621f 100644
--- a/app/views/projects/container_registry/_tag.html.haml
+++ b/app/views/projects/container_registry/_tag.html.haml
@@ -25,5 +25,5 @@
- if can?(current_user, :update_container_image, @project)
%td.content
.controls.hidden-xs.pull-right
- = link_to namespace_project_container_registry_path(@project.namespace, @project, { id: tag.repository.id, tag: tag.name} ), class: 'btn btn-remove has-tooltip', title: "Remove", data: { confirm: "Are you sure?" }, method: :delete do
+ = link_to namespace_project_container_registry_path(@project.namespace, @project, { id: tag.repository.id, tag: tag.name} ), class: 'btn btn-remove has-tooltip', title: "Remove tag", data: { confirm: "Are you sure?" }, method: :delete do
= icon("trash cred")
diff --git a/app/views/projects/container_registry/index.html.haml b/app/views/projects/container_registry/index.html.haml
index f074ce6be6d..ab6213f03d8 100644
--- a/app/views/projects/container_registry/index.html.haml
+++ b/app/views/projects/container_registry/index.html.haml
@@ -15,9 +15,9 @@
%br
Then you are free to create and upload a container image with build and push commands:
%pre
- docker build -t #{escape_once(@project.container_registry_repository_url)} .
+ docker build -t #{escape_once(@project.container_registry_url)} .
%br
- docker push #{escape_once(@project.container_registry_repository_url)}
+ docker push #{escape_once(@project.container_registry_url)}
- if @images.blank?
.nothing-here-block No container images in Container Registry for this project.