Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Add ListImages summary fields #1084

Merged
merged 7 commits into from
May 21, 2018
Merged

Add ListImages summary fields #1084

merged 7 commits into from
May 21, 2018

Conversation

aaron7
Copy link
Contributor

@aaron7 aaron7 commented May 17, 2018

Part of #913 to allow a HTTP client to receive image summary information instead of fetching all of the images.

  • Creates new fields in containers:

    • LatestFiltered - image.Info for the latest image
    • AvailableImagesCount - count of all available images
    • NewAvailableImagesCount - count of all new available images
    • FilteredImagesCount - count of all images after tag filter
    • NewFilteredImagesCount - count of all new images after tag filter
  • Allows specifiying which containerFields to return in the response via a ?containerFields=... query parameter

    • e.g. images?containerFields=Name,Current,AvailableImagesCount
  • Refactors some of the variable names around image fetching to make it clearer what is happening (image repo stuff)

  • Changes ListImages interface and so we will have to update this in WC service

  • Don't require queryParams like ?service= - defaults to <all>

@aaron7 aaron7 changed the title [WIP] Images summary fields Add ListImages summary fields May 17, 2018
@aaron7 aaron7 requested a review from squaremo May 17, 2018 15:51
Copy link
Member

@squaremo squaremo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some typos, and some opportunities to reduce the code a bit.

@@ -18,17 +18,17 @@ func (d *Daemon) pollForNewImages(logger log.Logger) {

ctx := context.Background()

candidateServices, err := d.unlockedAutomatedServices(ctx)
candidateServicesPolicyMap, err := d.getUnlockedAutomatedServicesPolicyMap(ctx)

This comment was marked as abuse.

This comment was marked as abuse.

update/images.go Outdated
@@ -21,14 +21,40 @@ type ImageRepos struct {
imageRepos imageReposMap
}

// LatestImage returns the latest releasable image for a repository
// FindImageInfo retruns image.Info given an image ref. If the image cannot be

This comment was marked as abuse.

update/images.go Outdated
@@ -21,14 +21,40 @@ type ImageRepos struct {
imageRepos imageReposMap
}

// LatestImage returns the latest releasable image for a repository
// FindImageInfo retruns image.Info given an image ref. If the image cannot be
// found, return the image.Info with only rhe ID.

This comment was marked as abuse.

update/images.go Outdated
return image.Info{}, false
}

// FilteredAvailable returns image.Info engtries for all the images in the

This comment was marked as abuse.

update/images.go Outdated
}

// FilteredAvailable returns image.Info engtries for all the images in the
// names image repository which match the tagGlob.

This comment was marked as abuse.

update/images.go Outdated

// FilteredAvailable returns image.Info engtries for all the images in the
// names image repository which match the tagGlob.
func (r ImageRepos) FilteredAvailable(repo image.Name, tagGlob string) []image.Info {

This comment was marked as abuse.

daemon/daemon.go Outdated
FilteredImagesCount: filteredImagesCount,
NewFilteredImagesCount: newFilteredImagesCount,
})
if _, ok := fields["Name"]; ok {

This comment was marked as abuse.

@@ -225,16 +225,16 @@ func (i Ref) WithNewTag(t string) Ref {
// from its registry.
type Info struct {
// the reference to this image; probably a tagged image name
ID Ref
ID Ref `json:",omitempty"`

This comment was marked as abuse.

daemon/daemon.go Outdated
@@ -544,23 +560,95 @@ func containers2containers(cs []resource.Container) []v6.Container {
return res
}

func containersWithAvailable(service cluster.Controller, images update.ImageMap) (res []v6.Container) {
func getServiceContainers(service cluster.Controller, imageRepos update.ImageRepos, policyResourceMap policy.ResourceMap, overrideFields []string) (res []v6.Container, err error) {
fields := map[string]struct{}{

This comment was marked as abuse.

update/images.go Outdated
// for which the tag matches a given pattern. A releasable image is
// one that is not tagged "latest". (Assumes the available images are
// in descending order of latestness.) If no such image exists,
// returns a zero value and `false`, and the caller can decide whether
// that's an error or not.
func (m ImageMap) LatestImage(repo image.Name, tagGlob string) (image.Info, bool) {
for _, available := range m.images[repo.CanonicalName()] {
func (r ImageRepos) LatestFilteredImage(repo image.Name, tagGlob string) (image.Info, bool) {

This comment was marked as abuse.

@aaron7 aaron7 requested a review from squaremo May 18, 2018 18:29
@squaremo
Copy link
Member

Nice work Aaron ⭐ I'm rerun the failing CI, which failed for a silly reason.

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

Successfully merging this pull request may close these issues.

2 participants