Skip to content

Commit 236d00b

Browse files
Use current OS as a default
Signed-off-by: Gabriel Adrian Samfira <[email protected]>
1 parent 686a84b commit 236d00b

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

client/llb/fileop.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
_ "crypto/sha256" // for opencontainers/go-digest
66
"os"
77
"path/filepath"
8+
"runtime"
89
"strconv"
910
"strings"
1011
"time"
@@ -771,7 +772,8 @@ func (f *FileOp) Marshal(ctx context.Context, c *Constraints) (digest.Digest, []
771772
}
772773
}
773774

774-
var platform string
775+
// Assume that we're building an image for the same OS we're running on.
776+
platform := runtime.GOOS
775777
if f.constraints.Platform != nil {
776778
platform = f.constraints.Platform.OS
777779
}

client/llb/meta.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"fmt"
66
"net"
7+
"runtime"
78

89
"github.com/containerd/containerd/platforms"
910
"github.com/google/shlex"
@@ -76,7 +77,7 @@ func dirf(value string, replace bool, v ...interface{}) StateOption {
7677
}
7778
return func(s State) State {
7879
return s.withValue(keyDir, func(ctx context.Context, c *Constraints) (interface{}, error) {
79-
var platform string
80+
platform := runtime.GOOS
8081
if c != nil && c.Platform != nil {
8182
platform = c.Platform.OS
8283
}

frontend/dockerfile/dockerfile2llb/convert.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"os"
1111
"path"
1212
"path/filepath"
13+
"runtime"
1314
"sort"
1415
"strconv"
1516
"strings"
@@ -994,7 +995,7 @@ func dispatchRun(d *dispatchState, c *instructions.RunCommand, proxy *llb.ProxyE
994995
}
995996

996997
func dispatchWorkdir(d *dispatchState, c *instructions.WorkdirCommand, commit bool, opt *dispatchOpt) error {
997-
var platformOS string
998+
platformOS := runtime.GOOS
998999
if d != nil && d.platform != nil {
9991000
platformOS = d.platform.OS
10001001
}
@@ -1032,7 +1033,7 @@ func dispatchWorkdir(d *dispatchState, c *instructions.WorkdirCommand, commit bo
10321033
}
10331034

10341035
func dispatchCopy(d *dispatchState, cfg copyConfig) error {
1035-
var platformOS string
1036+
platformOS := runtime.GOOS
10361037
if d.platform != nil {
10371038
platformOS = d.platform.OS
10381039
}

solver/llbsolver/ops/exec.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"fmt"
88
"os"
99
"path"
10+
"runtime"
1011
"sort"
1112
"strings"
1213

@@ -260,7 +261,7 @@ func (e *ExecOp) Exec(ctx context.Context, g session.Group, inputs []solver.Resu
260261
}
261262
}
262263

263-
var platformOS string
264+
platformOS := runtime.GOOS
264265
if e.platform != nil {
265266
platformOS = e.platform.OS
266267
}

0 commit comments

Comments
 (0)