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

Add Inspect image #239

Merged
merged 2 commits into from
Jun 19, 2021
Merged

Add Inspect image #239

merged 2 commits into from
Jun 19, 2021

Conversation

fahedouch
Copy link
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
inspect.go Outdated Show resolved Hide resolved
inspect.go Outdated Show resolved Hide resolved
inspect.go Outdated Show resolved Hide resolved
// Not compatible with `docker image inspect`.
type Image struct {
images.Image
ImageSpec interface{} `json:"Image"`
Copy link
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
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
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
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
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

image_inspect.go Outdated
defaultBashComplete(clicontext)
return
}
// show container names
Copy link
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
Member Author

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)
Copy link
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
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
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
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
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
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 :)

}

n.Descriptor = config
n.Image.Name = image.Name
Copy link
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
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
}

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

Choose a reason for hiding this comment

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

Copy link
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)

}
repository := strings.TrimSuffix(imgName, ":"+tag)
repository = strings.TrimPrefix(repository, "docker.io/library/")
repository = strings.TrimPrefix(repository, "docker.io/")
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
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
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 <fahed.dorgaa@gmail.com>
@AkihiroSuda
Copy link
Member

AkihiroSuda commented Jun 19, 2021

Added commit bcd29a7

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
Copy link
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