Add --replace option to podman artifact add command

This commit implements the --replace functionality for the artifact add command,
allowing users to replace existing artifacts without having to manually remove
them first.

Changes made:
- Add Replace field to ArtifactAddOptions entity types
- Add --replace CLI flag with validation to prevent conflicts with --append
- Implement replace logic in ABI backend to remove existing artifacts before adding
- Update API handlers and tunnel implementation for podman-remote support
- Add comprehensive documentation and examples to man page
- Add e2e and system BATS tests for --replace functionality
- Fix code formatting in pkg/bindings/artifacts/types_pull_options.go:
  * Reorder imports with proper spacing
  * Fix function declaration spacing
  * Convert spaces to proper tab indentation
  * Remove extraneous blank lines

The --replace option follows the same pattern as other podman replace options
like 'podman container create --replace' and 'podman pod create --replace'.
It gracefully handles cases where no existing artifact exists (no error thrown).

Usage examples:
  podman artifact add --replace quay.io/myimage/artifact:latest /path/to/file
  podman artifact add --replace localhost/test/artifact /tmp/newfile.txt

Fixes: Implements requested --replace functionality for artifact add command
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
Daniel J Walsh
2025-09-30 06:28:41 -04:00
parent 80b20c7614
commit b765c91580
14 changed files with 345 additions and 14 deletions

View File

@ -191,6 +191,11 @@ func (s *APIServer) registerArtifactHandlers(r *mux.Router) error {
// description: Append files to an existing artifact
// type: boolean
// default: false
// - name: replace
// in: query
// description: Replace an existing artifact with the same name
// type: boolean
// default: false
// - name: inputStream
// in: body
// description: Binary stream of the file to add to an artifact