summaryrefslogtreecommitdiff
path: root/pkg/api/handlers/compat
diff options
context:
space:
mode:
authorAditya Rajan <arajan@redhat.com>2021-11-26 18:18:30 +0530
committerAditya Rajan <arajan@redhat.com>2021-11-30 14:19:29 +0530
commite7204178e175d8ad619faa626ba284c777886cd3 (patch)
tree4903432e6c852b299695a92756cfc72bb1476186 /pkg/api/handlers/compat
parentbfcaf538bb000d7eb72975d234a95f566da54715 (diff)
downloadpodman-e7204178e175d8ad619faa626ba284c777886cd3.tar.gz
podman-e7204178e175d8ad619faa626ba284c777886cd3.tar.bz2
podman-e7204178e175d8ad619faa626ba284c777886cd3.zip
podman-remote: copy secret to contextdir is absolute path on host
Podman remote must treat build secrets as part of context directory. If secret path is absolute path on host copy it to tar file and pass it to remote server. Signed-off-by: Aditya Rajan <arajan@redhat.com>
Diffstat (limited to 'pkg/api/handlers/compat')
-rw-r--r--pkg/api/handlers/compat/images_build.go23
1 files changed, 22 insertions, 1 deletions
diff --git a/pkg/api/handlers/compat/images_build.go b/pkg/api/handlers/compat/images_build.go
index 18f9dc98b..200d72192 100644
--- a/pkg/api/handlers/compat/images_build.go
+++ b/pkg/api/handlers/compat/images_build.go
@@ -247,7 +247,28 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
utils.BadRequest(w, "secrets", query.Secrets, err)
return
}
- secrets = m
+
+ // for podman-remote all secrets must be picked from context director
+ // hence modify src so contextdir is added as prefix
+
+ for _, secret := range m {
+ secretOpt := strings.Split(secret, ",")
+ if len(secretOpt) > 0 {
+ modifiedOpt := []string{}
+ for _, token := range secretOpt {
+ arr := strings.SplitN(token, "=", 2)
+ if len(arr) > 1 {
+ if arr[0] == "src" {
+ modifiedSrc := fmt.Sprintf("src=%s", filepath.Join(contextDirectory, arr[1]))
+ modifiedOpt = append(modifiedOpt, modifiedSrc)
+ } else {
+ modifiedOpt = append(modifiedOpt, token)
+ }
+ }
+ }
+ secrets = append(secrets, strings.Join(modifiedOpt[:], ","))
+ }
+ }
}
var output string