Commit graph

665 commits

Author SHA1 Message Date
Debarshi Ray
35752e9943 build: Lower the minimum gh.c/spf13/cobra version to 0.0.5
Fedora's golang-github-spf13-cobra package is still at 0.0.5. Since
there's no real need for anything newer, lowering the requirement will
make it easier to build on Fedora.

https://github.com/containers/toolbox/pull/444
2020-05-14 23:54:38 +02:00
Debarshi Ray
95d3953aec build: Lower the minimum gh.c/sirupsen/logrus version to 1.4.2
Fedora's golang-github-sirupsen-logrus package is still at 1.4.2. Since
there's no real need for anything newer, lowering the requirement will
make it easier to build on Fedora.

https://github.com/containers/toolbox/pull/444
2020-05-14 23:54:33 +02:00
Harry Míchal
1e3d25c426 Prepare 0.0.90
https://github.com/containers/toolbox/pull/435
2020-05-14 16:42:52 +02:00
Harry Míchal
493bc1ffd5 .zuul, playbooks/shellcheck: Use Go 1.13
Toolbox requires Go 1.13, while Fedora 30 only has Go 1.12.17.
Therefore the test environment needs to be upgraded to something more
recent.

Otherwise, the test fails with:
  note: module requires Go 1.13

The name of the go-md2man package changed in Fedora 31, and hence had
to be updated.

https://github.com/containers/toolbox/pull/442
2020-05-14 16:14:47 +02:00
Harry Míchal
c95aacc488 playbooks/shellcheck: Add Go to the list of build dependencies
Otherwise, the test fails with:
  meson.build:8:0: ERROR: Program(s) ['go'] not found or not executable

https://github.com/containers/toolbox/pull/441
2020-05-14 15:39:00 +02:00
Debarshi Ray
0b3c66434e build: Ship the Go implementation by default, not the POSIX shell one
The Go implementation is now considered stable enough for wider use,
and should have feature parity with its POSIX shell counterpart.

https://github.com/containers/toolbox/pull/437
2020-05-14 09:53:18 +02:00
TomSweeneyRedHat
edf6aa4d1c Add Security Policy
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
2020-05-13 14:37:08 +02:00
Debarshi Ray
ebd92b9905 cmd/reset: Implement the reset command in Go
https://github.com/containers/toolbox/pull/318
2020-05-13 13:22:58 +02:00
Harry Míchal
662bd89931 cmd/enter: Implement the enter command in Go
The Go version supports specifying the name of the toolbox container as
'toolbox enter NAME', on top of the 'toolbox enter --container NAME'
form.

https://github.com/containers/toolbox/pull/318
2020-05-13 13:22:58 +02:00
Harry Míchal
238f2451e7 cmd/run: Implement the run command in Go
https://github.com/containers/toolbox/pull/318
2020-05-13 13:22:58 +02:00
Harry Míchal
cf5c58ab00 cmd/run: Add function to get the entry point PID of a container
For some reason, the State:Pid value in the JSON returned by
'podman inspect --format json --type container' is a float64 [1], even
though internally Podman represents it as an int.

[1] https://github.com/containers/libpod/issues/6105

https://github.com/containers/toolbox/pull/318
2020-05-13 13:22:58 +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
5d6bfffb6e pkg/utils: Add function to show an error when a container is missing
https://github.com/containers/toolbox/pull/318
2020-05-13 13:22:58 +02:00
Harry Míchal
8f30d71806 cmd/create: Implement the create command
The Go version supports specifying the name of the new toolbox
container as 'toolbox create NAME', in addition to the existing
'toolbox create --container NAME' form.

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
936f22ff15 pkg/utils: Add function to prompt the user for confirmation
https://github.com/containers/toolbox/pull/318
2020-05-13 12:59:04 +02:00
Harry Míchal
823fbacea9 pkg/utils: Figure out the name of the default toolbox container
https://github.com/containers/toolbox/pull/318
2020-05-13 12:59:04 +02:00
Harry Míchal
b148e42f15 pkg/utils: Resolve the actual container, image and release to be used
... based on the default values, and those overridden by the user.

https://github.com/containers/toolbox/pull/318
2020-05-13 12:59:04 +02:00
Harry Míchal
0ce54624df pkg/utils: Figure out the default operating system release
https://github.com/containers/toolbox/pull/318
2020-05-13 12:59:04 +02:00
Harry Míchal
0000cb0151 pkg/utils: Add functions to get the properties of an image reference
https://github.com/containers/toolbox/pull/318
2020-05-13 12:59:04 +02:00
Harry Míchal
dd947016b3 pkg/utils: Add function to check if an image is referenced by its ID
https://github.com/containers/toolbox/pull/318
2020-05-13 12:59:04 +02:00
Harry Míchal
d589b3a252 pkg/utils: Add function to show an error for invalid release arguments
https://github.com/containers/toolbox/pull/318
2020-05-13 12:59:04 +02:00
Harry Míchal
43082145a9 pkg/utils: Add function to parse the user-specified release string
https://github.com/containers/toolbox/pull/318
2020-05-13 12:59:04 +02:00
Debarshi Ray
9e2825524a pkg/utils: Add functions for reading various os-release fields
https://github.com/containers/toolbox/pull/318
2020-05-13 12:59:04 +02:00
Harry Míchal
2edc30836b pkg/utils: Add functions to get the mount metadata of a directory
https://github.com/containers/toolbox/pull/318
2020-05-13 12:59:04 +02:00
Harry Míchal
98b7753104 pkg/utils: Add function to check the validity of a container's name
https://github.com/containers/toolbox/pull/318
2020-05-13 12:42:26 +02:00
Debarshi Ray
08fbf92473 pkg/utils: Wrap call to o.fd.Flatpak.SessionHelper.RequestSession
https://github.com/containers/toolbox/pull/318
2020-05-13 12:42:26 +02:00
Harry Míchal
772b66bf3e cmd/initContainer: Implement the init-container command
https://github.com/containers/toolbox/pull/318
2020-05-13 12:42:26 +02:00
Harry Míchal
31f1b741c0 pkg/utils: Add function to get the name of the sudoers group
https://github.com/containers/toolbox/pull/318
2020-05-13 12:42:26 +02:00
Harry Míchal
188c92c76e cmd/rm: Implement the rm command in Go
https://github.com/containers/toolbox/pull/318
2020-05-13 12:42:26 +02:00
Harry Míchal
805450283b cmd/rmi: Implement the rmi command
https://github.com/containers/toolbox/pull/318
2020-05-13 12:42:26 +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
c30d5549b6 cmd/list: Implement the list command
Go's text/tabwriter package isn't aware of the ANSI Select Graphic
Rendition (or SGR) escape sequences to change the terminal's
foreground colour [1,2]. Using the sequences disrupt the alignment of
the columns in the tabbed output.

Therefore, unlike the existing POSIX shell implementation, running
containers aren't marked in green in the Go version.

[1] https://en.wikipedia.org/wiki/ANSI_escape_code
[2] https://github.com/golang/go/issues/12073

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
74c2d7f02b pkg/utils: Add function to sort sets of containers or images in JSON
https://github.com/containers/toolbox/pull/318
2020-05-13 12:42:26 +02:00
Harry Míchal
928bf53943 pkg/utils: Add function to join sets of containers or images in JSON
https://github.com/containers/toolbox/pull/318
2020-05-13 12:42:26 +02:00
Harry Míchal
6170f494aa pkg/utils: Add function to shorten the hash of a container of image
https://github.com/containers/toolbox/pull/318
2020-05-13 12:42:26 +02:00
Harry Míchal
c2ba67569b cmd/root: Implement migration of containers and images
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
Harry Míchal
3f0a135937 cmd/root: Initialize TOOLBOX_PATH; validate /etc/subgid & /etc/subuid
https://github.com/containers/toolbox/pull/318
2020-05-13 09:40:41 +02:00
Debarshi Ray
e8866f2db1 cmd/help, cmd/root: Parametrize the basename of the executable
... instead of hard coding it as 'toolbox'.

https://github.com/containers/toolbox/pull/318
2020-05-13 09:40:41 +02:00
Harry Míchal
e8d7f25e83 cmd/root: Initialize globals on start-up
These values are generally useful, and reading any of them is a
potentially fallible operation. Since the absence of any of these
values is indicative of a broken environment, it's more convenient to
read them early on during start-up and abort, instead of trying to
handle the error later on.

https://github.com/containers/toolbox/pull/318
2020-05-13 09:40:41 +02:00
Debarshi Ray
f5bf741f86 pkg/utils: Add function to get the cgroups version
Based on the IsCgroup2UnifiedMode function:
https://github.com/containers/libpod/tree/master/pkg/cgroups

As suggested by Matthew Heon.

https://github.com/containers/toolbox/pull/318
2020-05-13 09:40:41 +02:00
Harry Míchal
aaf81a56ea Sketch out the command line interface in Go
All the existing commands and their flags are present; but barring
'help', '--help' and logging, they don't do anything.

The skeleton was bootstrapped with Cobra Generator.

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
Debarshi Ray
c9ae8ad3b6 pkg/utils: Add function to tunnel a Toolbox invocation to the host
https://github.com/containers/toolbox/pull/318
2020-05-13 09:40:41 +02:00