diff options
author | Jhon Honce <jhonce@redhat.com> | 2020-04-02 15:58:23 -0700 |
---|---|---|
committer | Jhon Honce <jhonce@redhat.com> | 2020-04-07 19:22:10 -0700 |
commit | e0847f5457edfdeb17dad259f1cd06b1d4cec93e (patch) | |
tree | 157f89a3172892a83b7c8515b0991d806f4c159e /pkg/varlinkapi/images.go | |
parent | b4840ec0d34bd679faefe06ce52ee6cebcb8f0b5 (diff) | |
download | podman-e0847f5457edfdeb17dad259f1cd06b1d4cec93e.tar.gz podman-e0847f5457edfdeb17dad259f1cd06b1d4cec93e.tar.bz2 podman-e0847f5457edfdeb17dad259f1cd06b1d4cec93e.zip |
V2 podman system service
* Added support for system service
* Enabled linting on the varlinkapi source, needed to support V2
service command
* Added support for PODMAN_SOCKET
Skip linting deprecated code
Rather than introduce bugs by correcting deprecated code, linting the
code is being skipped. Code that is being ported into V2 is being
checked.
Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'pkg/varlinkapi/images.go')
-rw-r--r-- | pkg/varlinkapi/images.go | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/pkg/varlinkapi/images.go b/pkg/varlinkapi/images.go index c3b4bd9ae..49bd0b0cb 100644 --- a/pkg/varlinkapi/images.go +++ b/pkg/varlinkapi/images.go @@ -35,14 +35,14 @@ import ( ) // ListImagesWithFilters returns a list of images that have been filtered -func (i *LibpodAPI) ListImagesWithFilters(call iopodman.VarlinkCall, filters []string) error { +func (i *VarlinkAPI) ListImagesWithFilters(call iopodman.VarlinkCall, filters []string) error { images, err := i.Runtime.ImageRuntime().GetImagesWithFilters(filters) if err != nil { return call.ReplyErrorOccurred(fmt.Sprintf("unable to get list of images %q", err)) } imageList, err := imagesToImageList(images) if err != nil { - return call.ReplyErrorOccurred(fmt.Sprintf("unable to parse response", err)) + return call.ReplyErrorOccurred("unable to parse response " + err.Error()) } return call.ReplyListImagesWithFilters(imageList) } @@ -50,34 +50,34 @@ func (i *LibpodAPI) ListImagesWithFilters(call iopodman.VarlinkCall, filters []s // imagesToImageList converts a slice of Images to an imagelist for varlink responses func imagesToImageList(images []*image.Image) ([]iopodman.Image, error) { var imageList []iopodman.Image - for _, image := range images { - labels, _ := image.Labels(getContext()) - containers, _ := image.Containers() - repoDigests, err := image.RepoDigests() + for _, img := range images { + labels, _ := img.Labels(getContext()) + containers, _ := img.Containers() + repoDigests, err := img.RepoDigests() if err != nil { return nil, err } - size, _ := image.Size(getContext()) - isParent, err := image.IsParent(context.TODO()) + size, _ := img.Size(getContext()) + isParent, err := img.IsParent(context.TODO()) if err != nil { return nil, err } i := iopodman.Image{ - Id: image.ID(), - Digest: string(image.Digest()), - ParentId: image.Parent, - RepoTags: image.Names(), + Id: img.ID(), + Digest: string(img.Digest()), + ParentId: img.Parent, + RepoTags: img.Names(), RepoDigests: repoDigests, - Created: image.Created().Format(time.RFC3339), + Created: img.Created().Format(time.RFC3339), Size: int64(*size), - VirtualSize: image.VirtualSize, + VirtualSize: img.VirtualSize, Containers: int64(len(containers)), Labels: labels, IsParent: isParent, - ReadOnly: image.IsReadOnly(), - History: image.NamesHistory(), + ReadOnly: img.IsReadOnly(), + History: img.NamesHistory(), } imageList = append(imageList, i) } @@ -86,20 +86,20 @@ func imagesToImageList(images []*image.Image) ([]iopodman.Image, error) { // ListImages lists all the images in the store // It requires no inputs. -func (i *LibpodAPI) ListImages(call iopodman.VarlinkCall) error { +func (i *VarlinkAPI) ListImages(call iopodman.VarlinkCall) error { images, err := i.Runtime.ImageRuntime().GetImages() if err != nil { - return call.ReplyErrorOccurred(fmt.Sprintf("unable to get list of images %q", err)) + return call.ReplyErrorOccurred("unable to get list of images " + err.Error()) } imageList, err := imagesToImageList(images) if err != nil { - return call.ReplyErrorOccurred(fmt.Sprintf("unable to parse response", err)) + return call.ReplyErrorOccurred("unable to parse response " + err.Error()) } return call.ReplyListImages(imageList) } // GetImage returns a single image in the form of a Image -func (i *LibpodAPI) GetImage(call iopodman.VarlinkCall, id string) error { +func (i *VarlinkAPI) GetImage(call iopodman.VarlinkCall, id string) error { newImage, err := i.Runtime.ImageRuntime().NewFromLocal(id) if err != nil { return call.ReplyImageNotFound(id, err.Error()) @@ -139,7 +139,7 @@ func (i *LibpodAPI) GetImage(call iopodman.VarlinkCall, id string) error { } // BuildImage ... -func (i *LibpodAPI) BuildImage(call iopodman.VarlinkCall, config iopodman.BuildInfo) error { +func (i *VarlinkAPI) BuildImage(call iopodman.VarlinkCall, config iopodman.BuildInfo) error { var ( namespace []buildah.NamespaceOption imageID string @@ -302,7 +302,7 @@ func (i *LibpodAPI) BuildImage(call iopodman.VarlinkCall, config iopodman.BuildI // InspectImage returns an image's inspect information as a string that can be serialized. // Requires an image ID or name -func (i *LibpodAPI) InspectImage(call iopodman.VarlinkCall, name string) error { +func (i *VarlinkAPI) InspectImage(call iopodman.VarlinkCall, name string) error { newImage, err := i.Runtime.ImageRuntime().NewFromLocal(name) if err != nil { return call.ReplyImageNotFound(name, err.Error()) @@ -320,7 +320,7 @@ func (i *LibpodAPI) InspectImage(call iopodman.VarlinkCall, name string) error { // HistoryImage returns the history of the image's layers // Requires an image or name -func (i *LibpodAPI) HistoryImage(call iopodman.VarlinkCall, name string) error { +func (i *VarlinkAPI) HistoryImage(call iopodman.VarlinkCall, name string) error { newImage, err := i.Runtime.ImageRuntime().NewFromLocal(name) if err != nil { return call.ReplyImageNotFound(name, err.Error()) @@ -345,7 +345,7 @@ func (i *LibpodAPI) HistoryImage(call iopodman.VarlinkCall, name string) error { } // PushImage pushes an local image to registry -func (i *LibpodAPI) PushImage(call iopodman.VarlinkCall, name, tag string, compress bool, format string, removeSignatures bool, signBy string) error { +func (i *VarlinkAPI) PushImage(call iopodman.VarlinkCall, name, tag string, compress bool, format string, removeSignatures bool, signBy string) error { var ( manifestType string ) @@ -437,7 +437,7 @@ func (i *LibpodAPI) PushImage(call iopodman.VarlinkCall, name, tag string, compr } // TagImage accepts an image name and tag as strings and tags an image in the local store. -func (i *LibpodAPI) TagImage(call iopodman.VarlinkCall, name, tag string) error { +func (i *VarlinkAPI) TagImage(call iopodman.VarlinkCall, name, tag string) error { newImage, err := i.Runtime.ImageRuntime().NewFromLocal(name) if err != nil { return call.ReplyImageNotFound(name, err.Error()) @@ -449,7 +449,7 @@ func (i *LibpodAPI) TagImage(call iopodman.VarlinkCall, name, tag string) error } // UntagImage accepts an image name and tag as strings and removes the tag from the local store. -func (i *LibpodAPI) UntagImage(call iopodman.VarlinkCall, name, tag string) error { +func (i *VarlinkAPI) UntagImage(call iopodman.VarlinkCall, name, tag string) error { newImage, err := i.Runtime.ImageRuntime().NewFromLocal(name) if err != nil { return call.ReplyImageNotFound(name, err.Error()) @@ -462,7 +462,7 @@ func (i *LibpodAPI) UntagImage(call iopodman.VarlinkCall, name, tag string) erro // RemoveImage accepts a image name or ID as a string and force bool to determine if it should // remove the image even if being used by stopped containers -func (i *LibpodAPI) RemoveImage(call iopodman.VarlinkCall, name string, force bool) error { +func (i *VarlinkAPI) RemoveImage(call iopodman.VarlinkCall, name string, force bool) error { ctx := getContext() newImage, err := i.Runtime.ImageRuntime().NewFromLocal(name) if err != nil { @@ -477,7 +477,7 @@ func (i *LibpodAPI) RemoveImage(call iopodman.VarlinkCall, name string, force bo // RemoveImageWithResponse accepts an image name and force bool. It returns details about what // was done in removeimageresponse struct. -func (i *LibpodAPI) RemoveImageWithResponse(call iopodman.VarlinkCall, name string, force bool) error { +func (i *VarlinkAPI) RemoveImageWithResponse(call iopodman.VarlinkCall, name string, force bool) error { ir := iopodman.RemoveImageResponse{} ctx := getContext() newImage, err := i.Runtime.ImageRuntime().NewFromLocal(name) @@ -495,7 +495,7 @@ func (i *LibpodAPI) RemoveImageWithResponse(call iopodman.VarlinkCall, name stri // SearchImages searches all registries configured in /etc/containers/registries.conf for an image // Requires an image name and a search limit as int -func (i *LibpodAPI) SearchImages(call iopodman.VarlinkCall, query string, limit *int64, filter iopodman.ImageSearchFilter) error { +func (i *VarlinkAPI) SearchImages(call iopodman.VarlinkCall, query string, limit *int64, filter iopodman.ImageSearchFilter) error { // Transform all arguments to proper types first argLimit := 0 argIsOfficial := types.OptionalBoolUndefined @@ -543,7 +543,7 @@ func (i *LibpodAPI) SearchImages(call iopodman.VarlinkCall, query string, limit // DeleteUnusedImages deletes any images that do not have containers associated with it. // TODO Filters are not implemented -func (i *LibpodAPI) DeleteUnusedImages(call iopodman.VarlinkCall) error { +func (i *VarlinkAPI) DeleteUnusedImages(call iopodman.VarlinkCall) error { images, err := i.Runtime.ImageRuntime().GetImages() if err != nil { return call.ReplyErrorOccurred(err.Error()) @@ -565,7 +565,7 @@ func (i *LibpodAPI) DeleteUnusedImages(call iopodman.VarlinkCall) error { } // Commit ... -func (i *LibpodAPI) Commit(call iopodman.VarlinkCall, name, imageName string, changes []string, author, message string, pause bool, manifestType string) error { +func (i *VarlinkAPI) Commit(call iopodman.VarlinkCall, name, imageName string, changes []string, author, message string, pause bool, manifestType string) error { var ( newImage *image.Image log []string @@ -643,7 +643,7 @@ func (i *LibpodAPI) Commit(call iopodman.VarlinkCall, name, imageName string, ch } // ImportImage imports an image from a tarball to the image store -func (i *LibpodAPI) ImportImage(call iopodman.VarlinkCall, source, reference, message string, changes []string, delete bool) error { +func (i *VarlinkAPI) ImportImage(call iopodman.VarlinkCall, source, reference, message string, changes []string, delete bool) error { configChanges, err := util.GetImageConfig(changes) if err != nil { return call.ReplyErrorOccurred(err.Error()) @@ -670,7 +670,7 @@ func (i *LibpodAPI) ImportImage(call iopodman.VarlinkCall, source, reference, me // ExportImage exports an image to the provided destination // destination must have the transport type!! -func (i *LibpodAPI) ExportImage(call iopodman.VarlinkCall, name, destination string, compress bool, tags []string) error { +func (i *VarlinkAPI) ExportImage(call iopodman.VarlinkCall, name, destination string, compress bool, tags []string) error { newImage, err := i.Runtime.ImageRuntime().NewFromLocal(name) if err != nil { return call.ReplyImageNotFound(name, err.Error()) @@ -688,7 +688,7 @@ func (i *LibpodAPI) ExportImage(call iopodman.VarlinkCall, name, destination str } // PullImage pulls an image from a registry to the image store. -func (i *LibpodAPI) PullImage(call iopodman.VarlinkCall, name string, creds iopodman.AuthConfig) error { +func (i *VarlinkAPI) PullImage(call iopodman.VarlinkCall, name string, creds iopodman.AuthConfig) error { var ( imageID string err error @@ -760,7 +760,7 @@ func (i *LibpodAPI) PullImage(call iopodman.VarlinkCall, name string, creds iopo } // ImageExists returns bool as to whether the input image exists in local storage -func (i *LibpodAPI) ImageExists(call iopodman.VarlinkCall, name string) error { +func (i *VarlinkAPI) ImageExists(call iopodman.VarlinkCall, name string) error { _, err := i.Runtime.ImageRuntime().NewFromLocal(name) if errors.Cause(err) == image.ErrNoSuchImage { return call.ReplyImageExists(1) @@ -772,7 +772,7 @@ func (i *LibpodAPI) ImageExists(call iopodman.VarlinkCall, name string) error { } // ContainerRunlabel ... -func (i *LibpodAPI) ContainerRunlabel(call iopodman.VarlinkCall, input iopodman.Runlabel) error { +func (i *VarlinkAPI) ContainerRunlabel(call iopodman.VarlinkCall, input iopodman.Runlabel) error { ctx := getContext() dockerRegistryOptions := image.DockerRegistryOptions{} stdErr := os.Stderr @@ -798,7 +798,7 @@ func (i *LibpodAPI) ContainerRunlabel(call iopodman.VarlinkCall, input iopodman. } // ImagesPrune .... -func (i *LibpodAPI) ImagesPrune(call iopodman.VarlinkCall, all bool, filter []string) error { +func (i *VarlinkAPI) ImagesPrune(call iopodman.VarlinkCall, all bool, filter []string) error { prunedImages, err := i.Runtime.ImageRuntime().PruneImages(context.TODO(), all, []string{}) if err != nil { return call.ReplyErrorOccurred(err.Error()) @@ -807,7 +807,7 @@ func (i *LibpodAPI) ImagesPrune(call iopodman.VarlinkCall, all bool, filter []st } // ImageSave .... -func (i *LibpodAPI) ImageSave(call iopodman.VarlinkCall, options iopodman.ImageSaveOptions) error { +func (i *VarlinkAPI) ImageSave(call iopodman.VarlinkCall, options iopodman.ImageSaveOptions) error { newImage, err := i.Runtime.ImageRuntime().NewFromLocal(options.Name) if err != nil { if errors.Cause(err) == define.ErrNoSuchImage { @@ -905,7 +905,7 @@ func (i *LibpodAPI) ImageSave(call iopodman.VarlinkCall, options iopodman.ImageS } // LoadImage ... -func (i *LibpodAPI) LoadImage(call iopodman.VarlinkCall, name, inputFile string, deleteInputFile, quiet bool) error { +func (i *VarlinkAPI) LoadImage(call iopodman.VarlinkCall, name, inputFile string, deleteInputFile, quiet bool) error { var ( names string writer io.Writer @@ -974,7 +974,7 @@ func (i *LibpodAPI) LoadImage(call iopodman.VarlinkCall, name, inputFile string, } // Diff ... -func (i *LibpodAPI) Diff(call iopodman.VarlinkCall, name string) error { +func (i *VarlinkAPI) Diff(call iopodman.VarlinkCall, name string) error { var response []iopodman.DiffInfo changes, err := i.Runtime.GetDiff("", name) if err != nil { @@ -987,7 +987,7 @@ func (i *LibpodAPI) Diff(call iopodman.VarlinkCall, name string) error { } // GetLayersMapWithImageInfo is a development only endpoint to obtain layer information for an image. -func (i *LibpodAPI) GetLayersMapWithImageInfo(call iopodman.VarlinkCall) error { +func (i *VarlinkAPI) GetLayersMapWithImageInfo(call iopodman.VarlinkCall) error { layerInfo, err := image.GetLayersMapWithImageInfo(i.Runtime.ImageRuntime()) if err != nil { return call.ReplyErrorOccurred(err.Error()) @@ -1000,7 +1000,7 @@ func (i *LibpodAPI) GetLayersMapWithImageInfo(call iopodman.VarlinkCall) error { } // BuildImageHierarchyMap ... -func (i *LibpodAPI) BuildImageHierarchyMap(call iopodman.VarlinkCall, name string) error { +func (i *VarlinkAPI) BuildImageHierarchyMap(call iopodman.VarlinkCall, name string) error { img, err := i.Runtime.ImageRuntime().NewFromLocal(name) if err != nil { return call.ReplyErrorOccurred(err.Error()) @@ -1024,7 +1024,7 @@ func (i *LibpodAPI) BuildImageHierarchyMap(call iopodman.VarlinkCall, name strin } // ImageTree returns the image tree string for the provided image name or ID -func (i *LibpodAPI) ImageTree(call iopodman.VarlinkCall, nameOrID string, whatRequires bool) error { +func (i *VarlinkAPI) ImageTree(call iopodman.VarlinkCall, nameOrID string, whatRequires bool) error { img, err := i.Runtime.ImageRuntime().NewFromLocal(nameOrID) if err != nil { return call.ReplyErrorOccurred(err.Error()) |