Inspect inspects the image.
(ctx context.Context, options *InspectOptions)
| 60 | |
| 61 | // Inspect inspects the image. |
| 62 | func (i *Image) Inspect(ctx context.Context, options *InspectOptions) (*ImageData, error) { |
| 63 | logrus.Debugf("Inspecting image %s", i.ID()) |
| 64 | |
| 65 | if options == nil { |
| 66 | options = &InspectOptions{} |
| 67 | } |
| 68 | |
| 69 | if i.cached.completeInspectData != nil { |
| 70 | if options.WithSize && i.cached.completeInspectData.Size == int64(-1) { |
| 71 | size, err := i.Size() |
| 72 | if err != nil { |
| 73 | return nil, err |
| 74 | } |
| 75 | i.cached.completeInspectData.Size = size |
| 76 | } |
| 77 | if options.WithParent && i.cached.completeInspectData.Parent == "" { |
| 78 | parentImage, err := i.Parent(ctx) |
| 79 | if err != nil { |
| 80 | return nil, err |
| 81 | } |
| 82 | if parentImage != nil { |
| 83 | i.cached.completeInspectData.Parent = parentImage.ID() |
| 84 | } |
| 85 | } |
| 86 | return i.cached.completeInspectData, nil |
| 87 | } |
| 88 | |
| 89 | // First assemble data that does not depend on the format of the image. |
| 90 | info, err := i.inspectInfo(ctx) |
| 91 | if err != nil { |
| 92 | return nil, err |
| 93 | } |
| 94 | ociImage, err := i.toOCI(ctx) |
| 95 | if err != nil { |
| 96 | return nil, err |
| 97 | } |
| 98 | |
| 99 | repoTags, err := i.RepoTags() |
| 100 | if err != nil { |
| 101 | return nil, err |
| 102 | } |
| 103 | repoDigests, err := i.RepoDigests() |
| 104 | if err != nil { |
| 105 | return nil, err |
| 106 | } |
| 107 | driverData, err := i.driverData() |
| 108 | if err != nil { |
| 109 | return nil, err |
| 110 | } |
| 111 | |
| 112 | size := int64(-1) |
| 113 | if options.WithSize { |
| 114 | size, err = i.Size() |
| 115 | if err != nil { |
| 116 | return nil, err |
| 117 | } |
| 118 | } |
| 119 |