Open calh opened 7 years ago
Can you add in a method to sum up the sizes from each of the blobs from an image tag? (Using the API HEAD call to /v2/#{image}/blobs/#{blobSum})
Been a bit since I worked on the manifests, so can you explain how this is used? No issues with it, but always want to understand the use case.
Also, it would be nice to have a convenience method to run through the v1Compatibility elements, find the most recent, and return a Time object that represents the tag's upload time.
Hmm, again, what is the use case?
My use case is that I'm writing a backup script to stuff my older images into S3 storage. I want to pull accurate timestamps in order to implement algorithms like "keep the past 7 days". I also want to check sizes so that I can verify that a backup currently exists in S3, and has a size that's close to the size of the tag in my local repo.
On a side note, I already implemented this in my wrapper class, it'd just be nice to have in the gem:
def pull_manifest(tag)
ret = @registry.manifest(@image, tag)
size=0
ret["fsLayers"].each do |layer|
sum=layer["blobSum"]
size += blob_size(sum)
end
times = []
ret["history"].each do |i|
# Why does this come back as a String from the gem? (should I file a separate bug?)
v1 = JSON.parse( i['v1Compatibility'] )
times << Time.parse( v1['created'] )
end
time = times.sort!.last
end
def blob_size(checksum)
c=Curl::Easy.new
c.url = "https://my-registry//v2/#{image}/blobs/#{checksum}"
c.head = true
c.perform
c.downloaded_content_length
end
Finally coming back to this after a while.
On the first part, no need to ask for the sizes via HEAD, they are in the manifest. Putting it in right now. On the second part, can you explain that? I had thought they had stopped including the v1 compat elements?
Can you add in a method to sum up the sizes from each of the blobs from an image tag? (Using the API HEAD call to
/v2/#{image}/blobs/#{blobSum}
)Also, it would be nice to have a convenience method to run through the
v1Compatibility
elements, find the most recent, and return a Time object that represents the tag's upload time.Thank you!