summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
Diffstat (limited to 'pkg')
-rw-r--r--pkg/api/handlers/compat/events.go2
-rw-r--r--pkg/machine/ignition.go53
2 files changed, 55 insertions, 0 deletions
diff --git a/pkg/api/handlers/compat/events.go b/pkg/api/handlers/compat/events.go
index 901acdac4..bc31a36c4 100644
--- a/pkg/api/handlers/compat/events.go
+++ b/pkg/api/handlers/compat/events.go
@@ -91,6 +91,8 @@ func GetEvents(w http.ResponseWriter, r *http.Request) {
e := entities.ConvertToEntitiesEvent(*evt)
if !utils.IsLibpodRequest(r) && e.Status == "died" {
e.Status = "die"
+ e.Action = "die"
+ e.Actor.Attributes["exitCode"] = e.Actor.Attributes["containerExitCode"]
}
if err := coder.Encode(e); err != nil {
diff --git a/pkg/machine/ignition.go b/pkg/machine/ignition.go
index 139318977..84d3be296 100644
--- a/pkg/machine/ignition.go
+++ b/pkg/machine/ignition.go
@@ -7,7 +7,10 @@ import (
"fmt"
"io/ioutil"
"net/url"
+ "os"
"path/filepath"
+
+ "github.com/sirupsen/logrus"
)
/*
@@ -355,6 +358,56 @@ machine_enabled=true
},
})
+ // get certs for current user
+ userHome, err := os.UserHomeDir()
+ if err != nil {
+ logrus.Warnf("Unable to copy certs via ignition %s", err.Error())
+ return files
+ }
+
+ certFiles := getCerts(filepath.Join(userHome, ".config/containers/certs.d"))
+ files = append(files, certFiles...)
+
+ certFiles = getCerts(filepath.Join(userHome, ".config/docker/certs.d"))
+ files = append(files, certFiles...)
+
+ return files
+}
+
+func getCerts(certsDir string) []File {
+ var (
+ files []File
+ )
+
+ certs, err := ioutil.ReadDir(certsDir)
+ if err == nil {
+ for _, cert := range certs {
+ b, err := ioutil.ReadFile(filepath.Join(certsDir, cert.Name()))
+ if err != nil {
+ logrus.Warnf("Unable to read cert file %s", err.Error())
+ continue
+ }
+ files = append(files, File{
+ Node: Node{
+ Group: getNodeGrp("root"),
+ Path: filepath.Join("/etc/containers/certs.d/", cert.Name()),
+ User: getNodeUsr("root"),
+ },
+ FileEmbedded1: FileEmbedded1{
+ Append: nil,
+ Contents: Resource{
+ Source: encodeDataURLPtr(string(b)),
+ },
+ Mode: intToPtr(0644),
+ },
+ })
+ }
+ } else {
+ if !os.IsNotExist(err) {
+ logrus.Warnf("Unable to copy certs via ignition, error while reading certs from %s: %s", certsDir, err.Error())
+ }
+ }
+
return files
}