Skip to content

Add Inspect image#239

Merged
AkihiroSuda merged 2 commits intocontainerd:masterfrom
fahedouch:inspect-image
Jun 19, 2021
Merged

Add Inspect image#239
AkihiroSuda merged 2 commits intocontainerd:masterfrom
fahedouch:inspect-image

Conversation

@fahedouch
Copy link
Copy Markdown
Member

same as docker image inspect and docker inspect

related ticket #222

@fahedouch fahedouch marked this pull request as draft June 4, 2021 17:07
@fahedouch fahedouch changed the title Inspect image Add Inspect image Jun 4, 2021
@fahedouch fahedouch changed the title Add Inspect image [WIP] Add Inspect image Jun 4, 2021
@fahedouch fahedouch marked this pull request as ready for review June 9, 2021 14:58
@fahedouch fahedouch changed the title [WIP] Add Inspect image Add Inspect image Jun 10, 2021
@fahedouch fahedouch force-pushed the inspect-image branch 2 times, most recently from bfa9d38 to 4d8a1c7 Compare June 10, 2021 17:24
Comment thread image_inspect_test.go
Comment thread inspect.go Outdated
Comment thread inspect.go Outdated
Comment thread inspect.go Outdated
Comment thread pkg/inspecttypes/native/image.go Outdated
// Not compatible with `docker image inspect`.
type Image struct {
images.Image
ImageSpec interface{} `json:"Image"`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why interface{}?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

also json:"ImageSpec"

Copy link
Copy Markdown
Member Author

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

Copy link
Copy Markdown
Member

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?

Copy link
Copy Markdown
Member Author

@fahedouch fahedouch Jun 15, 2021

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

Comment thread image_inspect.go Outdated
defaultBashComplete(clicontext)
return
}
// show container names
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

s/container/image/

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

fixed

Comment thread inspect.go Outdated
}

if ni != 0 && nc != 0 {
return errors.Errorf("Multiple IDs found with provided prefix: %s", req)
Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Member Author

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()}
Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Member Author

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, "")})
Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I let you check :)

Comment thread pkg/imageinspector/imageinspector.go Outdated
}

n.Descriptor = config
n.Image.Name = image.Name
Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

fixed

@fahedouch fahedouch force-pushed the inspect-image branch 4 times, most recently from b53f984 to 5e4b918 Compare June 16, 2021 13:34
Comment thread pkg/imgutil/imgutil.go
}

var tag string
nameWithTagSplit := strings.Split(imgName, ":")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

@AkihiroSuda AkihiroSuda Jun 17, 2021

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)

Comment thread pkg/imgutil/imgutil.go
}
repository := strings.TrimSuffix(imgName, ":"+tag)
repository = strings.TrimPrefix(repository, "docker.io/library/")
repository = strings.TrimPrefix(repository, "docker.io/")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member Author

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!

@AkihiroSuda
Copy link
Copy Markdown
Member

As usual, please squash commits

@fahedouch fahedouch force-pushed the inspect-image branch 3 times, most recently from dc52fd7 to be8d9a0 Compare June 17, 2021 10:19
Signed-off-by: fahed dorgaa <[email protected]>
@AkihiroSuda
Copy link
Copy Markdown
Member

AkihiroSuda commented Jun 19, 2021

Added commit bcd29a7

Copy link
Copy Markdown
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

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

Thanks

@AkihiroSuda AkihiroSuda merged commit 1b4635a into containerd:master Jun 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants