summaryrefslogtreecommitdiff
path: root/pkg/util/utils.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/util/utils.go')
-rw-r--r--pkg/util/utils.go27
1 files changed, 20 insertions, 7 deletions
diff --git a/pkg/util/utils.go b/pkg/util/utils.go
index e0f631eb4..a4c8f3a64 100644
--- a/pkg/util/utils.go
+++ b/pkg/util/utils.go
@@ -16,13 +16,14 @@ import (
"github.com/BurntSushi/toml"
"github.com/containers/common/pkg/config"
"github.com/containers/image/v5/types"
- "github.com/containers/podman/v2/pkg/errorhandling"
- "github.com/containers/podman/v2/pkg/namespaces"
- "github.com/containers/podman/v2/pkg/rootless"
- "github.com/containers/podman/v2/pkg/signal"
+ "github.com/containers/podman/v3/pkg/errorhandling"
+ "github.com/containers/podman/v3/pkg/namespaces"
+ "github.com/containers/podman/v3/pkg/rootless"
+ "github.com/containers/podman/v3/pkg/signal"
"github.com/containers/storage"
"github.com/containers/storage/pkg/idtools"
v1 "github.com/opencontainers/image-spec/specs-go/v1"
+ "github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"golang.org/x/crypto/ssh/terminal"
@@ -388,7 +389,6 @@ func GetKeepIDMapping() (*storage.IDMappingOptions, int, int, error) {
options.HostUIDMapping = false
options.HostGIDMapping = false
-
}
// Simply ignore the setting and do not setup an inner namespace for root as it is a no-op
return &options, uid, gid, nil
@@ -530,9 +530,9 @@ func ParseInputTime(inputTime string) (time.Time, error) {
}
}
- unix_timestamp, err := strconv.ParseInt(inputTime, 10, 64)
+ unixTimestamp, err := strconv.ParseInt(inputTime, 10, 64)
if err == nil {
- return time.Unix(unix_timestamp, 0), nil
+ return time.Unix(unixTimestamp, 0), nil
}
// input might be a duration
@@ -693,3 +693,16 @@ func CoresToPeriodAndQuota(cores float64) (uint64, int64) {
func PeriodAndQuotaToCores(period uint64, quota int64) float64 {
return float64(quota) / float64(period)
}
+
+// IDtoolsToRuntimeSpec converts idtools ID mapping to the one of the runtime spec.
+func IDtoolsToRuntimeSpec(idMaps []idtools.IDMap) (convertedIDMap []specs.LinuxIDMapping) {
+ for _, idmap := range idMaps {
+ tempIDMap := specs.LinuxIDMapping{
+ ContainerID: uint32(idmap.ContainerID),
+ HostID: uint32(idmap.HostID),
+ Size: uint32(idmap.Size),
+ }
+ convertedIDMap = append(convertedIDMap, tempIDMap)
+ }
+ return convertedIDMap
+}