Class: ContainerRegistry::Tag
Instance Attribute Summary collapse
Instance Method Summary
collapse
#clear_memoization, #strong_memoize, #strong_memoized?
Constructor Details
#initialize(repository, name) ⇒ Tag
Returns a new instance of Tag.
12
13
14
|
# File 'lib/container_registry/tag.rb', line 12
def initialize(repository, name)
@repository, @name = repository, name
end
|
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name
7
8
9
|
# File 'lib/container_registry/tag.rb', line 7
def name
@name
end
|
#repository ⇒ Object
Returns the value of attribute repository
7
8
9
|
# File 'lib/container_registry/tag.rb', line 7
def repository
@repository
end
|
Instance Method Details
#[](key) ⇒ Object
46
47
48
49
50
|
# File 'lib/container_registry/tag.rb', line 46
def [](key)
return unless manifest
manifest[key]
end
|
#config ⇒ Object
66
67
68
69
70
71
72
|
# File 'lib/container_registry/tag.rb', line 66
def config
return unless config_blob&.data
strong_memoize(:config) do
ContainerRegistry::Config.new(self, config_blob)
end
end
|
#config_blob ⇒ Object
58
59
60
61
62
63
64
|
# File 'lib/container_registry/tag.rb', line 58
def config_blob
return unless manifest && manifest['config']
strong_memoize(:config_blob) do
repository.blob(manifest['config'])
end
end
|
#created_at ⇒ Object
74
75
76
77
78
79
80
81
82
|
# File 'lib/container_registry/tag.rb', line 74
def created_at
return unless config
strong_memoize(:created_at) do
DateTime.rfc3339(config['created'])
rescue ArgumentError
nil
end
end
|
#digest ⇒ Object
52
53
54
55
56
|
# File 'lib/container_registry/tag.rb', line 52
def digest
strong_memoize(:digest) do
client.repository_tag_digest(repository.path, name)
end
end
|
#latest? ⇒ Boolean
20
21
22
|
# File 'lib/container_registry/tag.rb', line 20
def latest?
name == "latest"
end
|
#layers ⇒ Object
84
85
86
87
88
89
90
91
92
93
94
|
# File 'lib/container_registry/tag.rb', line 84
def layers
return unless manifest
strong_memoize(:layers) do
layers = manifest['layers'] || manifest['fsLayers']
layers.map do |layer|
repository.blob(layer)
end
end
end
|
#location ⇒ Object
42
43
44
|
# File 'lib/container_registry/tag.rb', line 42
def location
"#{repository.location}:#{name}"
end
|
#manifest ⇒ Object
32
33
34
35
36
|
# File 'lib/container_registry/tag.rb', line 32
def manifest
strong_memoize(:manifest) do
client.repository_manifest(repository.path, name)
end
end
|
#path ⇒ Object
38
39
40
|
# File 'lib/container_registry/tag.rb', line 38
def path
"#{repository.path}:#{name}"
end
|
#put(digests) ⇒ Object
96
97
98
|
# File 'lib/container_registry/tag.rb', line 96
def put(digests)
repository.client.put_tag(repository.path, name, digests)
end
|
#total_size ⇒ Object
rubocop: disable CodeReuse/ActiveRecord
101
102
103
104
105
|
# File 'lib/container_registry/tag.rb', line 101
def total_size
return unless layers
layers.map(&:size).sum if v2?
end
|
#unsafe_delete ⇒ Object
Deletes the image associated with this tag Note this will delete the image and all tags associated with it. Consider using DeleteTagsService instead.
111
112
113
114
115
|
# File 'lib/container_registry/tag.rb', line 111
def unsafe_delete
return unless digest
client.delete_repository_tag_by_digest(repository.path, digest)
end
|
#v1? ⇒ Boolean
24
25
26
|
# File 'lib/container_registry/tag.rb', line 24
def v1?
manifest && manifest['schemaVersion'] == 1
end
|
#v2? ⇒ Boolean
28
29
30
|
# File 'lib/container_registry/tag.rb', line 28
def v2?
manifest && manifest['schemaVersion'] == 2
end
|
#valid? ⇒ Boolean
16
17
18
|
# File 'lib/container_registry/tag.rb', line 16
def valid?
manifest.present?
end
|