dagger.#Socket support

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi
2021-09-16 17:18:05 -07:00
parent 26becd29e3
commit 5480fb991d
7 changed files with 129 additions and 11 deletions

View File

@@ -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",