mirror of
https://github.com/containers/podman.git
synced 2025-08-06 19:44:14 +08:00
update github.com/rootless-containers/rootlesskit to v2
Contains a breaking change but also besides this renovate is not able to update the import paths so this needs to be done by hand. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
@ -8,11 +8,6 @@ const (
|
||||
Version = "1.1.1"
|
||||
)
|
||||
|
||||
// ErrorJSON is returned with "application/json" content type and non-2XX status code
|
||||
type ErrorJSON struct {
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
// Info is the structure returned by `GET /info`
|
||||
type Info struct {
|
||||
APIVersion string `json:"apiVersion"` // REST API version
|
@ -1,5 +1,5 @@
|
||||
// Package msgutil provides utility for JSON message with uint32le header
|
||||
package msgutil
|
||||
// Package lowlevelmsgutil provides utility for JSON message with uint32le header
|
||||
package lowlevelmsgutil
|
||||
|
||||
import (
|
||||
"bytes"
|
@ -3,9 +3,9 @@ package builtin
|
||||
import (
|
||||
"io"
|
||||
|
||||
"github.com/rootless-containers/rootlesskit/pkg/port"
|
||||
"github.com/rootless-containers/rootlesskit/pkg/port/builtin/child"
|
||||
"github.com/rootless-containers/rootlesskit/pkg/port/builtin/parent"
|
||||
"github.com/rootless-containers/rootlesskit/v2/pkg/port"
|
||||
"github.com/rootless-containers/rootlesskit/v2/pkg/port/builtin/child"
|
||||
"github.com/rootless-containers/rootlesskit/v2/pkg/port/builtin/parent"
|
||||
)
|
||||
|
||||
var (
|
@ -11,10 +11,11 @@ import (
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
|
||||
"github.com/rootless-containers/rootlesskit/pkg/msgutil"
|
||||
"github.com/rootless-containers/rootlesskit/pkg/port"
|
||||
"github.com/rootless-containers/rootlesskit/pkg/port/builtin/msg"
|
||||
opaquepkg "github.com/rootless-containers/rootlesskit/pkg/port/builtin/opaque"
|
||||
"github.com/containernetworking/plugins/pkg/ns"
|
||||
"github.com/rootless-containers/rootlesskit/v2/pkg/lowlevelmsgutil"
|
||||
"github.com/rootless-containers/rootlesskit/v2/pkg/port"
|
||||
"github.com/rootless-containers/rootlesskit/v2/pkg/port/builtin/msg"
|
||||
opaquepkg "github.com/rootless-containers/rootlesskit/v2/pkg/port/builtin/opaque"
|
||||
)
|
||||
|
||||
func NewDriver(logWriter io.Writer) port.ChildDriver {
|
||||
@ -27,7 +28,7 @@ type childDriver struct {
|
||||
logWriter io.Writer
|
||||
}
|
||||
|
||||
func (d *childDriver) RunChildDriver(opaque map[string]string, quit <-chan struct{}) error {
|
||||
func (d *childDriver) RunChildDriver(opaque map[string]string, quit <-chan struct{}, detachedNetNSPath string) error {
|
||||
socketPath := opaque[opaquepkg.SocketPath]
|
||||
if socketPath == "" {
|
||||
return errors.New("socket path not set")
|
||||
@ -68,34 +69,40 @@ func (d *childDriver) RunChildDriver(opaque map[string]string, quit <-chan struc
|
||||
return err
|
||||
}
|
||||
go func() {
|
||||
if rerr := d.routine(c); rerr != nil {
|
||||
if rerr := d.routine(c, detachedNetNSPath); rerr != nil {
|
||||
rep := msg.Reply{
|
||||
Error: rerr.Error(),
|
||||
}
|
||||
msgutil.MarshalToWriter(c, &rep)
|
||||
lowlevelmsgutil.MarshalToWriter(c, &rep)
|
||||
}
|
||||
c.Close()
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
func (d *childDriver) routine(c *net.UnixConn) error {
|
||||
func (d *childDriver) routine(c *net.UnixConn, detachedNetNSPath string) error {
|
||||
var req msg.Request
|
||||
if _, err := msgutil.UnmarshalFromReader(c, &req); err != nil {
|
||||
if _, err := lowlevelmsgutil.UnmarshalFromReader(c, &req); err != nil {
|
||||
return err
|
||||
}
|
||||
switch req.Type {
|
||||
case msg.RequestTypeInit:
|
||||
return d.handleConnectInit(c, &req)
|
||||
case msg.RequestTypeConnect:
|
||||
return d.handleConnectRequest(c, &req)
|
||||
if detachedNetNSPath == "" {
|
||||
return d.handleConnectRequest(c, &req)
|
||||
} else {
|
||||
return ns.WithNetNSPath(detachedNetNSPath, func(_ ns.NetNS) error {
|
||||
return d.handleConnectRequest(c, &req)
|
||||
})
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("unknown request type %q", req.Type)
|
||||
}
|
||||
}
|
||||
|
||||
func (d *childDriver) handleConnectInit(c *net.UnixConn, req *msg.Request) error {
|
||||
_, err := msgutil.MarshalToWriter(c, nil)
|
||||
_, err := lowlevelmsgutil.MarshalToWriter(c, nil)
|
||||
return err
|
||||
}
|
||||
|
@ -8,8 +8,8 @@ import (
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
|
||||
"github.com/rootless-containers/rootlesskit/pkg/msgutil"
|
||||
"github.com/rootless-containers/rootlesskit/pkg/port"
|
||||
"github.com/rootless-containers/rootlesskit/v2/pkg/lowlevelmsgutil"
|
||||
"github.com/rootless-containers/rootlesskit/v2/pkg/port"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -35,14 +35,14 @@ func Initiate(c *net.UnixConn) error {
|
||||
req := Request{
|
||||
Type: RequestTypeInit,
|
||||
}
|
||||
if _, err := msgutil.MarshalToWriter(c, &req); err != nil {
|
||||
if _, err := lowlevelmsgutil.MarshalToWriter(c, &req); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := c.CloseWrite(); err != nil {
|
||||
return err
|
||||
}
|
||||
var rep Reply
|
||||
if _, err := msgutil.UnmarshalFromReader(c, &rep); err != nil {
|
||||
if _, err := lowlevelmsgutil.UnmarshalFromReader(c, &rep); err != nil {
|
||||
return err
|
||||
}
|
||||
return c.CloseRead()
|
||||
@ -57,7 +57,7 @@ func ConnectToChild(c *net.UnixConn, spec port.Spec) (int, error) {
|
||||
Port: spec.ChildPort,
|
||||
IP: spec.ChildIP,
|
||||
}
|
||||
if _, err := msgutil.MarshalToWriter(c, &req); err != nil {
|
||||
if _, err := lowlevelmsgutil.MarshalToWriter(c, &req); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if err := c.CloseWrite(); err != nil {
|
@ -14,13 +14,13 @@ import (
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/rootless-containers/rootlesskit/pkg/api"
|
||||
"github.com/rootless-containers/rootlesskit/pkg/port"
|
||||
"github.com/rootless-containers/rootlesskit/pkg/port/builtin/msg"
|
||||
"github.com/rootless-containers/rootlesskit/pkg/port/builtin/opaque"
|
||||
"github.com/rootless-containers/rootlesskit/pkg/port/builtin/parent/tcp"
|
||||
"github.com/rootless-containers/rootlesskit/pkg/port/builtin/parent/udp"
|
||||
"github.com/rootless-containers/rootlesskit/pkg/port/portutil"
|
||||
"github.com/rootless-containers/rootlesskit/v2/pkg/api"
|
||||
"github.com/rootless-containers/rootlesskit/v2/pkg/port"
|
||||
"github.com/rootless-containers/rootlesskit/v2/pkg/port/builtin/msg"
|
||||
"github.com/rootless-containers/rootlesskit/v2/pkg/port/builtin/opaque"
|
||||
"github.com/rootless-containers/rootlesskit/v2/pkg/port/builtin/parent/tcp"
|
||||
"github.com/rootless-containers/rootlesskit/v2/pkg/port/builtin/parent/udp"
|
||||
"github.com/rootless-containers/rootlesskit/v2/pkg/port/portutil"
|
||||
)
|
||||
|
||||
// NewDriver for builtin driver.
|
@ -8,8 +8,8 @@ import (
|
||||
"strconv"
|
||||
"sync"
|
||||
|
||||
"github.com/rootless-containers/rootlesskit/pkg/port"
|
||||
"github.com/rootless-containers/rootlesskit/pkg/port/builtin/msg"
|
||||
"github.com/rootless-containers/rootlesskit/v2/pkg/port"
|
||||
"github.com/rootless-containers/rootlesskit/v2/pkg/port/builtin/msg"
|
||||
)
|
||||
|
||||
func Run(socketPath string, spec port.Spec, stopCh <-chan struct{}, stoppedCh chan error, logWriter io.Writer) error {
|
@ -7,9 +7,9 @@ import (
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/rootless-containers/rootlesskit/pkg/port"
|
||||
"github.com/rootless-containers/rootlesskit/pkg/port/builtin/msg"
|
||||
"github.com/rootless-containers/rootlesskit/pkg/port/builtin/parent/udp/udpproxy"
|
||||
"github.com/rootless-containers/rootlesskit/v2/pkg/port"
|
||||
"github.com/rootless-containers/rootlesskit/v2/pkg/port/builtin/msg"
|
||||
"github.com/rootless-containers/rootlesskit/v2/pkg/port/builtin/parent/udp/udpproxy"
|
||||
)
|
||||
|
||||
func Run(socketPath string, spec port.Spec, stopCh <-chan struct{}, stoppedCh chan error, logWriter io.Writer) error {
|
@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"net"
|
||||
|
||||
"github.com/rootless-containers/rootlesskit/pkg/api"
|
||||
"github.com/rootless-containers/rootlesskit/v2/pkg/api"
|
||||
)
|
||||
|
||||
type Spec struct {
|
||||
@ -35,8 +35,6 @@ type Manager interface {
|
||||
|
||||
// ChildContext is used for RunParentDriver
|
||||
type ChildContext struct {
|
||||
// PID of the child, can be used for ns-entering to the child namespaces.
|
||||
PID int
|
||||
// IP of the tap device
|
||||
IP net.IP
|
||||
}
|
||||
@ -57,5 +55,6 @@ type ParentDriver interface {
|
||||
}
|
||||
|
||||
type ChildDriver interface {
|
||||
RunChildDriver(opaque map[string]string, quit <-chan struct{}) error
|
||||
// RunChildDriver is executed in the child's namespaces, excluding detached-netns.
|
||||
RunChildDriver(opaque map[string]string, quit <-chan struct{}, detachedNetNSPath string) error
|
||||
}
|
@ -7,7 +7,7 @@ import (
|
||||
"strings"
|
||||
"text/scanner"
|
||||
|
||||
"github.com/rootless-containers/rootlesskit/pkg/port"
|
||||
"github.com/rootless-containers/rootlesskit/v2/pkg/port"
|
||||
)
|
||||
|
||||
// ParsePortSpec parses a Docker-like representation of PortSpec, but with
|
||||
@ -16,13 +16,13 @@ import (
|
||||
//
|
||||
// Format is as follows:
|
||||
//
|
||||
// <parent IP>:<parent port>[:<child IP>]:<child port>/<proto>
|
||||
// <parent IP>:<parent port>[:<child IP>]:<child port>/<proto>
|
||||
//
|
||||
// Note that (child IP being optional) the format can either contain 5 or 4
|
||||
// components. When using IPv6 IP addresses, addresses must use square brackets
|
||||
// to prevent the colons being mistaken for delimiters. For example:
|
||||
//
|
||||
// [::1]:8080:[::2]:80/udp
|
||||
// [::1]:8080:[::2]:80/udp
|
||||
func ParsePortSpec(portSpec string) (*port.Spec, error) {
|
||||
const (
|
||||
parentIP = iota
|
Reference in New Issue
Block a user