Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
gitlab-ce
Commits
a82109ee
Commit
a82109ee
authored
May 17, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add .gitkeep
parent
ac6992ba
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
48 additions
and
2 deletions
+48
-2
lib/container_registry/config.rb
lib/container_registry/config.rb
+1
-0
lib/container_registry/registry.rb
lib/container_registry/registry.rb
+8
-2
lib/container_registry/repository.rb
lib/container_registry/repository.rb
+1
-0
lib/container_registry/tag.rb
lib/container_registry/tag.rb
+10
-0
shared/registry/.gitkeep
shared/registry/.gitkeep
+0
-0
spec/lib/container_registry/registry_spec.rb
spec/lib/container_registry/registry_spec.rb
+28
-0
No files found.
lib/container_registry/config.rb
View file @
a82109ee
...
@@ -9,6 +9,7 @@ module ContainerRegistry
...
@@ -9,6 +9,7 @@ module ContainerRegistry
def
[]
(
key
)
def
[]
(
key
)
return
unless
data
return
unless
data
data
[
key
]
data
[
key
]
end
end
end
end
...
...
lib/container_registry/registry.rb
View file @
a82109ee
...
@@ -3,13 +3,19 @@ module ContainerRegistry
...
@@ -3,13 +3,19 @@ module ContainerRegistry
attr_reader
:uri
,
:client
,
:path
attr_reader
:uri
,
:client
,
:path
def
initialize
(
uri
,
options
=
{})
def
initialize
(
uri
,
options
=
{})
@
path
=
options
[
:path
]
||
uri
@
uri
=
uri
@
uri
=
URI
.
parse
(
uri
)
@
path
=
options
[
:path
]
||
default_path
@client
=
ContainerRegistry
::
Client
.
new
(
uri
,
options
)
@client
=
ContainerRegistry
::
Client
.
new
(
uri
,
options
)
end
end
def
[]
(
name
)
def
[]
(
name
)
ContainerRegistry
::
Repository
.
new
(
self
,
name
)
ContainerRegistry
::
Repository
.
new
(
self
,
name
)
end
end
private
def
default_path
@uri
.
sub
(
/^https?:\/\//
,
''
)
end
end
end
end
end
lib/container_registry/repository.rb
View file @
a82109ee
...
@@ -20,6 +20,7 @@ module ContainerRegistry
...
@@ -20,6 +20,7 @@ module ContainerRegistry
def
manifest
def
manifest
return
@manifest
if
defined?
(
@manifest
)
return
@manifest
if
defined?
(
@manifest
)
@manifest
=
client
.
repository_tags
(
name
)
@manifest
=
client
.
repository_tags
(
name
)
end
end
...
...
lib/container_registry/tag.rb
View file @
a82109ee
...
@@ -12,6 +12,7 @@ module ContainerRegistry
...
@@ -12,6 +12,7 @@ module ContainerRegistry
def
manifest
def
manifest
return
@manifest
if
defined?
(
@manifest
)
return
@manifest
if
defined?
(
@manifest
)
@manifest
=
client
.
repository_manifest
(
repository
.
name
,
name
)
@manifest
=
client
.
repository_manifest
(
repository
.
name
,
name
)
end
end
...
@@ -21,33 +22,39 @@ module ContainerRegistry
...
@@ -21,33 +22,39 @@ module ContainerRegistry
def
[]
(
key
)
def
[]
(
key
)
return
unless
manifest
return
unless
manifest
manifest
[
key
]
manifest
[
key
]
end
end
def
digest
def
digest
return
@digest
if
defined?
(
@digest
)
return
@digest
if
defined?
(
@digest
)
@digest
=
client
.
repository_tag_digest
(
repository
.
name
,
name
)
@digest
=
client
.
repository_tag_digest
(
repository
.
name
,
name
)
end
end
def
config_blob
def
config_blob
return
@config_blob
if
defined?
(
@config_blob
)
return
@config_blob
if
defined?
(
@config_blob
)
return
unless
manifest
&&
manifest
[
'config'
]
return
unless
manifest
&&
manifest
[
'config'
]
@config_blob
=
ContainerRegistry
::
Blob
.
new
(
repository
,
manifest
[
'config'
])
@config_blob
=
ContainerRegistry
::
Blob
.
new
(
repository
,
manifest
[
'config'
])
end
end
def
config
def
config
return
unless
config_blob
return
unless
config_blob
@config
||=
ContainerRegistry
::
Config
.
new
(
self
,
config_blob
)
@config
||=
ContainerRegistry
::
Config
.
new
(
self
,
config_blob
)
end
end
def
created_at
def
created_at
return
unless
config
return
unless
config
@created_at
||=
DateTime
.
rfc3339
(
config
[
'created'
])
@created_at
||=
DateTime
.
rfc3339
(
config
[
'created'
])
end
end
def
layers
def
layers
return
@layers
if
defined?
(
@layers
)
return
@layers
if
defined?
(
@layers
)
return
unless
manifest
return
unless
manifest
@layers
=
manifest
[
'layers'
].
map
do
|
layer
|
@layers
=
manifest
[
'layers'
].
map
do
|
layer
|
ContainerRegistry
::
Blob
.
new
(
repository
,
layer
)
ContainerRegistry
::
Blob
.
new
(
repository
,
layer
)
end
end
...
@@ -55,16 +62,19 @@ module ContainerRegistry
...
@@ -55,16 +62,19 @@ module ContainerRegistry
def
total_size
def
total_size
return
unless
layers
return
unless
layers
layers
.
map
(
&
:size
).
sum
layers
.
map
(
&
:size
).
sum
end
end
def
delete
def
delete
return
unless
digest
return
unless
digest
client
.
delete_repository_tag
(
repository
.
name
,
digest
)
client
.
delete_repository_tag
(
repository
.
name
,
digest
)
end
end
def
copy_to
(
repository
)
def
copy_to
(
repository
)
return
unless
manifest
return
unless
manifest
layers
.
each
do
|
blob
|
layers
.
each
do
|
blob
|
repository
.
mount_blob
(
blob
)
repository
.
mount_blob
(
blob
)
end
end
...
...
shared/registry/.gitkeep
0 → 100644
View file @
a82109ee
spec/lib/container_registry/registry_spec.rb
0 → 100644
View file @
a82109ee
require
'spec_helper'
describe
ContainerRegistry
::
Registry
do
let
(
:path
)
{
nil
}
let
(
:registry
)
{
described_class
.
new
(
'http://example.com'
,
path:
path
)
}
subject
{
registry
}
it
{
is_expected
.
to
respond_to
(
:client
)
}
it
{
is_expected
.
to
respond_to
(
:uri
)
}
it
{
is_expected
.
to
respond_to
(
:path
)
}
it
{
expect
(
subject
[
'test'
]).
to_not
be_nil
}
context
'#path'
do
subject
{
registry
.
path
}
context
'path from URL'
do
it
{
is_expected
.
to
eq
(
'example.com'
)
}
end
context
'custom path'
do
let
(
:path
)
{
'registry.example.com'
}
it
{
is_expected
.
to
eq
(
path
)
}
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment