Skip to content

Commit 823e042

Browse files
committed
Fix transfer service dependencies:
- Fill OSVersion field of ocispec.Platform for windows OS in transfer service plugin init() - Do not return error from transfer service ReceiveStream if stream.Recv() returned context.Canceled error Signed-off-by: Kirtana Ashok <[email protected]>
1 parent cfb30a3 commit 823e042

4 files changed

Lines changed: 25 additions & 1 deletion

File tree

pkg/transfer/streaming/stream.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ func ReceiveStream(ctx context.Context, stream streaming.Stream) io.Reader {
164164
}
165165
anyType, err := stream.Recv()
166166
if err != nil {
167-
if errors.Is(err, io.EOF) {
167+
if errors.Is(err, io.EOF) || errors.Is(err, context.Canceled) {
168168
err = nil
169169
} else {
170170
err = fmt.Errorf("received failed: %w", err)

platforms/platforms.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@ func Parse(specifier string) (specs.Platform, error) {
213213
p.Variant = cpuVariant()
214214
}
215215

216+
if p.OS == "windows" {
217+
p.OSVersion = GetWindowsOsVersion()
218+
}
219+
216220
return p, nil
217221
}
218222

@@ -235,6 +239,10 @@ func Parse(specifier string) (specs.Platform, error) {
235239
p.Variant = ""
236240
}
237241

242+
if p.OS == "windows" {
243+
p.OSVersion = GetWindowsOsVersion()
244+
}
245+
238246
return p, nil
239247
case 3:
240248
// we have a fully specified variant, this is rare
@@ -244,6 +252,10 @@ func Parse(specifier string) (specs.Platform, error) {
244252
p.Variant = "v8"
245253
}
246254

255+
if p.OS == "windows" {
256+
p.OSVersion = GetWindowsOsVersion()
257+
}
258+
247259
return p, nil
248260
}
249261

platforms/platforms_other.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,7 @@ func newDefaultMatcher(platform specs.Platform) Matcher {
2828
Platform: Normalize(platform),
2929
}
3030
}
31+
32+
func GetWindowsOsVersion() string {
33+
return ""
34+
}

platforms/platforms_windows.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
package platforms
1818

1919
import (
20+
"fmt"
21+
2022
specs "github.com/opencontainers/image-spec/specs-go/v1"
23+
"golang.org/x/sys/windows"
2124
)
2225

2326
// NewMatcher returns a Windows matcher that will match on osVersionPrefix if
@@ -32,3 +35,8 @@ func newDefaultMatcher(platform specs.Platform) Matcher {
3235
},
3336
}
3437
}
38+
39+
func GetWindowsOsVersion() string {
40+
major, minor, build := windows.RtlGetNtVersionNumbers()
41+
return fmt.Sprintf("%d.%d.%d", major, minor, build)
42+
}

0 commit comments

Comments
 (0)