Skip to content

Commit c542c80

Browse files
authored
Merge pull request #2630 from dheerajodha/EC-423
Remove "effective_on" from trusted_tasks
2 parents 6297bc7 + a0a6fa1 commit c542c80

File tree

7 files changed

+340
-205
lines changed

7 files changed

+340
-205
lines changed

cmd/track/track_bundle.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ func trackBundleCmd(track trackBundleFn, pullImage pullImageFn, pushImage pushIm
6262
or a digest is required.
6363
6464
The output is meant to assist enforcement of policies that ensure the
65-
most recent Tekton Bundle is used. As such, each entry contains an
66-
"effective_on" date which is set to 30 days from today. This indicates
67-
the Tekton Bundle usage should be updated within that period.
68-
69-
If --prune is set, on by default, non-acceptable entries are removed.
70-
Any entry with an effective_on date in the future, and the entry with
71-
the most recent effective_on date *not* in the future are considered
72-
acceptable.
65+
most recent Tekton Bundle is used. Each entry contains an "expires_on"
66+
date which indicates when that specific bundle version should no longer
67+
be used. When a new entry is introduced, an expiration date is added to
68+
the previous newest entry.
69+
70+
If --prune is set, on by default, expired entries are removed.
71+
Any entry with an expires_on date in the future (or no expires_on date)
72+
is considered current and will not be pruned.
7373
`),
7474

7575
Example: hd.Doc(`
@@ -181,7 +181,7 @@ func trackBundleCmd(track trackBundleFn, pullImage pullImageFn, pushImage pushIm
181181

182182
cmd.Flags().BoolVar(&params.freshen, "freshen", params.freshen, "resolve image tags to catch updates and use the latest image for the tag")
183183

184-
cmd.Flags().IntVar(&params.inEffectDays, "in-effect-days", params.inEffectDays, "number of days representing when the added reference becomes effective")
184+
cmd.Flags().IntVar(&params.inEffectDays, "in-effect-days", params.inEffectDays, "number of days after which older bundle entries expire when a new bundle entry is added (most recent entry stays valid until replaced)")
185185

186186
cmd.MarkFlagsOneRequired("bundle", "git", "input")
187187

cmd/track/track_bundle_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"testing"
2626

2727
"github.com/spf13/afero"
28+
"github.com/spf13/pflag"
2829
"github.com/stretchr/testify/assert"
2930

3031
"github.com/conforma/cli/cmd/root"
@@ -269,6 +270,33 @@ func Test_TrackBundleCommand(t *testing.T) {
269270
}
270271
}
271272

273+
// TestBundleCommandHelp tests that the command help reflects the new expires_on behavior
274+
func TestBundleCommandHelp(t *testing.T) {
275+
trackBundleCmd := trackBundleCmd(nil, nil, nil)
276+
277+
// Verify the long description mentions expires_on
278+
assert.Contains(t, trackBundleCmd.Long, "expires_on",
279+
"Command help should mention expires_on")
280+
281+
// Verify it explains the new behavior
282+
assert.Contains(t, trackBundleCmd.Long, "expiration date is added",
283+
"Command help should explain that expiration dates are added")
284+
285+
// Verify pruning explanation is updated
286+
assert.Contains(t, trackBundleCmd.Long, "expired entries are removed",
287+
"Command help should explain pruning removes expired entries")
288+
289+
// Verify the in-effect-days flag is documented
290+
foundFlag := false
291+
trackBundleCmd.Flags().VisitAll(func(flag *pflag.Flag) {
292+
if flag.Name == "in-effect-days" {
293+
foundFlag = true
294+
assert.Equal(t, "30", flag.DefValue, "Default value should be 30")
295+
}
296+
})
297+
assert.True(t, foundFlag, "in-effect-days flag should exist")
298+
}
299+
272300
func TestPreRunE(t *testing.T) {
273301
cases := []struct {
274302
name string

docs/modules/ROOT/pages/ec_track_bundle.adoc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ command will query the registry to determine its value. Either a tag
1212
or a digest is required.
1313

1414
The output is meant to assist enforcement of policies that ensure the
15-
most recent Tekton Bundle is used. As such, each entry contains an
16-
"effective_on" date which is set to 30 days from today. This indicates
17-
the Tekton Bundle usage should be updated within that period.
15+
most recent Tekton Bundle is used. Each entry contains an "expires_on"
16+
date which indicates when that specific bundle version should no longer
17+
be used. When a new entry is introduced, an expiration date is added to
18+
the previous newest entry.
1819

19-
If --prune is set, on by default, non-acceptable entries are removed.
20-
Any entry with an effective_on date in the future, and the entry with
21-
the most recent effective_on date *not* in the future are considered
22-
acceptable.
20+
If --prune is set, on by default, expired entries are removed.
21+
Any entry with an expires_on date in the future (or no expires_on date)
22+
is considered current and will not be pruned.
2323

2424
[source,shell]
2525
----
@@ -65,7 +65,7 @@ Update existing acceptable bundles:
6565
--freshen:: resolve image tags to catch updates and use the latest image for the tag (Default: false)
6666
-g, --git:: git references to track - may be used multiple times (Default: [])
6767
-h, --help:: help for bundle (Default: false)
68-
--in-effect-days:: number of days representing when the added reference becomes effective (Default: 30)
68+
--in-effect-days:: number of days after which older bundle entries expire when a new bundle entry is added (most recent entry stays valid until replaced) (Default: 30)
6969
-i, --input:: existing tracking file
7070
-o, --output:: write modified tracking file to a file. Use empty string for stdout, default behavior
7171
-p, --prune:: remove entries that are no longer acceptable, i.e. a newer entry already effective exists (Default: true)

features/__snapshots__/track_bundle.snap

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
/-/-/-/
44
trusted_tasks:
55
oci://${REGISTRY}/acceptance/bundle:tag:
6-
- effective_on: "${TIMESTAMP}"
7-
ref: sha256:${REGISTRY_acceptance/bundle:tag_DIGEST}
6+
- ref: sha256:${REGISTRY_acceptance/bundle:tag_DIGEST}
87

98
---
109

@@ -16,10 +15,8 @@ trusted_tasks:
1615
/-/-/-/
1716
trusted_tasks:
1817
oci://${REGISTRY}/acceptance/bundle:tag:
19-
- effective_on: "${TIMESTAMP}"
20-
ref: sha256:${REGISTRY_acceptance/bundle:tag_DIGEST}
21-
- effective_on: "2006-01-02T15:04:05Z"
22-
expires_on: "${TIMESTAMP}"
18+
- ref: sha256:${REGISTRY_acceptance/bundle:tag_DIGEST}
19+
- expires_on: "${TIMESTAMP}"
2320
ref: sha256:0af8c4f92f4b252b3ef0cbd712e7352196bc33a96c58b6e1d891b26e171deae8
2421

2522
---
@@ -32,8 +29,7 @@ trusted_tasks:
3229
/-/-/-/
3330
trusted_tasks:
3431
oci://${REGISTRY}/acceptance/bundle:tag:
35-
- effective_on: "${TIMESTAMP}"
36-
ref: sha256:${REGISTRY_acceptance/bundle:tag_DIGEST}
32+
- ref: sha256:${REGISTRY_acceptance/bundle:tag_DIGEST}
3733

3834
---
3935

@@ -55,8 +51,7 @@ trusted_tasks:
5551
/-/-/-/
5652
trusted_tasks:
5753
git+https://github.com/konflux-ci/build-definitions.git//task/buildah/0.1/buildah.yaml:
58-
- effective_on: "${TIMESTAMP}"
59-
ref: 3672a457e3e89c0591369f609eba727b8e84108f
54+
- ref: 3672a457e3e89c0591369f609eba727b8e84108f
6055

6156
---
6257

@@ -68,11 +63,9 @@ trusted_tasks:
6863
/-/-/-/
6964
trusted_tasks:
7065
git+https://github.com/konflux-ci/build-definitions.git//task/buildah/0.1/buildah.yaml:
71-
- effective_on: "${TIMESTAMP}"
72-
ref: 3672a457e3e89c0591369f609eba727b8e84108f
66+
- ref: 3672a457e3e89c0591369f609eba727b8e84108f
7367
oci://${REGISTRY}/acceptance/bundle:tag:
74-
- effective_on: "${TIMESTAMP}"
75-
ref: sha256:${REGISTRY_acceptance/bundle:tag_DIGEST}
68+
- ref: sha256:${REGISTRY_acceptance/bundle:tag_DIGEST}
7669

7770
---
7871

@@ -84,8 +77,7 @@ trusted_tasks:
8477
/-/-/-/
8578
trusted_tasks:
8679
git+https://forge.io/organization/repository.git//task/0.1/task.yaml:
87-
- effective_on: "${TIMESTAMP}"
88-
ref: f0cacc1af00d
80+
- ref: f0cacc1af00d
8981

9082
---
9183

@@ -97,11 +89,9 @@ trusted_tasks:
9789
/-/-/-/
9890
trusted_tasks:
9991
git+https://github.com/konflux-ci/build-definitions.git//task/buildah/0.1/buildah.yaml:
100-
- effective_on: "${TIMESTAMP}"
101-
ref: 3672a457e3e89c0591369f609eba727b8e84108f
92+
- ref: 3672a457e3e89c0591369f609eba727b8e84108f
10293
oci://${REGISTRY}/acceptance/bundle:tag:
103-
- effective_on: "${TIMESTAMP}"
104-
ref: sha256:${REGISTRY_acceptance/bundle:tag_DIGEST}
94+
- ref: sha256:${REGISTRY_acceptance/bundle:tag_DIGEST}
10595

10696
---
10797

@@ -113,10 +103,8 @@ trusted_tasks:
113103
/-/-/-/
114104
trusted_tasks:
115105
git+https://forge.io/organization/repository.git//task/0.1/task.yaml:
116-
- effective_on: "${TIMESTAMP}"
117-
ref: f0cacc1af00d
118-
- effective_on: "2006-01-02T15:04:05Z"
119-
expires_on: "${TIMESTAMP}"
106+
- ref: f0cacc1af00d
107+
- expires_on: "${TIMESTAMP}"
120108
ref: f0cacc1a
121109

122110
---
@@ -129,8 +117,7 @@ trusted_tasks:
129117
/-/-/-/
130118
trusted_tasks:
131119
git+https://forge.io/organization/repository.git//task/0.1/task.yaml:
132-
- effective_on: "2006-01-02T15:04:05Z"
133-
ref: f0cacc1a
120+
- ref: f0cacc1a
134121

135122
---
136123

@@ -150,8 +137,7 @@ Error: expected "git+https://${GITHOST}/git/tasks.git//task.yaml" to contain the
150137
/-/-/-/
151138
trusted_tasks:
152139
git+https://${GITHOST}/git/tasks.git//task.yaml:
153-
- effective_on: "${TIMESTAMP}"
154-
ref: ${LATEST_COMMIT}
140+
- ref: ${LATEST_COMMIT}
155141

156142
---
157143

features/track_bundle.feature

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ Feature: track bundles
2222
---
2323
trusted_tasks:
2424
oci://${REGISTRY}/acceptance/bundle:tag:
25-
- effective_on: "${TODAY_PLUS_30_DAYS}"
26-
ref: sha256:0af8c4f92f4b252b3ef0cbd712e7352196bc33a96c58b6e1d891b26e171deae8
25+
- ref: sha256:0af8c4f92f4b252b3ef0cbd712e7352196bc33a96c58b6e1d891b26e171deae8
2726
2827
"""
2928

@@ -40,11 +39,9 @@ Feature: track bundles
4039
---
4140
trusted_tasks:
4241
oci://${REGISTRY}/acceptance/bundle:1.0:
43-
- effective_on: "${TODAY_PLUS_30_DAYS}"
44-
ref: sha256:0af8c4f92f4b252b3ef0cbd712e7352196bc33a96c58b6e1d891b26e171deae8
42+
- ref: sha256:0af8c4f92f4b252b3ef0cbd712e7352196bc33a96c58b6e1d891b26e171deae8
4543
oci://${REGISTRY}/acceptance/bundle:1.1:
46-
- effective_on: "${TODAY_PLUS_30_DAYS}"
47-
ref: sha256:7af058b8a7adb24b74875411d625afbf90af6b4ed41b740606032edf1c4a0d1d
44+
- ref: sha256:7af058b8a7adb24b74875411d625afbf90af6b4ed41b740606032edf1c4a0d1d
4845
4946
"""
5047

@@ -57,8 +54,7 @@ Feature: track bundles
5754
---
5855
trusted_tasks:
5956
oci://${REGISTRY}/acceptance/bundle:tag:
60-
- effective_on: "${TODAY_PLUS_30_DAYS}"
61-
ref: sha256:0af8c4f92f4b252b3ef0cbd712e7352196bc33a96c58b6e1d891b26e171deae8
57+
- ref: sha256:0af8c4f92f4b252b3ef0cbd712e7352196bc33a96c58b6e1d891b26e171deae8
6258
6359
"""
6460

@@ -70,8 +66,7 @@ Feature: track bundles
7066
---
7167
trusted_tasks:
7268
oci://${REGISTRY}/acceptance/bundle:tag:
73-
- effective_on: 2006-01-02T15:04:05Z
74-
ref: sha256:${REGISTRY_acceptance/bundle:tag_DIGEST}
69+
- ref: sha256:${REGISTRY_acceptance/bundle:tag_DIGEST}
7570
"""
7671
And a tekton bundle image named "acceptance/bundle:tag" containing
7772
| Task | task1-updated |
@@ -112,8 +107,7 @@ Feature: track bundles
112107
---
113108
trusted_tasks:
114109
git+https://forge.io/organization/repository.git//task/0.1/task.yaml:
115-
- effective_on: 2006-01-02T15:04:05Z
116-
ref: f0cacc1a
110+
- ref: f0cacc1a
117111
"""
118112
When ec command is run with "track tekton-task --input ${TMPDIR}/bundles.yaml --git git+https://forge.io/organization/repository.git//task/0.1/task.yaml@f0cacc1af00d"
119113
Then the exit status should be 0
@@ -125,8 +119,7 @@ Feature: track bundles
125119
---
126120
trusted_tasks:
127121
git+https://forge.io/organization/repository.git//task/0.1/task.yaml:
128-
- effective_on: 2006-01-02T15:04:05Z
129-
ref: f0cacc1a
122+
- ref: f0cacc1a
130123
"""
131124
When ec command is run with "track tekton-task --prune --input ${TMPDIR}/bundles.yaml --git git+https://forge.io/organization/repository.git//task/0.1/task.yaml@f0cacc1a"
132125
Then the exit status should be 0
@@ -145,8 +138,7 @@ Feature: track bundles
145138
---
146139
trusted_tasks:
147140
git+https://${GITHOST}/git/tasks.git//task.yaml:
148-
- effective_on: 2006-01-02T15:04:05Z
149-
ref: f0cacc1a
141+
- ref: f0cacc1a
150142
"""
151143
Given a git repository named "tasks" with
152144
| task.yaml | examples/task.yaml |

0 commit comments

Comments
 (0)