Skip to content

Commit 2ae42e0

Browse files
authored
Merge pull request #4779 from tonistiigi/v0.13.1-picks
[v0.13] v0.13.1 cherry-picks
2 parents 3f62976 + 0aff323 commit 2ae42e0

6 files changed

Lines changed: 37 additions & 8 deletions

File tree

cache/remotecache/v1/chains.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ type DescriptorProviderPair struct {
122122
Provider content.Provider
123123
}
124124

125+
var _ withCheckDescriptor = DescriptorProviderPair{}
126+
125127
func (p DescriptorProviderPair) ReaderAt(ctx context.Context, desc ocispecs.Descriptor) (content.ReaderAt, error) {
126128
return p.Provider.ReaderAt(ctx, desc)
127129
}
@@ -156,6 +158,13 @@ func (p DescriptorProviderPair) SnapshotLabels(descs []ocispecs.Descriptor, inde
156158
return nil
157159
}
158160

161+
func (p DescriptorProviderPair) CheckDescriptor(ctx context.Context, desc ocispecs.Descriptor) error {
162+
if cd, ok := p.Provider.(withCheckDescriptor); ok {
163+
return cd.CheckDescriptor(ctx, desc)
164+
}
165+
return nil
166+
}
167+
159168
// item is an implementation of a record in the cache chain. After validation,
160169
// normalization and marshalling into the cache config, the item results form
161170
// into the "layers", while the digests and the links form into the "records".

cache/remotecache/v1/utils.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ import (
1212
"github.com/pkg/errors"
1313
)
1414

15+
type withCheckDescriptor interface {
16+
// CheckDescriptor is additional method on Provider to check if the descriptor is available without opening the reader
17+
CheckDescriptor(context.Context, ocispecs.Descriptor) error
18+
}
19+
1520
// sortConfig sorts the config structure to make sure it is deterministic
1621
func sortConfig(cc *CacheConfig) {
1722
type indexedLayer struct {
@@ -279,9 +284,7 @@ func marshalRemote(ctx context.Context, r *solver.Remote, state *marshalState) s
279284
return ""
280285
}
281286

282-
if cd, ok := r.Provider.(interface {
283-
CheckDescriptor(context.Context, ocispecs.Descriptor) error
284-
}); ok && len(r.Descriptors) > 0 {
287+
if cd, ok := r.Provider.(withCheckDescriptor); ok && len(r.Descriptors) > 0 {
285288
for _, d := range r.Descriptors {
286289
if cd.CheckDescriptor(ctx, d) != nil {
287290
return ""

executor/oci/spec.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package oci
22

33
import (
44
"context"
5+
"os"
56
"path"
67
"path/filepath"
78
"runtime"
@@ -197,8 +198,11 @@ func GenerateSpec(ctx context.Context, meta executor.Meta, mounts []executor.Mou
197198
}
198199

199200
if tracingSocket != "" {
200-
if mount := getTracingSocketMount(tracingSocket); mount != nil {
201-
s.Mounts = append(s.Mounts, *mount)
201+
// moby/buildkit#4764
202+
if _, err := os.Stat(tracingSocket); err == nil {
203+
if mount := getTracingSocketMount(tracingSocket); mount != nil {
204+
s.Mounts = append(s.Mounts, *mount)
205+
}
202206
}
203207
}
204208

solver/llbsolver/solver.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,10 @@ func New(opt Opt) (*Solver, error) {
125125

126126
func (s *Solver) Close() error {
127127
s.solver.Close()
128-
err := s.sysSampler.Close()
129-
return err
128+
if s.sysSampler != nil {
129+
return s.sysSampler.Close()
130+
}
131+
return nil
130132
}
131133

132134
func (s *Solver) resolver() solver.ResolveOpFunc {

util/gitutil/git_ref.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ func ParseGitRef(ref string) (*GitRef, error) {
5757
err error
5858
)
5959

60-
if strings.HasPrefix(ref, "github.com/") {
60+
if strings.HasPrefix(ref, "./") || strings.HasPrefix(ref, "../") {
61+
return nil, errdefs.ErrInvalidArgument
62+
} else if strings.HasPrefix(ref, "github.com/") {
6163
res.IndistinguishableFromLocal = true // Deprecated
6264
remote = fromURL(&url.URL{
6365
Scheme: "https",

util/gitutil/git_ref_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,21 @@ func TestParseGitRef(t *testing.T) {
133133
SubDir: "myfolder",
134134
},
135135
},
136+
{
137+
ref: "./.git",
138+
expected: nil,
139+
},
140+
{
141+
ref: ".git",
142+
expected: nil,
143+
},
136144
}
137145
for _, tt := range cases {
138146
tt := tt
139147
t.Run(tt.ref, func(t *testing.T) {
140148
got, err := ParseGitRef(tt.ref)
141149
if tt.expected == nil {
150+
require.Nil(t, got)
142151
require.Error(t, err)
143152
} else {
144153
require.NoError(t, err)

0 commit comments

Comments
 (0)