Skip to content

Commit 30a76c3

Browse files
committed
Add identity override for rke2
Signed-off-by: Paulo Gomes <[email protected]>
1 parent 45012ad commit 30a76c3

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

internal/verify/verify.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ func Verify(imageName string) error {
2626
return err
2727
}
2828

29+
fmt.Println("identity:", certIdentity)
30+
2931
v := &verify.VerifyCommand{
3032
CertVerifyOptions: options.CertVerifyOptions{
3133
CertIdentity: certIdentity,
@@ -64,10 +66,18 @@ func certIdentity(imageName string) (string, error) {
6466
}
6567

6668
repo := strings.Join(names[len(names)-2:], "/")
67-
ref := d[1]
69+
ref := strings.Replace(d[1], "-", "&#43;", 1)
70+
repo = overrideRepo(repo)
6871

6972
indentity := fmt.Sprintf(
7073
"https://github.com/%s/.github/workflows/release.yml@refs/tags/%s", repo, ref)
7174

7275
return indentity, nil
7376
}
77+
78+
func overrideRepo(repo string) string {
79+
if strings.HasPrefix(repo, "rancher/rke2-") {
80+
return "rancher/rke2"
81+
}
82+
return repo
83+
}

internal/verify/verify_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ func TestCertificateIdentity(t *testing.T) {
1616
image: "foo/bar:v0.0.7",
1717
want: "https://github.com/foo/bar/.github/workflows/release.yml@refs/tags/v0.0.7",
1818
},
19+
{
20+
image: "foo/bar:v0.0.7-barfoo2",
21+
want: "https://github.com/foo/bar/.github/workflows/release.yml@refs/tags/v0.0.7&#43;barfoo2",
22+
},
1923
{
2024
image: "",
2125
wantErr: "invalid image name",
@@ -48,6 +52,10 @@ func TestCertificateIdentity(t *testing.T) {
4852
image: "tocker.local/bar/foo/bar:v3.14",
4953
want: "https://github.com/foo/bar/.github/workflows/release.yml@refs/tags/v3.14",
5054
},
55+
{
56+
image: "rancher/rke2-bar:v0.0.7",
57+
want: "https://github.com/rancher/rke2/.github/workflows/release.yml@refs/tags/v0.0.7",
58+
},
5159
}
5260

5361
for _, tc := range tests {

0 commit comments

Comments
 (0)