From e4b11deb3d47709ab5503af711d5cff4beff7da6 Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Mon, 24 Jul 2017 12:33:14 -0700 Subject: [PATCH] llb: add missing runoptions and fixing scratch input Signed-off-by: Tonis Tiigi --- client/llb/exec.go | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/client/llb/exec.go b/client/llb/exec.go index 7af4082f8..63c79bfc1 100644 --- a/client/llb/exec.go +++ b/client/llb/exec.go @@ -125,7 +125,7 @@ func (e *ExecOp) Marshal() ([]byte, error) { pop.Inputs = append(pop.Inputs, inp) } } else { - inputIndex = 0 + inputIndex = pb.Empty } pm := &pb.Mount{ @@ -208,7 +208,42 @@ func Shlexf(str string, v ...interface{}) RunOption { } } -func AddMount(dest string, mountState *State, opts ...MountOption) RunOption { +func AddEnv(key, value string) RunOption { + return AddEnvf(key, value) +} + +func AddEnvf(key, value string, v ...interface{}) RunOption { + return func(ei ExecInfo) ExecInfo { + ei.State = ei.State.AddEnvf(key, value, v...) + return ei + } +} + +func Dir(str string) RunOption { + return Dirf(str) +} +func Dirf(str string, v ...interface{}) RunOption { + return func(ei ExecInfo) ExecInfo { + ei.State = ei.State.Dirf(str, v...) + return ei + } +} + +func Reset(s State) RunOption { + return func(ei ExecInfo) ExecInfo { + ei.State = ei.State.Reset(s) + return ei + } +} + +func With(so ...StateOption) RunOption { + return func(ei ExecInfo) ExecInfo { + ei.State = ei.State.With(so...) + return ei + } +} + +func AddMount(dest string, mountState State, opts ...MountOption) RunOption { return func(ei ExecInfo) ExecInfo { ei.Mounts = append(ei.Mounts, MountInfo{dest, mountState.Output(), opts}) return ei