Skip to content

Commit c7a35cc

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]> (cherry picked from commit 823e042) Signed-off-by: Kirtana Ashok <[email protected]>
1 parent 38d4e50 commit c7a35cc

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
any, 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
@@ -196,6 +196,10 @@ func Parse(specifier string) (specs.Platform, error) {
196196
p.Variant = cpuVariant()
197197
}
198198

199+
if p.OS == "windows" {
200+
p.OSVersion = GetWindowsOsVersion()
201+
}
202+
199203
return p, nil
200204
}
201205

@@ -218,6 +222,10 @@ func Parse(specifier string) (specs.Platform, error) {
218222
p.Variant = ""
219223
}
220224

225+
if p.OS == "windows" {
226+
p.OSVersion = GetWindowsOsVersion()
227+
}
228+
221229
return p, nil
222230
case 3:
223231
// we have a fully specified variant, this is rare
@@ -227,6 +235,10 @@ func Parse(specifier string) (specs.Platform, error) {
227235
p.Variant = "v8"
228236
}
229237

238+
if p.OS == "windows" {
239+
p.OSVersion = GetWindowsOsVersion()
240+
}
241+
230242
return p, nil
231243
}
232244

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)