Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
d05f0030
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d05f0030
编写于
5月 09, 2016
作者:
K
Kamil Trzcinski
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added Docker Registry View tests
上级
d5d8e76b
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
87 addition
and
27 deletion
+87
-27
app/controllers/jwt_controller.rb
app/controllers/jwt_controller.rb
+1
-1
app/services/jwt/container_registry_authentication_service.rb
...services/jwt/container_registry_authentication_service.rb
+4
-2
app/services/projects/destroy_service.rb
app/services/projects/destroy_service.rb
+1
-1
app/views/projects/container_registry/_tag.html.haml
app/views/projects/container_registry/_tag.html.haml
+20
-0
app/views/projects/container_registry/index.html.haml
app/views/projects/container_registry/index.html.haml
+2
-21
lib/container_registry/client.rb
lib/container_registry/client.rb
+2
-2
spec/features/container_registry_spec.rb
spec/features/container_registry_spec.rb
+43
-0
spec/fixtures/container_registry/config_blob.json
spec/fixtures/container_registry/config_blob.json
+1
-0
spec/fixtures/container_registry/tag_manifest.json
spec/fixtures/container_registry/tag_manifest.json
+1
-0
spec/support/stub_gitlab_calls.rb
spec/support/stub_gitlab_calls.rb
+12
-0
未找到文件。
app/controllers/jwt_controller.rb
浏览文件 @
d05f0030
...
...
@@ -3,7 +3,7 @@ class JwtController < ApplicationController
skip_before_action
:verify_authenticity_token
SERVICES
=
{
'container_registry'
=>
Jwt
::
ContainerRegistryAuthenticationService
,
Jwt
::
ContainerRegistryAuthenticationService
::
AUDIENCE
=>
Jwt
::
ContainerRegistryAuthenticationService
,
}
def
auth
...
...
app/services/jwt/container_registry_authentication_service.rb
浏览文件 @
d05f0030
module
Jwt
class
ContainerRegistryAuthenticationService
<
BaseService
AUDIENCE
=
'container_registry'
def
execute
if
params
[
:offline_token
]
return
error
(
'forbidden'
,
403
)
unless
current_user
...
...
@@ -14,7 +16,7 @@ module Jwt
registry
=
Gitlab
.
config
.
registry
token
=
::
Jwt
::
RSAToken
.
new
(
registry
.
key
)
token
.
issuer
=
registry
.
issuer
token
.
audience
=
'docker'
token
.
audience
=
AUDIENCE
token
[
:access
]
=
names
.
map
do
|
name
|
{
type:
'repository'
,
name:
name
,
actions:
%w(pull push)
}
end
...
...
@@ -26,7 +28,7 @@ module Jwt
def
authorized_token
(
access
)
token
=
::
Jwt
::
RSAToken
.
new
(
registry
.
key
)
token
.
issuer
=
registry
.
issuer
token
.
audience
=
params
[
:service
]
token
.
audience
=
AUDIENCE
token
.
subject
=
current_user
.
try
(
:username
)
token
[
:access
]
=
access
token
...
...
app/services/projects/destroy_service.rb
浏览文件 @
d05f0030
...
...
@@ -27,7 +27,7 @@ module Projects
project
.
destroy!
unless
remove_registry_tags
raise_error
(
'Failed to remove project
image
registry. Please try again or contact administrator'
)
raise_error
(
'Failed to remove project
container
registry. Please try again or contact administrator'
)
end
unless
remove_repository
(
repo_path
)
...
...
app/views/projects/container_registry/_tag.html.haml
0 → 100644
浏览文件 @
d05f0030
%tr
.tag
%td
=
escape_once
(
tag
.
name
)
=
clipboard_button
(
clipboard_text:
"docker pull
#{
tag
.
path
}
"
)
%td
-
if
layer
=
tag
.
layers
.
first
%span
.has-tooltip
(
title=
"#{layer.revision}"
)
=
layer
.
short_revision
-
else
\-
%td
=
number_to_human_size
(
tag
.
total_size
)
·
=
pluralize
(
tag
.
layers
.
size
,
"layer"
)
%td
=
time_ago_in_words
(
tag
.
created_at
)
%td
.content
.controls.hidden-xs.pull-right
=
link_to
namespace_project_container_registry_path
(
@project
.
namespace
,
@project
,
tag
.
name
),
class:
'btn btn-remove has-tooltip'
,
title:
"Remove"
,
data:
{
confirm:
"Are you sure?"
},
method: :delete
do
=
icon
(
"trash cred"
)
app/views/projects/container_registry/index.html.haml
浏览文件 @
d05f0030
...
...
@@ -26,7 +26,7 @@
-
else
.table-holder
%table
.table.
build
s
%table
.table.
tag
s
%thead
%tr
%th
Name
...
...
@@ -36,23 +36,4 @@
%th
-
@tags
.
each
do
|
tag
|
%tr
%td
=
escape_once
(
tag
.
name
)
=
clipboard_button
(
clipboard_text:
"docker pull
#{
tag
.
path
}
"
)
%td
-
if
layer
=
tag
.
layers
.
first
%span
.has-tooltip
(
title=
"#{layer.revision}"
)
=
layer
.
short_revision
-
else
\-
%td
=
number_to_human_size
(
tag
.
total_size
)
·
=
pluralize
(
tag
.
layers
.
size
,
"layer"
)
%td
=
time_ago_in_words
(
tag
.
created_at
)
%td
.content
.controls.hidden-xs.pull-right
=
link_to
namespace_project_container_registry_path
(
@project
.
namespace
,
@project
,
tag
.
name
),
class:
'btn btn-remove has-tooltip'
,
title:
"Remove"
,
data:
{
confirm:
"Are you sure?"
},
method: :delete
do
=
icon
(
"trash cred"
)
=
render
'tag'
,
tag:
tag
\ No newline at end of file
lib/container_registry/client.rb
浏览文件 @
d05f0030
...
...
@@ -10,7 +10,7 @@ module ContainerRegistry
def
initialize
(
base_uri
,
options
=
{})
@base_uri
=
base_uri
@faraday
=
Faraday
.
new
(
@base_uri
)
do
|
conn
|
initialize_connection
(
conn
)
initialize_connection
(
conn
,
options
)
end
end
...
...
@@ -51,7 +51,7 @@ module ContainerRegistry
private
def
initialize_connection
(
conn
)
def
initialize_connection
(
conn
,
options
)
conn
.
request
:json
conn
.
headers
[
'Accept'
]
=
MANIFEST_VERSION
...
...
spec/features/container_registry_spec.rb
0 → 100644
浏览文件 @
d05f0030
require
'spec_helper'
describe
"Container Registry"
do
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:repository
)
{
project
.
container_registry_repository
}
let
(
:tag_name
)
{
'latest'
}
let
(
:tags
)
{
[
tag_name
]
}
before
do
end
before
do
login_as
(
:user
)
project
.
team
<<
[
@user
,
:developer
]
stub_container_registry
(
*
tags
)
end
describe
'GET /:project/container_registry'
do
before
do
visit
namespace_project_container_registry_index_path
(
project
.
namespace
,
project
)
end
context
'when no tags'
do
let
(
:tags
)
{
[]
}
it
{
expect
(
page
).
to
have_content
(
'No images in Container Registry for this project'
)
}
end
context
'when there are tags'
do
it
{
expect
(
page
).
to
have_content
(
tag_name
)}
end
end
describe
'DELETE /:project/container_registry/tag'
do
before
do
visit
namespace_project_container_registry_index_path
(
project
.
namespace
,
project
)
end
it
do
expect_any_instance_of
(
::
ContainerRegistry
::
Tag
).
to
receive
(
:delete
).
and_return
(
true
)
click_on
'Remove'
end
end
end
\ No newline at end of file
spec/fixtures/container_registry/config_blob.json
0 → 100644
浏览文件 @
d05f0030
{
"architecture"
:
"amd64"
,
"config"
:{
"Hostname"
:
"b14cd8298755"
,
"Domainname"
:
""
,
"User"
:
""
,
"AttachStdin"
:
false
,
"AttachStdout"
:
false
,
"AttachStderr"
:
false
,
"Tty"
:
false
,
"OpenStdin"
:
false
,
"StdinOnce"
:
false
,
"Env"
:
null
,
"Cmd"
:
null
,
"Image"
:
""
,
"Volumes"
:
null
,
"WorkingDir"
:
""
,
"Entrypoint"
:
null
,
"OnBuild"
:
null
,
"Labels"
:
null
},
"container"
:
"b14cd82987550b01af9a666a2f4c996280a6152e66873134fae5a0f223dc5976"
,
"container_config"
:{
"Hostname"
:
"b14cd8298755"
,
"Domainname"
:
""
,
"User"
:
""
,
"AttachStdin"
:
false
,
"AttachStdout"
:
false
,
"AttachStderr"
:
false
,
"Tty"
:
false
,
"OpenStdin"
:
false
,
"StdinOnce"
:
false
,
"Env"
:
null
,
"Cmd"
:[
"/bin/sh"
,
"-c"
,
"#(nop) ADD file:033ab063740d9ff4dcfb1c69eccf25f91d88729f57cd5a73050e014e3e094aa0 in /"
],
"Image"
:
""
,
"Volumes"
:
null
,
"WorkingDir"
:
""
,
"Entrypoint"
:
null
,
"OnBuild"
:
null
,
"Labels"
:
null
},
"created"
:
"2016-04-01T20:53:00.160300546Z"
,
"docker_version"
:
"1.9.1"
,
"history"
:[{
"created"
:
"2016-04-01T20:53:00.160300546Z"
,
"created_by"
:
"/bin/sh -c #(nop) ADD file:033ab063740d9ff4dcfb1c69eccf25f91d88729f57cd5a73050e014e3e094aa0 in /"
}],
"os"
:
"linux"
,
"rootfs"
:{
"type"
:
"layers"
,
"diff_ids"
:[
"sha256:c56b7dabbc7aa730eeab07668bdcbd7e3d40855047ca9a0cc1bfed23a2486111"
]}}
spec/fixtures/container_registry/tag_manifest.json
0 → 100644
浏览文件 @
d05f0030
{
"schemaVersion"
:
2
,
"mediaType"
:
"application/vnd.docker.distribution.manifest.v2+json"
,
"config"
:{
"mediaType"
:
"application/octet-stream"
,
"size"
:
1145
,
"digest"
:
"sha256:d7a513a663c1a6dcdba9ed832ca53c02ac2af0c333322cd6ca92936d1d9917ac"
},
"layers"
:[{
"mediaType"
:
"application/vnd.docker.image.rootfs.diff.tar.gzip"
,
"size"
:
2319870
,
"digest"
:
"sha256:420890c9e918b6668faaedd9000e220190f2493b0693ee563ebd7b4cc754a57d"
}]}
spec/support/stub_gitlab_calls.rb
浏览文件 @
d05f0030
...
...
@@ -25,6 +25,18 @@ module StubGitlabCalls
allow_any_instance_of
(
Project
).
to
receive
(
:builds_enabled?
).
and_return
(
false
)
end
def
stub_container_registry
(
*
tags
)
allow_any_instance_of
(
ContainerRegistry
::
Client
).
to
receive
(
:repository_tags
).
and_return
(
{
"tags"
=>
tags
}
)
allow_any_instance_of
(
ContainerRegistry
::
Client
).
to
receive
(
:repository_manifest
).
and_return
(
JSON
.
load
(
File
.
read
(
Rails
.
root
+
'spec/fixtures/container_registry/tag_manifest.json'
))
)
allow_any_instance_of
(
ContainerRegistry
::
Client
).
to
receive
(
:blob
).
and_return
(
File
.
read
(
Rails
.
root
+
'spec/fixtures/container_registry/config_blob.json'
)
)
end
private
def
gitlab_url
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录