summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
Diffstat (limited to 'pkg')
-rw-r--r--pkg/api/handlers/decoder.go10
-rw-r--r--pkg/api/handlers/libpod/secrets.go8
-rw-r--r--pkg/domain/infra/abi/containers.go6
-rw-r--r--pkg/machine/qemu/config_test.go23
-rw-r--r--pkg/machine/qemu/machine.go5
5 files changed, 32 insertions, 20 deletions
diff --git a/pkg/api/handlers/decoder.go b/pkg/api/handlers/decoder.go
index 5e8f12960..fbe03d97b 100644
--- a/pkg/api/handlers/decoder.go
+++ b/pkg/api/handlers/decoder.go
@@ -21,6 +21,7 @@ func NewAPIDecoder() *schema.Decoder {
d.RegisterConverter(map[string][]string{}, convertURLValuesString)
d.RegisterConverter(time.Time{}, convertTimeString)
d.RegisterConverter(define.ContainerStatus(0), convertContainerStatusString)
+ d.RegisterConverter(map[string]string{}, convertStringMap)
var Signal syscall.Signal
d.RegisterConverter(Signal, convertSignal)
@@ -48,6 +49,15 @@ func convertURLValuesString(query string) reflect.Value {
return reflect.ValueOf(f)
}
+func convertStringMap(query string) reflect.Value {
+ res := make(map[string]string)
+ err := json.Unmarshal([]byte(query), &res)
+ if err != nil {
+ logrus.Infof("convertStringMap: Failed to Unmarshal %s: %s", query, err.Error())
+ }
+ return reflect.ValueOf(res)
+}
+
func convertContainerStatusString(query string) reflect.Value {
result, err := define.StringToContainerStatus(query)
if err != nil {
diff --git a/pkg/api/handlers/libpod/secrets.go b/pkg/api/handlers/libpod/secrets.go
index 8708e630c..3ea2c2ea8 100644
--- a/pkg/api/handlers/libpod/secrets.go
+++ b/pkg/api/handlers/libpod/secrets.go
@@ -1,9 +1,7 @@
package libpod
import (
- "encoding/json"
"net/http"
- "reflect"
"github.com/containers/podman/v4/libpod"
"github.com/containers/podman/v4/pkg/api/handlers/utils"
@@ -20,12 +18,6 @@ func CreateSecret(w http.ResponseWriter, r *http.Request) {
decoder = r.Context().Value(api.DecoderKey).(*schema.Decoder)
)
- decoder.RegisterConverter(map[string]string{}, func(str string) reflect.Value {
- res := make(map[string]string)
- json.Unmarshal([]byte(str), &res)
- return reflect.ValueOf(res)
- })
-
query := struct {
Name string `schema:"name"`
Driver string `schema:"driver"`
diff --git a/pkg/domain/infra/abi/containers.go b/pkg/domain/infra/abi/containers.go
index b56c36015..89b09bb1d 100644
--- a/pkg/domain/infra/abi/containers.go
+++ b/pkg/domain/infra/abi/containers.go
@@ -641,7 +641,11 @@ func (ic *ContainerEngine) ContainerRestore(ctx context.Context, namesOrIds []st
}
restoreOptions.CheckpointImageID = img.ID()
mountPoint, err := img.Mount(ctx, nil, "")
- defer img.Unmount(true)
+ defer func() {
+ if err := img.Unmount(true); err != nil {
+ logrus.Errorf("Failed to unmount image: %v", err)
+ }
+ }()
if err != nil {
return nil, err
}
diff --git a/pkg/machine/qemu/config_test.go b/pkg/machine/qemu/config_test.go
index 0fbb5b3bf..3f92881fa 100644
--- a/pkg/machine/qemu/config_test.go
+++ b/pkg/machine/qemu/config_test.go
@@ -68,9 +68,15 @@ func TestNewMachineFile(t *testing.T) {
p := "/var/tmp/podman/my.sock"
longp := filepath.Join(longTemp, utils.RandomString(100), "my.sock")
- os.MkdirAll(filepath.Dir(longp), 0755)
- f, _ := os.Create(longp)
- f.Close()
+ err = os.MkdirAll(filepath.Dir(longp), 0755)
+ if err != nil {
+ panic(err)
+ }
+ f, err := os.Create(longp)
+ if err != nil {
+ panic(err)
+ }
+ _ = f.Close()
sym := "my.sock"
longSym := filepath.Join(homedir, ".podman", sym)
@@ -120,14 +126,15 @@ func TestNewMachineFile(t *testing.T) {
},
}
for _, tt := range tests {
+ tt := tt
t.Run(tt.name, func(t *testing.T) {
- got, err := machine.NewMachineFile(tt.args.path, tt.args.symlink) //nolint: scopelint
- if (err != nil) != tt.wantErr { //nolint: scopelint
- t.Errorf("NewMachineFile() error = %v, wantErr %v", err, tt.wantErr) //nolint: scopelint
+ got, err := machine.NewMachineFile(tt.args.path, tt.args.symlink)
+ if (err != nil) != tt.wantErr {
+ t.Errorf("NewMachineFile() error = %v, wantErr %v", err, tt.wantErr)
return
}
- if !reflect.DeepEqual(got, tt.want) { //nolint: scopelint
- t.Errorf("NewMachineFile() got = %v, want %v", got, tt.want) //nolint: scopelint
+ if !reflect.DeepEqual(got, tt.want) {
+ t.Errorf("NewMachineFile() got = %v, want %v", got, tt.want)
}
})
}
diff --git a/pkg/machine/qemu/machine.go b/pkg/machine/qemu/machine.go
index 35eea5fb4..91e15c2af 100644
--- a/pkg/machine/qemu/machine.go
+++ b/pkg/machine/qemu/machine.go
@@ -484,12 +484,11 @@ func (v *MachineVM) Start(name string, _ machine.StartOptions) error {
if err := v.writeConfig(); err != nil {
return fmt.Errorf("writing JSON file: %w", err)
}
- defer func() error {
+ defer func() {
v.Starting = false
if err := v.writeConfig(); err != nil {
- return fmt.Errorf("writing JSON file: %w", err)
+ logrus.Errorf("Writing JSON file: %v", err)
}
- return nil
}()
if v.isIncompatible() {
logrus.Errorf("machine %q is incompatible with this release of podman and needs to be recreated, starting for recovery only", v.Name)