Skip to content

Commit 09e9fbe

Browse files
authored
fix template install policy registry (#591)
1 parent 51cd8cb commit 09e9fbe

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

pkg/cc/config/generator.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"html/template"
55
"io"
66
"os"
7+
"strings"
78

89
"github.com/aserto-dev/topaz/pkg/cli/cc"
910
"github.com/aserto-dev/topaz/pkg/cli/x"
@@ -34,7 +35,15 @@ func (g *Generator) WithPolicyName(policyName string) *Generator {
3435
}
3536

3637
func (g *Generator) WithResource(resource string) *Generator {
38+
g.PolicyRegistry = "https://ghcr.io" // set to original default
39+
40+
policyRegistry, _, found := strings.Cut(resource, "/")
41+
if found && policyRegistry != "" {
42+
g.PolicyRegistry = "https://" + policyRegistry
43+
}
44+
3745
g.Resource = resource
46+
3847
return g
3948
}
4049

pkg/cc/config/templates.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package config
22

33
type templateParams struct {
44
Version int
5+
PolicyRegistry string
56
PolicyName string
67
Resource string
78
Authorization string
@@ -49,13 +50,13 @@ opa:
4950
skip_verification: true
5051
config:
5152
services:
52-
ghcr:
53-
url: https://ghcr.io
53+
policy-registry:
54+
url: "{{ .PolicyRegistry }}"
5455
type: "oci"
5556
response_header_timeout_seconds: 5
5657
bundles:
5758
{{ .PolicyName }}:
58-
service: ghcr
59+
service: policy-registry
5960
resource: "{{ .Resource }}"
6061
persist: false
6162
config:

0 commit comments

Comments
 (0)