1
0
mirror of https://github.com/containers/buildah.git synced 2025-09-17 15:42:18 +03:00

24 Commits

Author SHA1 Message Date
Jan Kaluza
a0a9ac6380 Switch common, storage and image to monorepo.
Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
2025-08-29 15:04:28 +02:00
Kir Kolyshkin
84a3905f61 Use slices.Contains
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-08 15:26:01 -07:00
Kir Kolyshkin
7b15646547 Apply De Morgan's law to fix QF1001 warnings
This fixes the following warnings:

> chroot/run_test.go:319:39: QF1001: could apply De Morgan's law (staticcheck)
> 				if limit == unix.RLIM_INFINITY && !(rlim == nil || (rlim.Soft == unix.RLIM_INFINITY && rlim.Hard == unix.RLIM_INFINITY)) {
> 				                                  ^
> copier/copier.go:1012:92: QF1001: could apply De Morgan's law (staticcheck)
> 			if target, err := os.Readlink(filepath.Join(workingPath, components[0])); err == nil && !(len(components) == 1 && !evaluateFinalComponent) {
> 			                                                                                        ^
> run_linux.go:459:118: QF1001: could apply De Morgan's law (staticcheck)
> 	if !slices.Contains(volumes, resolvconf.DefaultResolvConf) && options.ConfigureNetwork != define.NetworkDisabled && !(len(b.CommonBuildOpts.DNSServers) == 1 && strings.ToLower(b.CommonBuildOpts.DNSServers[0]) == "none") {
> 	                                                                                                                    ^

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-07 13:01:56 -07:00
flouthoc
aadfc5cf30 unit_test: use Parallel test where possible
Add `t.Parallel()` to unit tests whereever its possible without race.

Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2025-02-04 11:07:15 -08:00
Eng Zer Jun
59024c41ad refactor: replace golang.org/x/exp with stdlib
These experimental packages are now available in the Go standard
library since Go 1.21:

	1. golang.org/x/exp/slices -> slices [1]
	2. golang.org/x/exp/maps -> maps [2]

[1]: https://go.dev/doc/go1.21#slices
[2]: https://go.dev/doc/go1.21#maps

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2025-01-24 00:27:55 +08:00
Nalin Dahyabhai
62709d718e Fix an error message in the chroot unit test
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-12-13 15:16:16 -05:00
Nalin Dahyabhai
4adca286fe chroot: on Linux, try to pivot_root before falling back to chroot
Unless --no-pivot or the equivalent API flag is set, try to pivot_root()
to enter the rootfs during Run().  Fall back to using chroot() as before
if that fails for any reason.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-12-12 14:33:12 -05:00
Nalin Dahyabhai
8ae99121c1 CI: enable the gofumpt linter
Turn on the gofumpt linter.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-08-15 13:17:44 -04:00
Kir Kolyshkin
24da18800e *: fix build tags
This change is generated by `go1.23rc2 fix ./...`.

Had to use go1.23rc2, since all released go versions have a bug
preventing it from working with `go 1.22.0` in go.mod (opened
https://github.com/golang/go/issues/68825,
https://github.com/golang/go/issues/68824 for awareness).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-08-09 17:05:30 -07:00
Nalin Dahyabhai
fdf1c75cd3 linters: unused arguments shouldn't have names
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-08-07 10:10:35 -04:00
Nalin Dahyabhai
4f0b619dd2 Use golang.org/x/exp/slices.Contains
... instead of github.com/containers/common/pkg/util.StringInSlice,
per linters.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-02-07 11:50:41 -05:00
Philip Dubé
a42bfd0191 Replace map[K]bool with map[K]struct{} where it makes sense
Signed-off-by: Philip Dubé <philip@peerdb.io>
2024-01-05 15:58:43 +00:00
Nalin Dahyabhai
2a3a956cbb chroot.setupChrootBindMounts: pay more attention to flags
Pay better attention to dev/nodev/exec/noexec/suid/nosuid/ro/rw flags on
bind, overlay, and tmpfs mounts when any of them are specified.  Stop
quietly adding "nodev" when it isn't asked for.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2023-10-20 09:46:58 -04:00
Eng Zer Jun
0c4b19ba83 test: use T.TempDir to create temporary test directory
This commit replaces `ioutil.TempDir` with `t.TempDir` in tests. The
directory created by `t.TempDir` is automatically removed when the test
and all its subtests complete.

Prior to this commit, temporary directory created using `ioutil.TempDir`
needs to be removed manually by calling `os.RemoveAll`, which is omitted
in some tests. The error handling boilerplate e.g.
	defer func() {
		if err := os.RemoveAll(dir); err != nil {
			t.Fatal(err)
		}
	}
is also tedious, but `t.TempDir` handles this for us nicely.

Reference: https://pkg.go.dev/testing#T.TempDir
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-08-20 21:13:27 +08:00
Sascha Grunert
ce384684c0 Switch to golang native error wrapping
We now use the golang error wrapping format specifier `%w` instead of
the deprecated github.com/pkg/errors package.

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2022-07-07 11:41:47 +02:00
Nalin Dahyabhai
81f2af5021 chroot: don't use the generate default seccomp filter for unit tests
When we link our test helper statically using the external linker, the
hardwired default seccomp filter we get from the runtime-tools generator
triggers a hang in it at startup.

Rather than switch to the internal linker, which seems to work around
this, start using the same seccomp filter for unit tests that we
actually use in real life, leaving analysis of which difference between
the two is responsible for it for another day.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-11-18 14:07:50 -05:00
Nalin Dahyabhai
1135bcac5e Fix an error message: unlocking vs locking
Don't complain about being unable to lock a descriptor when we attempted
to unlock it.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-11-11 14:22:11 -05:00
Nalin Dahyabhai
c6e2a5e87d Replace fmt.Sprintf("%d", x) with strconv.Itoa(x)
Replace calls to fmt.Sprintf("%d", x) with strconv.Itoa(x), which is
slightly faster.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-09-27 18:27:22 -04:00
Valentin Rothberg
9bf7586a1e chroot/run_test.go: export funcs to actually be executed
Reported by golangci-lint.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>

Closes: #1678
Approved by: rhatdan
2019-06-19 11:33:36 +00:00
Valentin Rothberg
7234f342e4 chroot/run_test.go: check errors
Reported by golangc-lint.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>

Closes: #1624
Approved by: TomSweeneyRedHat
2019-06-17 18:45:00 +00:00
TomSweeneyRedHat
e43b864952 Add default /root if empty on chroot iso
Checks to see if the $HOME envvar has been set
and if not, trys to set it as best as possible.

Fixes: #1592

Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Closes: #1594
Approved by: rhatdan
2019-05-22 06:53:33 +00:00
Miloslav Trmač
c8727b4033 Fix a few issues found by tests/validate/gometalinter.sh
For some reason, the CI does not report any of these; on macOS
I see many more reports (including complaints about the standard
library), this only cleans up the trivial cases.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>

Closes: #1365
Approved by: rhatdan
2019-02-25 10:27:46 +00:00
Daniel J Walsh
ba012ddec6 Move buildah from projecatatomic/buildah to containers/buildah
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2018-09-18 08:06:11 -04:00
Nalin Dahyabhai
38ef1231f2 Add and implement IsolationChroot
Add an IsolationChroot that trades flexibility and isolation for being
able to do what it does in a host environment that's already isolated to
the point where we're not allowed to set up some of that isolation,
producing a result that leans more toward chroot(1) than runc(1) does.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #836
Approved by: rhatdan
2018-08-01 14:04:59 +00:00