Skip to content

Commit 559c050

Browse files
committed
fix(cozypkg): pin tap short-name to the index version and harden the gate
Conformance review against the design proposals surfaced that a short-name tap ignored the index entry's recorded version: resolveTapTarget returned the bare ociRef, so 'cozypkg tap <name>' pulled :latest while the CI gate had validated and cosign-verified <ociRef>:<version>. The gate signed one tag and the cluster pulled another, breaking both the versioning model (#18) and the signature chain (#23). Resolve the short name to <ociRef>:<version> when a version is recorded. Also harden the publication gate: run 'cozypkg validate --helm-lint' (with helm installed in the workflow) so charts are linted as the design specifies, and add a CODEOWNERS so every index entry requires maintainer review. Signed-off-by: IvanHunters <[email protected]>
1 parent 3643fce commit 559c050

5 files changed

Lines changed: 30 additions & 3 deletions

File tree

‎cmd/cozypkg/cmd/index.go‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,12 @@ func resolveTapTarget(arg, indexRef string) (string, error) {
215215
if !ok {
216216
return "", fmt.Errorf("no index entry named %q", arg)
217217
}
218+
// Pin to the entry's recorded version: the CI gate validated and
219+
// cosign-verified <ociRef>:<version>, so tapping must consume that exact
220+
// tag rather than defaulting to latest.
221+
if entry.Version != "" {
222+
return entry.OCIRef + ":" + entry.Version, nil
223+
}
218224
return entry.OCIRef, nil
219225
}
220226

‎cmd/cozypkg/cmd/index_test.go‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,14 @@ func TestResolveTapTarget(t *testing.T) {
106106
if err != nil {
107107
t.Fatalf("resolveTapTarget: %v", err)
108108
}
109-
if got != "oci://ghcr.io/foo/bar" {
110-
t.Fatalf("resolved ref = %q", got)
109+
// Must pin to the entry's recorded version, not default to latest.
110+
if got != "oci://ghcr.io/foo/bar:v1.2.3" {
111+
t.Fatalf("resolved ref = %q, want the version-pinned ref", got)
112+
}
113+
114+
// An entry without a version resolves to the bare ref (tap defaults to latest).
115+
if got, err := resolveTapTarget("baz.qux", dir); err != nil || got != "oci://ghcr.io/baz/qux" {
116+
t.Fatalf("versionless resolve = %q err %v", got, err)
111117
}
112118

113119
if _, err := resolveTapTarget("does.not.exist", dir); err == nil {

‎hack/packages-index/CODEOWNERS‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Every index entry requires maintainer review before merge (the auto-merge
2+
# lane in validate.yaml only fires for an owner version bump signed by the
3+
# entry's recorded identity; everything else lands here).
4+
/entries/ @cozystack/maintainers
5+
6+
# The gate itself and the workflow are maintainer-owned.
7+
/scripts/ @cozystack/maintainers
8+
/github-workflows/ @cozystack/maintainers

‎hack/packages-index/github-workflows/validate.yaml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ jobs:
4848
with:
4949
cosign-release: v2.4.3
5050

51+
# helm is needed for `cozypkg validate --helm-lint` in the gate.
52+
- uses: azure/setup-helm@b9e51907a09c216f16ebe8536097933489208112 # v4.3.0
53+
with:
54+
version: v3.16.4
55+
5156
- name: Validate changed entries
5257
id: gate
5358
env:

‎hack/packages-index/scripts/validate-entry.sh‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,10 @@ while IFS= read -r file; do
7272
lane="review"
7373
fi
7474

75-
# Mandatory validation plus cosign verification against the RECORDED identity.
75+
# Mandatory validation (including helm lint of every component chart) plus
76+
# cosign verification against the RECORDED identity.
7677
cozypkg validate "${ociRef}:${version}" \
78+
--helm-lint \
7779
--require-signature \
7880
--certificate-identity "$identity" \
7981
--certificate-oidc-issuer "$issuer"

0 commit comments

Comments
 (0)