Skip to content

Commit

Permalink
feat: 根据node Metadata获取版本信息兼容旧docker制品 TencentBlueKing#1689
Browse files Browse the repository at this point in the history
  • Loading branch information
xujian-xj authored and scplsy committed Jan 23, 2024
1 parent f60be2f commit b54cf58
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const val DIGEST = "oci_digest"
const val SIZE = "size"
const val SCHEMA_VERSION = "schemaVersion"
const val IMAGE_VERSION = "blob_version"
const val OLD_DOCKER_VERSION = "docker.manifest"
const val MANIFEST_DIGEST = "manifest_digest"
const val DIGEST_LIST = "digest_list"
const val FORCE = "force"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import com.tencent.bkrepo.oci.constant.MEDIA_TYPE
import com.tencent.bkrepo.oci.constant.N
import com.tencent.bkrepo.oci.constant.OCI_IMAGE_MANIFEST_MEDIA_TYPE
import com.tencent.bkrepo.oci.constant.OLD_DOCKER_MEDIA_TYPE
import com.tencent.bkrepo.oci.constant.OLD_DOCKER_VERSION
import com.tencent.bkrepo.oci.constant.OciMessageCode
import com.tencent.bkrepo.oci.constant.PATCH
import com.tencent.bkrepo.oci.constant.POST
Expand Down Expand Up @@ -335,7 +336,9 @@ class OciRegistryLocalRepository(
if (context.request.method == HttpMethod.HEAD.name) {
return null
}
val version = artifactResource.node?.metadata?.get(IMAGE_VERSION)?.toString() ?: return null
val version = artifactResource.node?.metadata?.get(IMAGE_VERSION)?.toString() ?: run {
artifactResource.node?.metadata?.get(OLD_DOCKER_VERSION)?.toString() ?: return null
}
return PackageDownloadRecord(
projectId = context.projectId,
repoName = context.repoName,
Expand Down Expand Up @@ -454,7 +457,9 @@ class OciRegistryLocalRepository(
with(context) {
val artifactInfo = context.artifactInfo as OciArtifactInfo
val packageKey = PackageKeys.ofName(repo.type, artifactInfo.packageName)
val version = node.metadata[IMAGE_VERSION]?.toString() ?: return null
val version = node.metadata[IMAGE_VERSION]?.toString() ?: run {
node.metadata[OLD_DOCKER_VERSION]?.toString() ?: return null
}
return packageClient.findVersionByName(projectId, repoName, packageKey, version).data
}
}
Expand Down

0 comments on commit b54cf58

Please sign in to comment.