Skip to content

Commit 88dea89

Browse files
committed
[lwpm] sync support oci
Signed-off-by: Kang Huaishuai <khs1994@khs1994.com>
1 parent f9e7804 commit 88dea89

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

dockerfile/sync/.github/workflows/ci.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ jobs:
88
ci:
99
runs-on: ubuntu-latest
1010
steps:
11+
- run: |
12+
docker manifest inspect moby/buildkit
13+
- run: |
14+
docker manifest inspect moby/buildkit@sha256:e39f6119f134b4811af19fd5c20f495a6a264a85c1b6920daf569b23009dd42c
1115
- run: |
1216
docker run -i --rm \
1317
-e DEST_DOCKER_USERNAME=${DOCKER_USERNAME} \

windows/docker-image-sync.ps1

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ Function _sync($source, $dest, $config) {
257257
}
258258

259259
# get manifest list
260+
$oci_manifest_list = $false
260261
$token = _getSourceToken $source_registry $source_image
261262
$manifest_list_json_path = Get-Manifest $token $source_image $source_ref -raw $false `
262263
-registry $source_registry
@@ -265,6 +266,15 @@ Function _sync($source, $dest, $config) {
265266
}
266267
else {
267268
$manifest_list_json = $null
269+
270+
# try oci manifest list
271+
$manifest_list_json_path = Get-Manifest $token $source_image $source_ref -raw $false `
272+
-registry $source_registry -header [OCIImageSpec]::manifest_list
273+
274+
if ($manifest_list_json_path) {
275+
$oci_manifest_list = $true
276+
$manifest_list_json = ConvertFrom-Json (Get-Content $manifest_list_json_path -raw)
277+
}
268278
}
269279

270280
$manifest_list_mediaType = $manifest_list_json.mediaType

windows/sdk/dockerhub/manifests/get.psm1

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ function Get-Manifest([string]$token, [string]$image, $ref, $header, $registry =
88
$type = "manifest"
99

1010
if ($header -eq [DockerImageSpec]::manifest_list) { $type = "docker manifest list" }
11+
if ($header -eq [OCIImageSpec]::manifest_list) { $type = "oci manifest list" }
12+
if ($header -eq [OCIImageSpec]::manifest) { $type = "oci manifest" }
1113

1214
Write-host "==> Get [ $image $ref ] $type ..." -ForegroundColor Blue
1315

@@ -43,6 +45,8 @@ function Get-Manifest([string]$token, [string]$image, $ref, $header, $registry =
4345
$type = "oci manifest"
4446
}
4547

48+
Write-Host "==> [Info] Try [ $image $ref ] $type ..." -ForegroundColor Blue
49+
4650
try {
4751
$result = Invoke-WebRequest `
4852
-Authentication OAuth `
@@ -63,7 +67,7 @@ function Get-Manifest([string]$token, [string]$image, $ref, $header, $registry =
6367
}
6468

6569
if ($result.Headers.'Content-Type' -ne $header) {
66-
Write-Host "==> [error] Get [ $image $ref ] $type error" -ForegroundColor Red
70+
Write-Host "==> [error] Get [ $image $ref ] $type error, find [ $($result.Headers.'Content-Type') ]" -ForegroundColor Red
6771

6872
return $false
6973
}
@@ -110,3 +114,30 @@ Export-ModuleMember -Function Get-Manifest
110114
# }
111115
# ]
112116
# }
117+
118+
119+
# {
120+
# "schemaVersion": 2,
121+
# "mediaType": "application/vnd.oci.image.index.v1+json",
122+
# "manifests": [
123+
# {
124+
# "mediaType": "application/vnd.oci.image.manifest.v1+json",
125+
# "size": 1598,
126+
# "digest": "sha256:e39f6119f134b4811af19fd5c20f495a6a264a85c1b6920daf569b23009dd42c",
127+
# "platform": {
128+
# "architecture": "amd64",
129+
# "os": "linux"
130+
# }
131+
# },
132+
# {
133+
# "mediaType": "application/vnd.oci.image.manifest.v1+json",
134+
# "size": 1598,
135+
# "digest": "sha256:a090c17d367f2686633f2be8a10cb1670ed1c12bb47c6e47ea0dde84a8512765",
136+
# "platform": {
137+
# "architecture": "arm",
138+
# "os": "linux",
139+
# "variant": "v7"
140+
# }
141+
# }
142+
# ]
143+
# }

0 commit comments

Comments
 (0)