1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-27 20:58:36 +00:00

Fix some package registry problems (#34759)

1. Fix #33787
2. Fix container image display
This commit is contained in:
wxiaoguang
2025-06-19 00:32:43 +08:00
committed by GitHub
parent 7954f25290
commit a2ae7c69da
11 changed files with 118 additions and 60 deletions

View File

@@ -49,7 +49,11 @@
{{/* "unknown/unknown" is attestation-manifest, so we should skip it */}}
{{if ne .Platform "unknown/unknown"}}
<tr>
<td><a class="tw-font-mono" href="{{$.PackageDescriptor.PackageWebLink}}/{{PathEscape .Digest}}">{{StringUtils.TrimPrefix .Digest "sha256:" | ShortSha}}</a></td>
<td>
<a class="tw-font-mono" href="{{$.PackageDescriptor.PackageWebLink}}/{{$.PackageDescriptor.Version.LowerVersion}}/{{PathEscape .Digest}}">
{{StringUtils.TrimPrefix .Digest "sha256:" | ShortSha}}
</a>
</td>
<td>{{.Platform}}</td>
<td>{{FileSize .Size}}</td>
</tr>
@@ -65,12 +69,24 @@
{{.PackageDescriptor.Metadata.Description}}
</div>
{{end}}
{{if .PackageDescriptor.Metadata.ImageLayers}}
<h4 class="ui top attached header">{{ctx.Locale.Tr "packages.container.layers"}}</h4>
{{/* a container manifest may contain sub manifests, so here we try to display some information of the sub manifest,
not perfect, just better than before */}}
{{$imageMetadata := .ContainerImageMetadata}}
{{if $imageMetadata.ImageLayers}}
<h4 class="ui top attached header flex-text-block">
{{ctx.Locale.Tr "packages.container.layers"}}
{{/* only show the platform if the image metadata is not the package's, which means that it is a sub manifest */}}
{{if ne .ContainerImageMetadata .PackageDescriptor.Metadata}}
<span class="tw-text-sm flex-text-inline" title="{{ctx.Locale.Tr "packages.container.details.platform"}}">
({{svg "octicon-cpu" 12}} {{.ContainerImageMetadata.Platform}})
</span>
{{end}}
</h4>
<div class="ui attached segment tw-break-anywhere">
<table class="ui very basic compact table">
<tbody>
{{range .PackageDescriptor.Metadata.ImageLayers}}
{{range $imageMetadata.ImageLayers}}
<tr>
<td>{{.}}</td>
</tr>
@@ -79,7 +95,7 @@
</table>
</div>
{{end}}
{{if .PackageDescriptor.Metadata.Labels}}
{{if $imageMetadata.Labels}}
<h4 class="ui top attached header">{{ctx.Locale.Tr "packages.container.labels"}}</h4>
<div class="ui attached segment">
<table class="ui very basic compact table">
@@ -90,7 +106,7 @@
</tr>
</thead>
<tbody>
{{range $key, $value := .PackageDescriptor.Metadata.Labels}}
{{range $key, $value := $imageMetadata.Labels}}
<tr>
<td class="tw-align-top">{{$key}}</td>
<td class="tw-break-anywhere">{{$value}}</td>

View File

@@ -4,7 +4,7 @@
<div class="ui form">
<div class="field">
<label>{{svg "octicon-terminal"}} {{ctx.Locale.Tr "packages.pypi.install"}}</label>
<div class="markup"><pre class="code-block"><code>pip install --index-url <origin-url data-url="{{AppSubUrl}}/api/packages/{{.PackageDescriptor.Owner.Name}}/pypi/simple/"></origin-url> {{.PackageDescriptor.Package.Name}}</code></pre></div>
<div class="markup"><pre class="code-block"><code>pip install --index-url <origin-url data-url="{{AppSubUrl}}/api/packages/{{.PackageDescriptor.Owner.Name}}/pypi/simple/"></origin-url> --extra-index-url https://pypi.org/ {{.PackageDescriptor.Package.Name}}</code></pre></div>
</div>
<div class="field">
<label>{{ctx.Locale.Tr "packages.registry.documentation" "PyPI" "https://docs.gitea.com/usage/packages/pypi/"}}</label>