use PackageRegistryHost

pull/31037/head
wxiaoguang 1 week ago
parent 84ff353804
commit ce73234b42
  1. 2
      modules/packages/arch/metadata_test.go
  2. 16
      routers/web/user/package.go
  3. 2
      templates/package/content/arch.tmpl
  4. 4
      templates/package/content/container.tmpl

@ -448,6 +448,6 @@ dummy6
func TestOptVersionCheck(t *testing.T) {
for _, s := range []string{"foo", "foo>=1.0.0", "foo<=1.0.0", "foo>=1:1.0.0: aaa"} {
require.True(t, reOptDep.MatchString(s), s)
require.True(t, GlobalVar().reOptDep.MatchString(s), s)
}
}

@ -180,13 +180,12 @@ func ViewPackageVersion(ctx *context.Context) {
ctx.Data["IsPackagesPage"] = true
ctx.Data["PackageDescriptor"] = pd
curAppURL, _ := url.Parse(httplib.GuessCurrentAppURL(ctx))
packageRegistryHost := curAppURL.Host
ctx.Data["PackageRegistryHost"] = packageRegistryHost
switch pd.Package.Type {
case packages_model.TypeContainer:
registryAppURL, err := url.Parse(httplib.GuessCurrentAppURL(ctx))
if err != nil {
registryAppURL, _ = url.Parse(setting.AppURL)
}
ctx.Data["RegistryHost"] = registryAppURL.Host
case packages_model.TypeAlpine:
branches := make(container.Set[string])
repositories := make(container.Set[string])
@ -209,12 +208,7 @@ func ViewPackageVersion(ctx *context.Context) {
ctx.Data["Repositories"] = util.Sorted(repositories.Values())
ctx.Data["Architectures"] = util.Sorted(architectures.Values())
case packages_model.TypeArch:
registryAppURL, err := url.Parse(httplib.GuessCurrentAppURL(ctx))
if err != nil {
registryAppURL, _ = url.Parse(setting.AppURL)
}
ctx.Data["RegistryHost"] = registryAppURL.Host
ctx.Data["SignMail"] = fmt.Sprintf("%s@noreply.%s", ctx.Package.Owner.Name, registryAppURL.Host)
ctx.Data["SignMail"] = fmt.Sprintf("%s@noreply.%s", ctx.Package.Owner.Name, packageRegistryHost)
groups := make(container.Set[string])
for _, f := range pd.Files {
for _, pp := range f.Properties {

@ -25,7 +25,7 @@ pacman-key --lsign-key '{{$.SignMail}}'</code></pre>
{{end -}}{{- if gt $GroupSize 1 -}}
# {{ctx.Locale.Tr "packages.arch.pacman.repo.multi.item" .}}
{{end -}}
[{{$.PackageDescriptor.Owner.LowerName}}.{{$.RegistryHost}}]
[{{$.PackageDescriptor.Owner.LowerName}}.{{$.PackageRegistryHost}}]
SigLevel = Required
Server = <origin-url data-url="{{AppSubUrl}}/api/packages/{{$.PackageDescriptor.Owner.Name}}/arch/{{.}}/$arch"></origin-url>
{{end -}}

@ -5,13 +5,13 @@
<div class="field">
<label>{{svg "octicon-terminal"}} {{ctx.Locale.Tr "packages.container.pull"}}</label>
{{if eq .PackageDescriptor.Metadata.Type "helm"}}
<div class="markup"><pre class="code-block"><code>helm pull oci://{{.RegistryHost}}/{{.PackageDescriptor.Owner.LowerName}}/{{.PackageDescriptor.Package.LowerName}} --version {{.PackageDescriptor.Version.LowerVersion}}</code></pre></div>
<div class="markup"><pre class="code-block"><code>helm pull oci://{{.PackageRegistryHost}}/{{.PackageDescriptor.Owner.LowerName}}/{{.PackageDescriptor.Package.LowerName}} --version {{.PackageDescriptor.Version.LowerVersion}}</code></pre></div>
{{else}}
{{$separator := ":"}}
{{if not .PackageDescriptor.Metadata.IsTagged}}
{{$separator = "@"}}
{{end}}
<div class="markup"><pre class="code-block"><code>docker pull {{.RegistryHost}}/{{.PackageDescriptor.Owner.LowerName}}/{{.PackageDescriptor.Package.LowerName}}{{$separator}}{{.PackageDescriptor.Version.LowerVersion}}</code></pre></div>
<div class="markup"><pre class="code-block"><code>docker pull {{.PackageRegistryHost}}/{{.PackageDescriptor.Owner.LowerName}}/{{.PackageDescriptor.Package.LowerName}}{{$separator}}{{.PackageDescriptor.Version.LowerVersion}}</code></pre></div>
{{end}}
</div>
<div class="field">

Loading…
Cancel
Save