Skip to content
This repository has been archived by the owner on Jun 13, 2021. It is now read-only.

Fix handling short id in docker app commands #717

Merged
merged 2 commits into from
Oct 30, 2019

Conversation

jcsirot
Copy link
Contributor

@jcsirot jcsirot commented Oct 28, 2019

- What I did
This PR add the possibility to use short id in docker app commands (app image tag , app image remove, app run...)

- How I did it
The bundle store interface now exposes a LookUp function which convert a string (an id, short id, tagged or digested reference) into a reference.Reference object if it exists in the store. A map of ID to []reference.Reference is also maintained by the bundle store implementation.

- How to verify it
Some unit tests and e2e tests have been added

- A picture of a cute animal (not mandatory but encouraged)

7702124

Signed-off-by: Jean-Christophe Sirot <jean-christophe.sirot@docker.com>
@codecov
Copy link

codecov bot commented Oct 28, 2019

Codecov Report

Merging #717 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #717   +/-   ##
=======================================
  Coverage   72.45%   72.45%           
=======================================
  Files          59       59           
  Lines        3438     3438           
=======================================
  Hits         2491     2491           
  Misses        612      612           
  Partials      335      335

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6267dc4...280f562. Read the comment docs.

internal/store/bundle.go Outdated Show resolved Hide resolved
internal/cnab/cnab.go Outdated Show resolved Hide resolved
internal/cnab/cnab.go Outdated Show resolved Hide resolved
internal/store/app.go Outdated Show resolved Hide resolved
internal/store/bundle.go Outdated Show resolved Hide resolved
internal/store/bundle.go Outdated Show resolved Hide resolved
@jcsirot jcsirot force-pushed the fix-handling-short-id branch 4 times, most recently from 015dc6d to 7fa7cc7 Compare October 29, 2019 10:28
@jcsirot jcsirot requested review from rumpl and eunomie October 29, 2019 15:31
e2e/images_test.go Outdated Show resolved Hide resolved
var (
identifierRegexp = regexp.MustCompile(`^([a-f0-9]{64})$`)

shortIdentifierRegexp = regexp.MustCompile(`^([a-f0-9]{1,64})$`)
Copy link
Contributor

Choose a reason for hiding this comment

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

Only one character looks a little bit short, isn't it too widely open?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems that docker image inspect x works if you have only 1 image whose id is starting with x

if err != nil {
return nil, errors.Wrapf(err, "failed to read bundle %q", ref)
}

data, err := ioutil.ReadFile(filepath.Join(path, "bundle.json"))
bndl, err := b.fetchBundleJSON(filepath.Join(paths[0], "bundle.json"))
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens to other paths here? Is it worth it returning all the paths if we only use the first (and I guess it has to be the id path?

Copy link
Member

@chris-crone chris-crone left a comment

Choose a reason for hiding this comment

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

LGTM with a couple of nits

internal/cnab/cnab.go Outdated Show resolved Hide resolved
internal/cnab/cnab.go Outdated Show resolved Hide resolved
internal/commands/image/tag.go Outdated Show resolved Hide resolved
…le store. Now the bundle store scans the bundle directory and creates a map of existing bundle references. All subsequent operations on the bundle store are using this map as the reference for stored bundle.

Signed-off-by: Jean-Christophe Sirot <jean-christophe.sirot@docker.com>
@jcsirot jcsirot merged commit cbf819c into docker:master Oct 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants