Commit Graph

20 Commits

Author SHA1 Message Date
Debarshi Ray 5f324d537e cmd/list, pkg/podman: Limit access to the raw 'podman images' JSON
This builds on top of commit 0465d78fd9034ce9.

The toolboxImage type has been renamed to Image and moved into the
podman package.

There is nothing Toolbx specific about the type - it represents any
image returned by 'podman images'.  The images are only later filtered
for Toolbx images.

Secondly, having the Image type inside the podman package makes it
possible to encapsulate the unmarshalling of the JSON within the package
without exposing the raw JSON to outside consumers.  This is desirable
because the unmarshalling involves tracking changes in the JSON output
by different Podman versions, and it's better to limit such details to
the podman package.

https://github.com/containers/toolbox/pull/1190
2022-12-07 13:06:20 +01:00
Debarshi Ray 2486e25601 cmd/list, pkg/podman: Don't unmarshal the 'podman images' JSON twice
This builds on top of commit e772207831.

Currently, the JSON from 'podman images --format json' gets unmarshalled
into a []map[string]interface{} in podman.GetImages, where the maps in
the slice represent images.  Each map is then marshalled back into JSON
and then again unmarshalled into a toolboxImage type.

This is wasteful.  The toolboxImage type already implements the
json.Unmarshaler interface [1], since commit e772207831.  Hence,
the entire JSON from 'podman images --format json' can be directly
unmarshalled into a slice of toolboxImages without involving the
[]map[string]interface{}.

A subsequent commit will move the toolboxImage type into the podman
package to more tightly encapsulate the unmarshalling of the JSON.  So,
as an intermediate step in that direction, the podman.GetImages function
has been temporarily changed to return the entire JSON.

[1] https://pkg.go.dev/encoding/json#Unmarshaler

https://github.com/containers/toolbox/pull/1190
2022-12-07 13:06:20 +01:00
Debarshi Ray 630792e0a1 Update copyright notices
https://github.com/containers/toolbox/pull/1179
2022-11-28 21:01:18 +01:00
Ondřej Míchal ecd1ced719 cmd/create: Add option --authfile
The option accepts a path to a file that is passed to an internal call
to 'podman pull' via the '--authfile' option. This will make it easier
to pull images from registries with authentication in-place.

Fixes https://github.com/containers/toolbox/issues/689

https://github.com/containers/toolbox/pull/935
2022-03-20 18:08:42 +02:00
Debarshi Ray c2f8e19e56 Update copyright notices
https://github.com/containers/toolbox/pull/688
2021-02-08 16:49:54 +01:00
Debarshi Ray b511a76578 Update the labels used for filtering toolbox containers images
The com.github.debarshiray.toolbox label was introduced in commit
0ab6eb7401 to replace the com.redhat.component label for
filtering toolbox containers and images. This happened right before
the release of Fedora 30, which hasn't been supported for a while [1].
Therefore, it's time to stop using the old label.

It's also time to start using the newer com.github.containers.toolbox
label that was introduced in commit de5e5df9b7 to reflect the
project's new home under the Containers organization on GitHub.

[1] https://fedoraproject.org/wiki/Releases/30/Schedule

https://github.com/containers/toolbox/pull/665
2021-01-11 23:38:48 +01:00
Ondřej Míchal ff1fab0f52 cmd/rmi, pkg/podman: Move 'removeImage' func to podman pkg
The 'removeImage' function should go into 'pkg/podman' because it wraps
around Podman's command. Because it no longer has access to the commands
- toolbox rmi - parameters it has a new forceDelete parameter.

https://github.com/containers/toolbox/pull/519
2020-08-14 11:00:06 +02:00
Ondřej Míchal 2ecaaf8ba3 cmd/rm, pkg/podman: Move 'removeContainer' func to podman pkg
The 'removeContainer' function should go into 'pkg/podman' because it
wraps around Podman's command. Because it no longer has access to the
commands - 'toolbox rm' - parameters it has a new forceDelete parameter.

https://github.com/containers/toolbox/pull/519
2020-08-14 11:00:06 +02:00
Ondřej Míchal 843d4ce2cc pkg/podman: Speed things up by caching the Podman version at runtime
We call `podman version` every time we want to check Podman's version.
This slows Toolbox down considerably. It's more efficient if we call
`podman version` just once and remember the output during runtime and
use the cached value.

https://github.com/containers/toolbox/pull/481
2020-07-03 19:09:39 +02:00
Debarshi Ray bcacb1196c pkg/podman: Rename a variable
The subsequent commit will introduce a global variable called
podmanVersion, so this will prevent the local variable from colliding
with the global.

https://github.com/containers/toolbox/pull/481
2020-07-03 19:06:09 +02:00
Harry Míchal eb0ce415b0 pkg/podman: Wrap 'podman start'
https://github.com/containers/toolbox/pull/318
2020-05-13 13:22:58 +02:00
Harry Míchal 49146028bc pkg/podman: Wrap 'podman pull'
https://github.com/containers/toolbox/pull/318
2020-05-13 12:59:04 +02:00
Harry Míchal 8aea0b0521 pkg/podman: Wrap 'podman container exists' and 'podman image exists'
https://github.com/containers/toolbox/pull/318
2020-05-13 12:59:04 +02:00
Harry Míchal 08e8a80d4c pkg/podman: Add functions to check if a container/image is a Toolbox
https://github.com/containers/toolbox/pull/318
2020-05-13 12:42:26 +02:00
Harry Míchal c75404c056 pkg/podman: Wrap 'podman inspect --format json'
https://github.com/containers/toolbox/pull/318
2020-05-13 12:42:26 +02:00
Harry Míchal f4d129ab4d pkg/podman: Wrap 'podman images' & 'podman ps'
https://github.com/containers/toolbox/pull/318
2020-05-13 12:42:26 +02:00
Harry Míchal d1a9fe20aa pkg/podman: Wrap 'podman system migrate'
https://github.com/containers/toolbox/pull/318
2020-05-13 12:33:34 +02:00
Harry Míchal 46c21a5c14 podman: Add function to check if Podman is newer than a given version
This is in the same style as GLib's GLIB_CHECK_VERSION [1].

Note that the github.com/HarryMichal/go-version package is a fork of
github.com/mcuadros/go-version. The latter is now marked as read-only
and archived by its owner.

The fork was necessary to fix the documentation of the CompareSimple
function. The function is supposed to conform to the strcmp
convention. ie., return 0 if both versions are equal, 1 if the left
side is bigger, and -1 if the right side is bigger. However, the
documentation had it the other way round.

[1] https://developer.gnome.org/glib/stable/glib-Version-Information.html#GLIB-CHECK-VERSION:CAPS

https://github.com/containers/toolbox/pull/318
2020-05-13 12:16:48 +02:00
Harry Míchal b3fca25764 pkg/podman: Wrap 'podman version --format json'
https://github.com/containers/toolbox/pull/318
2020-05-13 09:40:41 +02:00
Debarshi Ray 561fe8b12d Lay the foundations for logging Podman in Go
https://github.com/containers/toolbox/pull/318
2020-05-13 09:40:41 +02:00