Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Image size and mod timestamp #6

Open
calh opened this issue Nov 10, 2016 · 3 comments
Open

Feature request: Image size and mod timestamp #6

calh opened this issue Nov 10, 2016 · 3 comments

Comments

@calh
Copy link

calh commented Nov 10, 2016

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!

@deitch
Copy link
Owner

deitch commented Nov 10, 2016

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?

@calh
Copy link
Author

calh commented Nov 11, 2016

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

@deitch
Copy link
Owner

deitch commented Mar 26, 2017

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants