Commit Graph

69 Commits

Author SHA1 Message Date
Stéphane Graber
6728a1eafc
global: Update for go-yaml/v4 rc5
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2026-06-10 22:26:22 -04:00
Stéphane Graber
3675d12eba
shared/subprocess: Log deferred errors with WarnOnError
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2026-06-06 19:15:12 -04:00
Stéphane Graber
40dd4f151d
Rewrite Go import path to v7
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2026-05-02 01:18:25 +02:00
Stéphane Graber
e57a32b762
shared/subprocess: Cleanup pointless check
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2026-04-17 21:02:28 -04:00
Stéphane Graber
28e767d808
shared/subprocess: Switch to go-yaml/v4
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2026-03-31 16:14:28 -04:00
Nathan Chase
aba6837ee4
shared/subprocess: Don't needlessly use format string functions
Signed-off-by: Nathan Chase <ntc477@utexas.edu>
2025-05-23 01:42:42 -04:00
JUN JIE NAN
23bfc8a010
shared/subprocess: Simplify code by using modern constructs
Using more modern features of Go, such as:
- conditional assignment -> built-in min or max in go1.21,
- sort.Slice -> slices.Sort in go1.21,
- loop assign map -> maps.Copy in go1.21,
- []byte(fmt.Sprintf...) -> fmt.Appendf(nil,...) in go1.19,
- strings.HasPrefix / strings.TrimPrefix -> strings.CutPrefix in go1.20

Signed-off-by: JUN JIE NAN <nanjunjie@gmail.com>
2025-05-17 12:33:44 -04:00
Stéphane Graber
60927988b8
shared/subprocess: Make golangci-lint clean
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2025-04-03 00:10:30 -04:00
Stéphane Graber
ca087ff47d
shared/subprocess: Fix gofumpt
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2025-03-17 20:56:25 -04:00
Stéphane Graber
5cb502bf3b
shared/subprocess: Allow overriding Cwd
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2024-11-14 20:57:47 -05:00
Mathias Gibbens
c25c6e5e96
shared/subprocess: Add TryRunCommandAttemptsDuration() which allows the caller to specify the number of attempts and duration between each attempt
Signed-off-by: Mathias Gibbens <mathias.gibbens@futurfusion.io>
2024-10-02 17:26:08 -04:00
Stéphane Graber
170bef15d0
shared/subprocess: Fix gofmt
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2024-07-11 14:54:59 -04:00
Stéphane Graber
6fb4b53377
shared/subprocess: Allow building on Windows
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2024-07-10 23:34:45 -04:00
Stéphane Graber
09dc3e60bc
global: Update Go package to v6
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2024-04-05 11:11:11 -04:00
Stéphane Graber
8f5f80ea8f
shared/subprocess: Improve error handling
This generally improves the error handling around finding processes and
works around a Go change in tip.

Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2024-02-21 23:37:47 -05:00
Simon Deziel
5317249c86
[lxd-import] shared/util: use LC_ALL instead of LANG in RunCommandCLocale()
https://www.gnu.org/savannah-checkouts/gnu/gettext/manual/html_node/Locale-Environment-Variables.html:

> LC_ALL is an environment variable that overrides all of the LC_*.
> It is typically used in scripts that run particular programs.

This *might* help with #11902

Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
2023-10-03 17:48:53 -04:00
Stéphane Graber
aa6ce1469a
shared: Eliminate use of shared package
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2023-09-28 04:33:41 -04:00
Stéphane Graber
6b0dc934e6
shared/subprocess: Fix bad copy/paste
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2023-09-28 04:33:32 -04:00
Stéphane Graber
b81af5098b
shared/subprocess: Don't use internal packages
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2023-09-13 23:24:40 -04:00
Stéphane Graber
09c067f8f6
shares/util: Move RunCommand to shared/subprocess
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2023-09-08 10:35:59 -04:00
Stéphane Graber
adabac67cc
global: Update for internal/idmap
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2023-09-07 15:40:35 -04:00
Stéphane Graber
f08d71c17e
shared: Update for lxc/incus
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2023-08-08 23:35:43 -04:00
Stéphane Graber
4d1c75206b
shared: Update env variables
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2023-08-03 01:46:19 -04:00
Aleksa Sarai
ab0295afdd
global: update go import paths to github.com/cyphar/incus
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2023-08-01 07:27:12 +10:00
Thomas Parrott
284e7c3e0c
shared/subprocess/proc: Fix go routine leak in start
We should not call cmd.Process.Wait() as otherwise there is go routine leak
as the error channel collected in cmd.Wait() isn't collected.

Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
2023-07-11 15:35:04 +01:00
Thomas Parrott
adb697c4e1
shared: Rename imports to new go module
Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>

And make tests go fmt safe.

Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
2023-07-04 22:13:07 +01:00
Thomas Parrott
f5eb24080d shared/subprocess/proc: Respect LXD_SECURITY_APPARMOR env var
Fixes #11675

Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
2023-05-16 09:19:53 +01:00
Simon Deziel
eb94a1ba80 shared/subprocess/testscript/signal.sh: lookup signal name to trap
https://www.shellcheck.net/wiki/SC2172

Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
2022-11-28 17:35:37 -05:00
Eng Zer Jun
915b227966
shared: move from io/ioutil to io and os packages
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-10-02 15:10:57 +08:00
Thomas Parrott
6e573ba372 lxd/device: subprocess usage
Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
2022-09-08 10:01:51 +01:00
Thomas Parrott
47b3a00470 shared/subprocess/manager: Removes redundant error return value from NewProcessWithFds
It was always nil.

Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
2022-09-08 10:01:51 +01:00
Thomas Parrott
ec1334d370 shared/subprocess/proc: Adds context support
Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
2022-09-08 10:01:51 +01:00
Mark Laing
b0ca5d91e9 shared: Inserts newlines after blocks.
Signed-off-by: Mark Laing <mark.laing@canonical.com>
2022-06-29 09:56:22 +01:00
Mark Laing
ff509220ad shared/subprocess: Fixes imports.
Signed-off-by: Mark Laing <mark.laing@canonical.com>
2022-06-28 10:27:20 +01:00
Mark Laing
f45832c4a9 shared/subprocess: Ends all comments with a full-stop.
Signed-off-by: Mark Laing <mark.laing@canonical.com>
2022-06-28 10:27:20 +01:00
Thomas Parrott
a12dd42338 shared/subprocess/manager: Improve errors in ImportProcess
Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
2022-06-27 12:12:17 +01:00
Mark Laing
7524bb279d shared: Checks or explicitly ignores errors.
Signed-off-by: Mark Laing <mark.laing@canonical.com>
2022-05-19 12:48:57 +01:00
Stéphane Graber
b556879294
shared/subprocess: Fix comment
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2022-04-12 17:17:28 -04:00
Stéphane Graber
ce9365f5cd
global: Remove legacy build tags
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2022-04-11 18:30:58 -04:00
Stéphane Graber
8604637ed6
shared/subprocess: Add SetUserns
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2022-04-11 18:30:15 -04:00
Thomas Hipp
55c7e31775
Replace github.com/pkg/errors with fmt and errors
This removes the usage of github.com/pkg/errors in favor of the fmt
and errors packages from the standard library.

Signed-off-by: Thomas Hipp <thomas.hipp@canonical.com>
2022-03-02 13:36:15 +01:00
Piotr Resztak
80cf29883e shared/subprocess: Support for file descriptors
Signed-off-by: Piotr Resztak <piotr.resztak@gmail.com>
2022-02-23 16:46:44 +01:00
Thomas Parrott
5426b746c0 shared/subprocess/proc: Simplify process cleanup channel closure
Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
2021-11-17 16:32:16 +00:00
Thomas Parrott
4919fa47ed shared/subprocess: Fix tests to use p.Wait() with context
Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
2021-05-19 17:08:56 +01:00
Thomas Parrott
2de4326052 shared/subprocess/proc: Adds context support to Wait
Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
2021-05-19 17:00:58 +01:00
Thomas Parrott
2e6d28ceed shared/subprocess/proc: Add exit code to error message
Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
2021-05-19 16:29:36 +01:00
Stéphane Graber
2a9aa8f5bc
Update for Go 1.17 go:build tags
This is the output of "gofmt -s -w ./" from current Go development branch.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2021-02-23 21:55:34 -05:00
Stéphane Graber
0c8fd1c6bd
shared/subprocess: Restrict to unix
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2021-01-27 22:33:16 -05:00
Stéphane Graber
0e8a905ce1
shared/subprocess: Set err on non-zero
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2020-09-15 21:54:12 -04:00
Stéphane Graber
eb97c1ef8f
shared/subprocess: Add StartWithFiles
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2020-08-13 18:27:57 -04:00