dagger.#Socket support
Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
@@ -492,6 +492,7 @@ func (p *Pipeline) mount(ctx context.Context, dest string, mnt *compiler.Value)
|
||||
return nil, fmt.Errorf("invalid mount source: %q", s)
|
||||
}
|
||||
}
|
||||
|
||||
// eg. mount: "/foo": secret: mysecret
|
||||
if secret := mnt.Lookup("secret"); secret.Exists() {
|
||||
id, err := getSecretID(secret)
|
||||
@@ -505,6 +506,28 @@ func (p *Pipeline) mount(ctx context.Context, dest string, mnt *compiler.Value)
|
||||
), nil
|
||||
}
|
||||
|
||||
// eg. mount: "/var/run/docker.sock": socket: mysocket
|
||||
if socket := mnt.Lookup("socket"); socket.Exists() {
|
||||
if !socket.HasAttr("socket") {
|
||||
return nil, fmt.Errorf("invalid socket %q: not a socket", socket.Path().String())
|
||||
}
|
||||
|
||||
unixValue := socket.Lookup("unix")
|
||||
if !unixValue.Exists() {
|
||||
return nil, fmt.Errorf("invalid socket %q: not a unix socket", socket.Path().String())
|
||||
}
|
||||
|
||||
unix, err := unixValue.String()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("invalid unix path id: %w", err)
|
||||
}
|
||||
|
||||
return llb.AddSSHSocket(
|
||||
llb.SSHID(fmt.Sprintf("unix=%s", unix)),
|
||||
llb.SSHSocketTarget(dest),
|
||||
), nil
|
||||
}
|
||||
|
||||
// eg. mount: "/foo": { from: www.source }
|
||||
if !mnt.Lookup("from").Exists() {
|
||||
return nil, fmt.Errorf("invalid mount: should have %s structure",
|
||||
|
Reference in New Issue
Block a user