-
Notifications
You must be signed in to change notification settings - Fork 595
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
Add Inspect image #239
Add Inspect image #239
Conversation
bfa9d38
to
4d8a1c7
Compare
pkg/inspecttypes/native/image.go
Outdated
// Not compatible with `docker image inspect`. | ||
type Image struct { | ||
images.Image | ||
ImageSpec interface{} `json:"Image"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why interface{}
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also json:"ImageSpec"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AkihiroSuda interface{}
. because i want to avoid using the ocispec.Image
in this native containerd object
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you want to avoid it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks cleaner if i use an interface here and map this interface to ocispec.Image
in dockercompat may be I'm wrong. Anyway I made the change
image_inspect.go
Outdated
defaultBashComplete(clicontext) | ||
return | ||
} | ||
// show container names |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/container/image/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
inspect.go
Outdated
} | ||
|
||
if ni != 0 && nc != 0 { | ||
return errors.Errorf("Multiple IDs found with provided prefix: %s", req) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error should start with a lower char
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
|
||
i.ID = n.Descriptor.Digest.String() | ||
|
||
s := []string{n.Image.Name, "@", n.Image.Target.Digest.String()} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not use fmt.Sprintf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
i.ID = n.Descriptor.Digest.String() | ||
|
||
s := []string{n.Image.Name, "@", n.Image.Target.Digest.String()} | ||
i.RepoTags, i.RepoDigests = parseImageReferences([]string{strings.Join(s, "")}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already know the digest, no need to "parse" it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I let you check :)
pkg/imageinspector/imageinspector.go
Outdated
} | ||
|
||
n.Descriptor = config | ||
n.Image.Name = image.Name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just set n.Image = image
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
b53f984
to
5e4b918
Compare
} | ||
|
||
var tag string | ||
nameWithTagSplit := strings.Split(imgName, ":") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I noticed that the code is not new in this PR, so this can be done later)
} | ||
repository := strings.TrimSuffix(imgName, ":"+tag) | ||
repository = strings.TrimPrefix(repository, "docker.io/library/") | ||
repository = strings.TrimPrefix(repository, "docker.io/") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same for this, this will be done in new PR!
As usual, please squash commits |
dc52fd7
to
be8d9a0
Compare
Signed-off-by: fahed dorgaa <fahed.dorgaa@gmail.com>
Added commit bcd29a7 |
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
ba1dfc0
to
bcd29a7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
same as
docker image inspect
anddocker inspect
related ticket #222