Skip to content

Commit 474d783

Browse files
leodidoona-agent
andcommitted
refactor: use ProvenanceBundleFilename constant
Replace hardcoded '.provenance.jsonl' strings with exported ProvenanceBundleFilename constant for consistency and maintainability. The constant includes the dot prefix as it represents a filename suffix that gets appended to artifact paths (e.g., artifact.tar.gz + .provenance.jsonl). This addresses the linter warning about unused provenanceBundleFilename by renaming and properly using it throughout the codebase. Co-authored-by: Ona <no-reply@ona.com>
1 parent cdb2518 commit 474d783

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

pkg/leeway/provenance.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@ import (
2323
)
2424

2525
const (
26-
// provenanceBundleFilename is the name of the attestation bundle file
27-
// we store in the archived build artefacts.
26+
// ProvenanceBundleFilename is the filename suffix for provenance bundles stored alongside artifacts.
27+
// Provenance is stored as <artifact>.tar.gz + ProvenanceBundleFilename to keep it separate from the
28+
// deterministic artifact tar.gz.
2829
//
2930
// BEWARE: when you change this value this will break consumers. Existing
3031
// cached artefacts will not have the new filename which will break
3132
// builds. If you change this value, make sure you introduce a cache-invalidating
3233
// change, e.g. update the provenanceProcessVersion.
33-
provenanceBundleFilename = "provenance-bundle.jsonl"
34+
ProvenanceBundleFilename = ".provenance.jsonl"
3435

3536
// provenanceProcessVersion is the version of the provenance generating process.
3637
// If provenance is enabled in a workspace, this version becomes part of the manifest,
@@ -76,7 +77,7 @@ func writeProvenance(p *Package, buildctx *buildContext, builddir string, subjec
7677

7778
// Write provenance alongside artifact: <artifact>.provenance.jsonl
7879
// This keeps provenance metadata separate from the artifact for determinism
79-
provenancePath := artifactPath + ".provenance.jsonl"
80+
provenancePath := artifactPath + ProvenanceBundleFilename
8081

8182
// Ensure directory exists
8283
dir := filepath.Dir(provenancePath)
@@ -155,7 +156,7 @@ func AccessAttestationBundleInCachedArchive(fn string, handler func(bundle io.Re
155156
}
156157
}()
157158

158-
provenancePath := fn + ".provenance.jsonl"
159+
provenancePath := fn + ProvenanceBundleFilename
159160
if !fileExists(provenancePath) {
160161
return ErrNoAttestationBundle
161162
}

pkg/leeway/provenance_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func TestAccessAttestationBundleInCachedArchive(t *testing.T) {
2424
name: "provenance exists outside tar.gz",
2525
setupFunc: func(t *testing.T, dir string) string {
2626
artifactPath := filepath.Join(dir, "test.tar.gz")
27-
provenancePath := artifactPath + ".provenance.jsonl"
27+
provenancePath := artifactPath + leeway.ProvenanceBundleFilename
2828

2929
// Create empty artifact
3030
if err := os.WriteFile(artifactPath, []byte("fake tar.gz"), 0644); err != nil {
@@ -154,7 +154,7 @@ func TestProvenanceNotInTarGz(t *testing.T) {
154154
func TestProvenanceOutsideTarGz(t *testing.T) {
155155
tmpDir := t.TempDir()
156156
artifactPath := filepath.Join(tmpDir, "test.tar.gz")
157-
provenancePath := artifactPath + ".provenance.jsonl"
157+
provenancePath := artifactPath + leeway.ProvenanceBundleFilename
158158

159159
// Create a simple tar.gz WITHOUT provenance inside
160160
f, err := os.Create(artifactPath)
@@ -267,7 +267,7 @@ func TestProvenancePathExtensionHandling(t *testing.T) {
267267
t.Run(tt.name, func(t *testing.T) {
268268
// The provenance path is always <artifact>.provenance.jsonl
269269
// This is handled by AccessAttestationBundleInCachedArchive
270-
expectedPath := tt.artifactPath + ".provenance.jsonl"
270+
expectedPath := tt.artifactPath + leeway.ProvenanceBundleFilename
271271
if expectedPath != tt.expectedProvPath {
272272
t.Errorf("Expected provenance path %q, got %q", tt.expectedProvPath, expectedPath)
273273
}
@@ -281,7 +281,7 @@ func TestProvenanceDirectoryCreation(t *testing.T) {
281281
// Create nested directory structure
282282
nestedDir := filepath.Join(tmpDir, "cache", "subdir", "nested")
283283
artifactPath := filepath.Join(nestedDir, "test.tar.gz")
284-
provenancePath := artifactPath + ".provenance.jsonl"
284+
provenancePath := artifactPath + leeway.ProvenanceBundleFilename
285285

286286
// Directory doesn't exist yet
287287
if _, err := os.Stat(nestedDir); !os.IsNotExist(err) {

0 commit comments

Comments
 (0)