Skip to content

Commit

Permalink
Move devices code to unit specific directory.
Browse files Browse the repository at this point in the history
This change is required to allow podman for windows to build.

Signed-off-by: Daniel J Walsh <[email protected]>

Closes: containers#1855
Approved by: TomSweeneyRedHat
  • Loading branch information
rhatdan authored and rh-atomic-bot committed Sep 13, 2019
1 parent 9cac447 commit e58b898
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 19 deletions.
19 changes: 0 additions & 19 deletions pkg/parse/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@ import (
"unicode"

"github.com/containers/buildah"
"github.com/containers/buildah/pkg/unshare"
"github.com/containers/image/types"
"github.com/containers/storage/pkg/idtools"
"github.com/docker/go-units"
"github.com/opencontainers/runc/libcontainer/configs"
"github.com/opencontainers/runc/libcontainer/devices"
"github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -953,19 +950,3 @@ func isValidDeviceMode(mode string) bool {
}
return true
}

func DeviceFromPath(device string) (configs.Device, error) {
src, dst, permissions, err := Device(device)
if err != nil {
return configs.Device{}, err
}
if unshare.IsRootless() {
return configs.Device{}, errors.Errorf("Renameing device %s to %s is not a supported in rootless containers", src, dst)
}
dev, err := devices.DeviceFromPath(src, permissions)
if err != nil {
return configs.Device{}, errors.Wrapf(err, "%s is not a valid device", src)
}
dev.Path = dst
return *dev, nil
}
20 changes: 20 additions & 0 deletions pkg/parse/parse_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ package parse
import (
"fmt"

"github.com/containers/buildah/pkg/unshare"
"github.com/opencontainers/runc/libcontainer/configs"
"github.com/opencontainers/runc/libcontainer/devices"
"github.com/pkg/errors"
"golang.org/x/sys/unix"
)

Expand All @@ -19,3 +23,19 @@ func getDefaultProcessLimits() []string {
}
return defaultLimits
}

func DeviceFromPath(device string) (configs.Device, error) {
src, dst, permissions, err := Device(device)
if err != nil {
return configs.Device{}, err
}
if unshare.IsRootless() {
return configs.Device{}, errors.Errorf("Renaming device %s to %s is not a supported in rootless containers", src, dst)
}
dev, err := devices.DeviceFromPath(src, permissions)
if err != nil {
return configs.Device{}, errors.Wrapf(err, "%s is not a valid device", src)
}
dev.Path = dst
return *dev, nil
}
10 changes: 10 additions & 0 deletions pkg/parse/parse_unsupported.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

package parse

import (
"fmt"

"github.com/opencontainers/runc/libcontainer/configs"
)

func getDefaultProcessLimits() []string {
return []string{}
}

func DeviceFromPath(device string) (configs.Device, error) {
return configs.Device{}, fmt.Errorf("devices not supported")
}

0 comments on commit e58b898

Please sign in to comment.