summaryrefslogtreecommitdiff
path: root/pkg/util
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2019-06-25 08:40:19 -0500
committerbaude <bbaude@redhat.com>2019-06-27 07:56:24 -0500
commit8561b996447793999a6465f9b9e3f0f7bbea2c6a (patch)
tree133cf8d959934eac882535e6b572aee5d0acf3c5 /pkg/util
parent58a1777f518657ff12744bb69ccf2dab3d429625 (diff)
downloadpodman-8561b996447793999a6465f9b9e3f0f7bbea2c6a.tar.gz
podman-8561b996447793999a6465f9b9e3f0f7bbea2c6a.tar.bz2
podman-8561b996447793999a6465f9b9e3f0f7bbea2c6a.zip
libpod removal from main (phase 2)
this is phase 2 for the removal of libpod from main. Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'pkg/util')
-rw-r--r--pkg/util/utils.go11
-rw-r--r--pkg/util/utils_darwin.go11
-rw-r--r--pkg/util/utils_linux.go11
-rw-r--r--pkg/util/utils_supported.go5
-rw-r--r--pkg/util/utils_windows.go16
5 files changed, 47 insertions, 7 deletions
diff --git a/pkg/util/utils.go b/pkg/util/utils.go
index 61cdbbf38..9e49f08a0 100644
--- a/pkg/util/utils.go
+++ b/pkg/util/utils.go
@@ -337,3 +337,14 @@ func GetGlobalOpts(c *cliconfig.RunlabelValues) string {
})
return strings.Join(optsCommand, " ")
}
+
+// OpenExclusiveFile opens a file for writing and ensure it doesn't already exist
+func OpenExclusiveFile(path string) (*os.File, error) {
+ baseDir := filepath.Dir(path)
+ if baseDir != "" {
+ if _, err := os.Stat(baseDir); err != nil {
+ return nil, err
+ }
+ }
+ return os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0666)
+}
diff --git a/pkg/util/utils_darwin.go b/pkg/util/utils_darwin.go
new file mode 100644
index 000000000..33a46a5d4
--- /dev/null
+++ b/pkg/util/utils_darwin.go
@@ -0,0 +1,11 @@
+//+build darwin
+
+package util
+
+import (
+ "github.com/pkg/errors"
+)
+
+func GetContainerPidInformationDescriptors() ([]string, error) {
+ return []string{}, errors.New("this function is not supported on darwin")
+}
diff --git a/pkg/util/utils_linux.go b/pkg/util/utils_linux.go
new file mode 100644
index 000000000..47fa1031f
--- /dev/null
+++ b/pkg/util/utils_linux.go
@@ -0,0 +1,11 @@
+package util
+
+import (
+ "github.com/containers/psgo"
+)
+
+// GetContainerPidInformationDescriptors returns a string slice of all supported
+// format descriptors of GetContainerPidInformation.
+func GetContainerPidInformationDescriptors() ([]string, error) {
+ return psgo.ListDescriptors(), nil
+}
diff --git a/pkg/util/utils_supported.go b/pkg/util/utils_supported.go
index f8045f855..99c9e4f1e 100644
--- a/pkg/util/utils_supported.go
+++ b/pkg/util/utils_supported.go
@@ -7,11 +7,12 @@ package util
import (
"fmt"
- "github.com/containers/libpod/pkg/rootless"
- "github.com/pkg/errors"
"os"
"path/filepath"
"syscall"
+
+ "github.com/containers/libpod/pkg/rootless"
+ "github.com/pkg/errors"
)
// GetRootlessRuntimeDir returns the runtime directory when running as non root
diff --git a/pkg/util/utils_windows.go b/pkg/util/utils_windows.go
index 3faa6f10c..635558bf7 100644
--- a/pkg/util/utils_windows.go
+++ b/pkg/util/utils_windows.go
@@ -6,18 +6,24 @@ import (
"github.com/pkg/errors"
)
-// GetRootlessRuntimeDir returns the runtime directory when running as non root
-func GetRootlessRuntimeDir() (string, error) {
- return "", errors.New("this function is not implemented for windows")
-}
-
// IsCgroup2UnifiedMode returns whether we are running in cgroup 2 unified mode.
func IsCgroup2UnifiedMode() (bool, error) {
return false, errors.New("this function is not implemented for windows")
}
+// GetContainerPidInformationDescriptors returns a string slice of all supported
+// format descriptors of GetContainerPidInformation.
+func GetContainerPidInformationDescriptors() ([]string, error) {
+ return nil, errors.New("this function is not implemented for windows")
+}
+
// GetRootlessPauseProcessPidPath returns the path to the file that holds the pid for
// the pause process
func GetRootlessPauseProcessPidPath() (string, error) {
return "", errors.New("this function is not implemented for windows")
}
+
+// GetRootlessRuntimeDir returns the runtime directory when running as non root
+func GetRootlessRuntimeDir() (string, error) {
+ return "", errors.New("this function is not implemented for windows")
+}