9 Commits

Author SHA1 Message Date
copilot-swe-agent[bot]
f566e04888 chore: enable more linters and fix all critical issues
Enabled additional linters from fakemachine configuration:
- errorlint: Error wrapping with %w
- misspell: Spelling checks
- revive: Code quality checks
- whitespace: Formatting checks

Fixed all issues including:
- Error handling: Added proper error checks for all function returns
- Error wrapping: Changed %v to %w for proper error wrapping
- Type assertions: Used errors.As instead of direct type assertions
- Unused parameters: Renamed to underscore where appropriate
- Variable naming: Fixed ALL_CAPS constants and underscored names
- Whitespace: Removed unnecessary leading/trailing newlines
- Code flow: Removed unnecessary else blocks

Renamed types (breaking internal API changes):
- DebosState → State
- DebosContext → Context
- DownloadHttpUrl → DownloadHTTPURL

Fixed struct field naming with proper YAML tags:
- Url → URL (with yaml:"url" tag)
- TlsClientCertPath → TLSClientCertPath (kept yaml:"tls-client-cert-path")
- TlsClientKeyPath → TLSClientKeyPath (kept yaml:"tls-client-key-path")
- validateUrl → validateURL method

Co-authored-by: sjoerdsimons <22603932+sjoerdsimons@users.noreply.github.com>
2025-10-01 21:21:22 +02:00
Loïc Minier
38ffb9dd28 fix: Using a deprecated function, variable, constant or field (SA1019)
Reported by staticcheck

Signed-off-by: Loïc Minier <loic.minier@oss.qualcomm.com>
2025-09-05 09:24:07 +02:00
Loïc Minier
ae9d5574cc fix: Incorrectly formatted error string (ST1005)
Reported by staticcheck

Signed-off-by: Loïc Minier <loic.minier@oss.qualcomm.com>
2025-09-05 09:24:07 +02:00
Christopher Obbard
5412d8beac filesystem: Bubble up errors rather than panicing
If the overlay action fails to copy a file into the target filesystem
(e.g. destination path inside the filesystem doesn't exist), the current
behaviour is to panic, which causes a debos call inside the fakemachine
to panic, which isn't detected by the outer debos call.

This causes the execution of the inner debos call to stop (i.e. the
remaining recipe actions are no longer ran which is expected), but the
postexec commands still run and the overall exection is marked as
successful!

Rework the panics to instead bubble up errors so that any errors when
overlaying files causes the recipe to error out correctly rather than
this unexpected behaviour.

Before this commit is applied, the panic causes the debos call inside the
fakemachine to fail without being trapped by the outer debos call and the
outer debos call to still run the postprocess commands and exit with no
error as if the overlay action was successful:

    $ debos tests/overlay-non-existent-destination/overlay-non-existent-destination.yaml
    2023/07/05 11:07:24 ==== Overlay file to a non-existent destination ====
    2023/07/05 11:07:24 Overlaying tests/overlay-non-existent-destination/overlay-non-existent-destination.yaml on /scratch/root/this/path/does/not/exist
    2023/07/05 11:07:24 Failed to copy file tests/overlay-non-existent-destination/overlay-non-existent-destination.yaml: open /scratch/root/this/path/does/not/3277940894: no such file or directory
    2023/07/05 12:07:24 ==== run ====
    2023/07/05 12:07:24 echo Test | Test
    2023/07/05 12:07:24 ==== Recipe done ====
    $ echo $?
    0

With this commit applied, the execution of the outer debos call stops when
the overlay action fails and the error is correctly bubbled up to the user:

    $ debos tests/overlay-non-existent-destination/overlay-non-existent-destination.yaml
    2023/07/05 11:08:15 ==== Overlay file to a non-existent destination ====
    2023/07/05 11:08:15 Overlaying tests/overlay-non-existent-destination/overlay-non-existent-destination.yaml on /scratch/root/this/path/does/not/exist
    2023/07/05 11:08:15 Action `Overlay file to a non-existent destination` failed at stage Run, error: Failed to copy file tests/overlay-non-existent-destination/overlay-non-existent-destination.yaml: open /scratch/root/this/path/does/not/1742738134: no such file or directory
    $ echo $?
    1

Fixes: #401
Signed-off-by: Christopher Obbard <chris.obbard@collabora.com>
2023-07-10 19:42:19 +00:00
Christopher Obbard
b40722f4b6 actions: overlay: Log using action log functions
Currently the overlay action prints directly to stdout, which
ends up not following the standard output format the other
actions follow. Let's clean this up by using the action's
existing logging functions rather than printing directly
to stdout.

Signed-off-by: Christopher Obbard <chris.obbard@collabora.com>
2021-08-13 12:04:25 +01:00
Arnaud Rebillout
0f2b35e7af Abort on various error cases that were silently ignored
Various filesystem operations here and there are done without checking
the return value, so when it fails nobody knows and the user waste his
time understanding what's going on. Checking return values is useful.

Signed-off-by: Arnaud Rebillout <arnaud.rebillout@collabora.com>
2018-06-14 10:30:43 +02:00
Sjoerd Simons
d64043a99a Add realpath filesystem helper
Add a new function similar to the realpath C function to resolve the
canonical absolute path of a file.

Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
2017-12-22 08:38:33 +01:00
Denis Pynkin
a5150f2795 Fix typo in CopyTree function
Fix typo leading to incorrect error message in case of any problems
with links during FS copying.

Signed-off-by: Denis Pynkin <denis.pynkin@collabora.com>
2017-09-22 16:12:20 +03:00
Denis Pynkin
8a89531a6a Split debos main file
Initially 'debos.go' contained a lot of additions and logical parts in
single file. So move logical parts from 'debos.go' to appropriate packages:
- 'debos' package: actions interface and filesystem addons
- 'recipe' package: logic of Yaml-based recipe parsing

Use correct imports, naming and syntax for splitted files.

Signed-off-by: Denis Pynkin <denis.pynkin@collabora.com>
2017-09-05 15:24:37 +03:00