Commit graph

812 commits

Author SHA1 Message Date
Timothée Ravier
e80cba4d3e Images: Create F37 toolbox image from F36
https://github.com/containers/toolbox/pull/1012
2022-03-21 00:26:10 +02:00
Ondřej Míchal
958a2c91af ci: Enable testing on Fedora 36 2022-03-21 00:06:41 +02:00
Oliver Gutierrez
f8e21a31b3 cmd/run, root: Exit with exit code of invoked command
When a command is executed with toolbox run and it returns a non-zero
exit code, it is just ignored if that exit code is not handled. This
prevents users to identify errors when executing commands in toolbox.

With this fix, the exit codes of the invoked command are propagated
and returned by 'toolbox run'. This includes even exit codes returned
by Podman on error.

https://github.com/containers/toolbox/pull/1013

Co-authored-by: Ondřej Míchal <harrymichal@seznam.cz>
2022-03-21 00:05:45 +02:00
Ondřej Míchal
7cba807e45 cmd/run: Launch command with stderr being attached
Without stderr being attached stderr output of the invoked command goes
into stdout.

Behaviour before:
; output="$(toolbox run /etc)"
Error: failed to invoke command /etc in container <name-of-container>
; echo -e "$output"
/bin/sh: line 1: /etc: Is a directory
/bin/sh: line 1: exec: /etc: cannot execute: Is a directory

Behaviour after:
; output="$(toolbox run /etc)"
/bin/sh: line 1: /etc: Is a directory
/bin/sh: line 1: exec: /etc: cannot execute: Is a directory
Error: failed to invoke command /etc in container <name-of-container>
; echo -e "$output"

https://github.com/containers/toolbox/pull/1013
2022-03-21 00:05:45 +02:00
Ondřej Míchal
a22d7821cb cmd/run: Don't allocate pseudo-TTY if not connected to terminal
Passing '--tty' to 'podman exec' unconditionally causes Podman to
allocate a pseudo-TTY for the command execution. This causes problems
with piping (values not being piped in and values being piped out with
carriage return at the end of a line). The solution is to track the
presence of a terminal on stdin/stdout and based on its presence use the
'--tty' flag.

Original behaviour:
; echo foo | toolbox run less

; toolbox echo foo | od -c
0000000   f   o   o  \r  \n
0000005

New behaviour:
; echo foo | toolbox run less
foo

; toolbox echo foo | od -c
0000000   f   o   o  \n
0000004

As seen in the 'Piping in' example, the value gets only printed into
stdout. Not ideal from the point of view of using 'less' (or similar
tools) but still a move forward.

Based on a discussion in Podman's bugtracker[0].

Fixes https://github.com/containers/toolbox/issues/157
Fixes https://github.com/containers/toolbox/issues/848

[0] https://github.com/containers/podman/issues/9718

https://github.com/containers/toolbox/pull/1013
2022-03-21 00:05:45 +02:00
Ondřej Míchal
9d3601e0a6 .zuul: Use labels/nodes without the '-small' suffix 2022-03-20 23:40:58 +02:00
Ondřej Míchal
9bffbb7e13 Revert "ci: Build & Publish Fedora Toolbx images with GitHub Packages"
This revert is done based on discussion happening around the PR that
originally added the change[0].

This reverts commit 818748001c.

[0] https://github.com/containers/toolbox/pull/973

https://github.com/containers/toolbox/pull/1028
2022-03-20 21:11:32 +02: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
Ondřej Míchal
192b9c8265 test/system: Mention where to find available environmental variables
https://github.com/containers/toolbox/pull/1024
2022-03-20 17:11:33 +02:00
Ondřej Míchal
0cdc6b8305 test/system: Add a section about test writing guidelines
https://github.com/containers/toolbox/pull/1024
2022-03-20 17:11:33 +02:00
Ondřej Míchal
dfc38b156c test/system: Adjust the return value of container start test
The output of 'podman logs' does not need to be returned as it can already
be seen in the logs when bats is properly configured.

https://github.com/containers/toolbox/pull/1024
2022-03-20 17:11:33 +02:00
Ondřej Míchal
fc71b9de34 test/system: Skip caching of an image if it is already cached
https://github.com/containers/toolbox/pull/1024
2022-03-20 17:11:33 +02:00
Ondřej Míchal
754c6fb4d1 test/system: Set custom runtime root for rootless Podman
To more completely separate the test environment Podman runtime from the
default system one set also a custom runtime directory.

https://github.com/containers/toolbox/pull/1024
2022-03-20 17:11:33 +02:00
Ondřej Míchal
813f971181 test/system: Don't cleanup tests by resetting Podman
Calling 'podman system cleanup' causes problems with containers/images
in a separate Podman root. Despite being stored elsewhere, they are
still under Podman's influence and the cleanup removes them. Also,
running containers (outside the scope of the tests) still got affected
by this call and e.g., lost the ability to follow terminal size changes.

Despite the raised concerns, to ensure proper cleanup of any Podman
state, the reset still needs to be done. Thus, do it only once during
the test suite teardown, moving the potential source of problems to a
single position..

https://github.com/containers/toolbox/pull/1024
2022-03-20 17:11:33 +02:00
Ondřej Míchal
5012cda506 test/system: Minor fixes & renaming
https://github.com/containers/toolbox/pull/1024
2022-03-20 17:11:33 +02:00
Ondřej Míchal
5c27d73021 .zuul: Run system tests when they are changed
Fallout from c28d902089

https://github.com/containers/toolbox/pull/1024
2022-03-20 17:11:33 +02:00
Ondřej Míchal
bafbbe81c9 Generate & install completion scripts in build system
The previous commit added a means to generating the completion scripts
and this one plugs that into the build system.

A new build option 'install_completions' has been introduced. Set to
'True' by default.

Completions for bash and fish use pkg-config for getting the preferred
install locations for the completions. If the packages are not
available, fallbacks are in-place.

The 'completion' subdir has been kept to work around the ideology of
Meson that does not allow creating/outputing files in subdirectories nor
using the output of custom_target() in install_data().

https://github.com/containers/toolbox/pull/840
2022-02-21 15:15:30 +02:00
Oliver Gutierrez
d69ce6794b cmd: Add shell completion command & generate completion
Cobra (the CLI library) has an advanced support for generating shell
completion. It support Bash, Zsh, Fish and PowerShell. This offering
covers the majority of use cases with some exceptions, of course.

The generated completion scripts have one behavioral difference when
compared to the existing solution: flags (--xxx) are not shown by
default. User needs to type '-' first to get the completion.

https://github.com/containers/toolbox/pull/840

Co-authored-by: Ondřej Míchal <harrymichal@seznam.cz>
2022-02-21 15:15:30 +02:00
Ondřej Míchal
5c8ad7a7ec pkg/utils: Use global default instead of magic value
Found while working on https://github.com/containers/toolbox/issues/937

https://github.com/containers/toolbox/pull/977
2022-02-21 13:43:24 +02:00
Ondřej Míchal
02f45fd3f2 pkg/utils: Use newly introduced API for resolving default distro
https://github.com/containers/toolbox/pull/977
2022-02-21 13:43:24 +02:00
Ondřej Míchal
8b6418d8aa cmd, pkg/utils: Split distro and release parsing and report better errors
Using a non-supported distribution via `--distro` resulted in a silent
fallback to the Fedora image which confuses users. When a faulty release
format was used with `--release` a message without any hint about the
correct format was shown to the user.

This separates distro and release parsing into two chunks that have
greater control over error reporting and provides more accurate error
reports for the user.

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

https://github.com/containers/toolbox/pull/977
2022-02-21 13:43:24 +02:00
pablomh
2af0b30ed3 test/system: Delete .swp file
Delete .swp file that was inadvertenly introduced in [1].

[1] 7a5f3ba2e2

https://github.com/containers/toolbox/pull/996
2022-02-07 01:10:10 +02:00
Debarshi Ray
656deb3677 Canonicalize Ondra's name
From now on, Harry Míchal <harrymichal@seznam.cz> will show up as
Ondřej Míchal <harrymichal@seznam.cz>.

https://github.com/containers/toolbox/pull/1002
2022-01-26 01:44:31 +01:00
Ondřej Míchal
8ae0f9c5c6 doc/toolbox: Add section about supported distribution images
Having a list of supported distributions in the manual has been long
overdue. Complementing it with the expected formats should make lives
of users a bit easier.

https://github.com/containers/toolbox/pull/977
https://github.com/containers/toolbox/pull/986
2022-01-13 22:20:47 +01:00
Ondřej Míchal
ffd365342e doc: Highlight that --distro has to be used with --release
...unless the selected distro matches the host system.

https://github.com/containers/toolbox/pull/977
https://github.com/containers/toolbox/pull/986
2022-01-13 22:20:43 +01:00
Jakub Steiner
4a652d1efd README: Flip the graphic's facing direction for better layout
https://github.com/containers/toolbox/pull/985
2022-01-13 21:22:23 +01:00
Debarshi Ray
afbed7a057 build: Enforce gofmt on all Go sources
Gofmt returns with an exit code of 0 even when it's not happy with the
formatting of the source files. The recommendation is to check the
emptyness of the output [1].

[1] https://github.com/golang/go/issues/24230

https://github.com/containers/toolbox/pull/983
2022-01-11 22:33:51 +01:00
Debarshi Ray
3f9ee19a66 build: Add copyright and license notice
Fallout from be2ba6d2e2

https://github.com/containers/toolbox/pull/984
2022-01-11 19:55:22 +01:00
Debarshi Ray
b1743c4927 .zuul: Trigger the tests when the post-install script changes
Fallout from be2ba6d2e2

https://github.com/containers/toolbox/pull/984
2022-01-11 19:55:18 +01:00
Debarshi Ray
4459e02e02 .zuul: Re-align
This will make the subsequent commit easier to read.

https://github.com/containers/toolbox/pull/984
2022-01-11 19:55:05 +01:00
Debarshi Ray
d2067ea688 build: Tidy up the Go dependencies with 'go mod tidy'
https://github.com/containers/toolbox/pull/982
2022-01-11 01:24:56 +01:00
Debarshi Ray
de6d587c8b build: Mark golang.org/x/term as a direct dependency
The deprecated golang.org/x/crypto/ssh/terminal API was replaced with
golang.org/x/term. Now, every invocation of 'go build' insists on
updating src/go.mod to drop the 'indirect' marker from
golang.org/x/term.

Fallout from d323143c46

https://github.com/containers/toolbox/pull/982
2022-01-11 01:23:41 +01:00
Debarshi Ray
be2ba6d2e2 build: Call 'systemd-tmpfiles --create' when installing
It's only necessary to call 'systemd-tmpfiles --create' when building
and installing from source on the host operating system.

It's not needed when using a pre-built binary downstream package,
because:

  * When 'meson install' is called as part of building the package,
    that's not when the temporary files need to be created. They need
    to be created when the binary package is later downloaded and
    installed by the user.

  * Downstream tools can sometimes handle it automatically. eg., on
    Fedora, the systemd RPM installs a trigger that tells RPM to call
    'systemd-tmpfiles --create' automatically when a tmpfiles.d snippet
    is installed.

It's also not needed when installing inside a toolbox container because
the files that 'systemd-tmpfiles --create' is supposed to create are
meant to be on the host.

Downstream distributors set the DESTDIR environment variable when
building their packages. Therefore, it's used to detect when a
downstream package is being built.

Unfortunately, environment variables are messy and, generally, Meson
doesn't support accessing them inside its scripts [1]. Therefore, this
adds a spurious build-time dependency on systemd for downstream
distributors. However, that's probably not a big problem because all
supported downstream operating systems are already expected to use
systemd for the tmpfiles.d(5) snippets to work.

[1] https://github.com/mesonbuild/meson/issues/9

https://github.com/containers/toolbox/issues/955
2022-01-10 22:14:01 +01:00
Ondřej Míchal
5d61a74b1a ci: Set full path to Containerfile
The action does not use provided context when looking for a
Containerfile[0].

[0] https://github.com/redhat-actions/buildah-build/issues/44

https://github.com/containers/toolbox/pull/981
2022-01-10 13:40:32 +02:00
Ondřej Míchal
05eef2aaa6 ci: Add manual trigger to image factory pipeline
https://github.com/containers/toolbox/pull/981
2022-01-10 13:40:32 +02:00
Ondřej Míchal
818748001c ci: Build & Publish Fedora Toolbx images with GitHub Packages
For the sake of greater control over the testing of images and for having an
infrustructure for hosting images that are not endorsed by the distirbutions.

The images are to be rebuilt every day at midnight.

https://github.com/containers/toolbox/pull/973
2022-01-09 18:16:47 +01:00
Ondřej Míchal
d323143c46 cmd: Fix issues raised by Golangci
Issues included:

- unreachable code
- unneeded type assertions
- unhandled errors
- use of deprecated API
- unused code

https://github.com/containers/toolbox/pull/979
2022-01-09 17:48:47 +01:00
Ondřej Míchal
46ff946190 ci: Remove only-new-issues option from linter run
The option is mutually exclusive with the working-directory option that
we need to use due to Toolbx code residing in a subdirectory. The tool
itself does not work recursively.

Fallout from https://github.com/containers/toolbox/pull/974

https://github.com/containers/toolbox/pull/978
2022-01-09 17:01:40 +01:00
Ondřej Míchal
f456c173b6 pkg/utils: Use new UBI toolbox image
Red Hat has published a new UBI image made specificaly for Toolbx.
Make use of it from now on.

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

https://github.com/containers/toolbox/issues/976
2022-01-09 16:46:37 +01:00
Ondřej Míchal
7c86f30b77 ci: Add golangci linter
Use machines to do (at least some) of the work humans had to do!

https://github.com/containers/toolbox/pull/974
2022-01-09 16:29:32 +01:00
Jakub Steiner
7351313dc8 CONTRIBUTING: Custom graphic
Can't have right aligned images or inline css, better to just have them
on the left.

https://github.com/containers/toolbox/pull/958
2022-01-07 09:34:39 +01:00
Debarshi Ray
4dd3c89721 .zuul: Style fixes
List the jobs in the same order that they are defined.

https://github.com/containers/toolbox/pull/971
2022-01-05 02:18:15 +01:00
Debarshi Ray
12fbb2361e .zuul: Shuffle some code around
Defining the YAML anchor as part of the Rawhide tests, instead of the
Fedora 34 test, will prevent it from getting lost by mistake when
Fedora 34 reaches its End of Life.

https://github.com/containers/toolbox/pull/971
2022-01-05 02:15:38 +01:00
Debarshi Ray
53a7ac0f9e .zuul: Try to prevent the CI from timing out running the unit tests
Currently, the CI has been frequently timing out when running the unit
tests. It's possible that the current 5 minute timeout isn't enough,
because it's significantly lower than the 20 minute timeout on stable
Fedoras for the system tests.

Increase the timeout to 10 minutes to see if that makes the CI more
stable.

https://github.com/containers/toolbox/pull/970
2022-01-05 00:54:25 +01:00
Debarshi Ray
bedea6fa09 .zuul: Try to prevent the CI from timing out on Fedora Rawhide
Currently, the CI has been frequently timing out on Fedora Rawhide
nodes, and it's not clear why that is. One possibility is that this is
due to Rawhide using Linux kernels that are built with debugging
enabled, which makes it slower than released Fedoras. So it might be a
matter of just increasing the timeout.

Currently, the timeout for stable Fedoras is 20 minutes, and that for
Rawhide is 22 minutes. An attempt to increase the Rawhide timeout to 30
minutes didn't succeed, so maybe 45 minutes will be sufficient.

https://github.com/containers/toolbox/pull/964
2022-01-04 23:50:58 +01:00
Ondřej Míchal
73c53a347b src: Update dependencies with 'go get -u'
- github.com/acobaugh/osrelease v0.0.0-20181218015638-a93a0a55a249 => v0.1.0
- github.com/briandowns/spinner v1.10.0 => v1.17.0
- github.com/fsnotify/fsnotify v1.4.9 => v1.5.1
- github.com/sirupsen/logrus v1.4.2 => v1.8.1
- github.com/spf13/cobra v0.0.7 => v1.3.0
- github.com/spf13/viper v1.4.0 => v1.10.1
- golang.org/x/crypto v0.0.0-20211115234514-b4de73f9ece8 => v0.0.0-20211215153901-e495a2d5b3d3
- golang.org/x/sys v0.0.0-20211113001501-0c823b97ae02 => v0.0.0-20211216021012-1d35b9e2eb4e

https://github.com/containers/toolbox/pull/917
2021-12-17 16:26:19 +01:00
Ondřej Míchal
e598e21603 cmd/root: Work around Cobra 1.1.2's handling of usage functions
In version 1.1.2 of Cobra has been included a change[0] that changes
how custom usage functions are handled.

Example of the wrong behaviour:
$ toolbox --foo
Error: unknown flag: --foo
Run 'toolbox --help' for usage.Error: Run 'toolbox --help' for usage.

Desired behaviour:
$ toolbox --foo
Error: unknown flag: --foo
Run 'toolbox --help' for usage.

A workaround is to define a template string for the usage instead. The
template uses the templating language of Go[1]. See the default
template string in version 1.2.1[2].

Because the template is set only once, the executableBase needs to be
set before the template is applied. That required the move of
setUpGlobals() into init() of the cmd package. This is a better place
for the function call as init() is called earlier than Execute()[3].

Upstream issue: https://github.com/spf13/cobra/issues/1532

[0] https://github.com/spf13/cobra/pull/1044
[1] https://pkg.go.dev/text/template
[2] https://github.com/spf13/cobra/blob/v1.2.1/command.go#L491
[3] https://golang.org/doc/effective_go#init

https://github.com/containers/toolbox/pull/917
2021-12-17 16:25:46 +01:00
Ondřej Míchal
b49149f0c5 src: Update dependencies with 'go get -u=patch'
- github.com/HarryMichal/go-version v1.0.0 => v1.0.1
- github.com/fsnotify/fsnotify v1.4.7 => v1.4.9
- github.com/godbus/dbus/v5 v5.0.3 => v5.0.6
- github.com/mattn/go-isatty v0.0.8 => v0.0.14
- github.com/spf13/cobra v0.0.5 => v0.0.7
- github.com/spf13/viper v1.3.2 => v1.4.0
- golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9 => v0.0.0-20211115234514-b4de73f9ece8
- golang.org/x/sys v0.0.0-20190422165155-953cdadca894 => v0.0.0-20211113001501-0c823b97ae02

https://github.com/containers/toolbox/pull/917
2021-12-17 15:19:46 +01:00
Debarshi Ray
708fa593e2 doc: Document the configuration file
https://github.com/containers/toolbox/pull/963
2021-12-17 13:23:37 +01:00
Debarshi Ray
0e78e4a313 build: Don't assume that all the pages are in section 1 of the manual
This will be used by the subsequent commit to add a page to document
the configuration file, which should go into section 5 of the manual.

https://github.com/containers/toolbox/pull/963
2021-12-17 13:23:33 +01:00