Skip to content

Conversation

scop
Copy link
Contributor

@scop scop commented Mar 14, 2025

This adds support for generating cosign configs for checksum files in gr.

Lightly tested, may have bugs. But a happy path exists: aquaproj/aqua-registry#33234

Check List

Comment on lines -251 to +254
pkgInfo := &registry.PackageInfo{}
pkgInfo := &registry.PackageInfo{
RepoOwner: pkgInfo.RepoOwner,
RepoName: pkgInfo.RepoName,
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and carrying the pkgInfo around is not too nice at all, but I needed some way to get the repo owner and name down to patchRelease. Figured I'd start simple, this appears to work at least for some cases.

Comment on lines +319 to +321
`^https://github\.com/%s/%s/\.github/workflows/.+\.ya?ml@refs/tags/`,
regexp.QuoteMeta(pkgInfo.RepoOwner),
regexp.QuoteMeta(pkgInfo.RepoName),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't be correct for everything (if the identity is from another project), but I thought it would be ok to do it this way and leave it for humans to fix where necessary.

Opts: []string{
"--certificate-identity-regexp",
fmt.Sprintf(
`^https://github\.com/%s/%s/\.github/workflows/.+\.ya?ml@refs/tags/`,
Copy link
Contributor Author

@scop scop Mar 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left {{.Version}} out from here, mostly because I feel simply having the version replaced here literally by templating would not be a good thing to do as the version could contain regex metacharacters -- and in fact it in the vast majority of cases does: the period is one (a regexp . matches a literal . so it would kind of work, but be hacky).

We could go with this though, on a second look I think I'd actually like this better. Thoughts?

Suggested change
`^https://github\.com/%s/%s/\.github/workflows/.+\.ya?ml@refs/tags/`,
`^https://github\.com/%s/%s/\.github/workflows/.+\.ya?ml@refs/tags/\Q{{.Version}}\E$`,

@suzuki-shunsuke
Copy link
Member

Thank you for your contribution!

@suzuki-shunsuke suzuki-shunsuke added this to the v2.45.2 milestone Mar 15, 2025
@suzuki-shunsuke
Copy link
Member

Great work.
Honestly, I'm not sure if this works well actually unless we try it out.
If there are any problems, we can fix them.

Comment on lines +320 to +321
regexp.QuoteMeta(pkgInfo.RepoOwner),
regexp.QuoteMeta(pkgInfo.RepoName),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
regexp.QuoteMeta(pkgInfo.RepoOwner),
regexp.QuoteMeta(pkgInfo.RepoName),
pkgInfo.RepoOwner,
pkgInfo.RepoName,

In my understanding, regular expression metacharacters aren't available in GitHub repository owners and names.
So we don't need to use regexp.QuoteMeta here.
But there is no problem even if it is used.

@suzuki-shunsuke suzuki-shunsuke merged commit 5e805c4 into aquaproj:main Mar 15, 2025
15 checks passed
@github-project-automation github-project-automation bot moved this to Done in main Mar 15, 2025
@scop scop deleted the feat/gr-checksum-cosign branch March 16, 2025 08:34
scop added a commit to scop/aqua that referenced this pull request Mar 16, 2025
suzuki-shunsuke pushed a commit that referenced this pull request Mar 16, 2025
@suzuki-shunsuke
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants