mirror of
https://github.com/podman-container-tools/podman.git
synced 2026-09-10 09:37:52 +00:00
(cherry picked from commit 4231526e18)
The common v0.57.7 vendor bump added !remote build tags to libimage,
causing podman-remote builds to fail. This change splits files that
use libimage into separate _local and _remote variants:
- pkg/specgen/specgen_{local,remote}.go: Image field storage and methods
- pkg/api/handlers/types_local.go: ImageDataToImageInspect function
- cmd/podman/utils/error_local.go: ExitCodeFromBuildError function
This allows type definitions to be shared between remote and local
builds while keeping libimage-dependent implementations local-only.
Signed-off-by: Lokesh Mandvekar <lsm5@redhat.com>
33 lines
907 B
Go
33 lines
907 B
Go
//go:build !remote
|
|
|
|
package utils
|
|
|
|
import (
|
|
"errors"
|
|
"strconv"
|
|
"strings"
|
|
|
|
buildahCLI "github.com/containers/buildah/pkg/cli"
|
|
)
|
|
|
|
/*
|
|
For remote client, server does not returns error with exit code
|
|
instead returns a message and we cast it to a new error.
|
|
|
|
Following function performs parsing on build error and returns
|
|
exit status which was expected for this current build
|
|
*/
|
|
func ExitCodeFromBuildError(errorMsg string) (int, error) {
|
|
if strings.Contains(errorMsg, "exit status") {
|
|
errorSplit := strings.Split(errorMsg, " ")
|
|
if errorSplit[len(errorSplit)-2] == "status" {
|
|
tmpSplit := strings.Split(errorSplit[len(errorSplit)-1], "\n")
|
|
exitCodeRemote, err := strconv.Atoi(tmpSplit[0])
|
|
if err == nil {
|
|
return exitCodeRemote, nil
|
|
}
|
|
return buildahCLI.ExecErrorCodeGeneric, err
|
|
}
|
|
}
|
|
return buildahCLI.ExecErrorCodeGeneric, errors.New("message does not contains a valid exit code")
|
|
}
|