Skip to content

Commit 3d51e58

Browse files
committed
review feedback
Signed-off-by: Tobias Trabelsi <[email protected]>
1 parent 21ec318 commit 3d51e58

File tree

9 files changed

+43
-43
lines changed

9 files changed

+43
-43
lines changed

cmd/cosign/cli/options/sign.go

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,27 @@ import (
2121

2222
// SignOptions is the top level wrapper for the sign command.
2323
type SignOptions struct {
24-
Key string
25-
Cert string
26-
CertChain string
27-
Upload bool
28-
Output string // deprecated: TODO remove when the output flag is fully deprecated
29-
OutputSignature string // TODO: this should be the root output file arg.
30-
OutputPayload string
31-
OutputCertificate string
32-
PayloadPath string
33-
Recursive bool
34-
Attachment string
35-
SkipConfirmation bool
36-
TlogUpload bool
37-
TSAClientCACert string
38-
TSAClientCert string
39-
TSAClientKey string
40-
TSAServerName string
41-
TSAServerURL string
42-
IssueCertificate bool
43-
SignContainerIdentity string
44-
HonorCreateTimestamp bool
24+
Key string
25+
Cert string
26+
CertChain string
27+
Upload bool
28+
Output string // deprecated: TODO remove when the output flag is fully deprecated
29+
OutputSignature string // TODO: this should be the root output file arg.
30+
OutputPayload string
31+
OutputCertificate string
32+
PayloadPath string
33+
Recursive bool
34+
Attachment string
35+
SkipConfirmation bool
36+
TlogUpload bool
37+
TSAClientCACert string
38+
TSAClientCert string
39+
TSAClientKey string
40+
TSAServerName string
41+
TSAServerURL string
42+
IssueCertificate bool
43+
SignContainerIdentity string
44+
RecordCreationTimestamp bool
4545

4646
Rekor RekorOptions
4747
Fulcio FulcioOptions
@@ -132,5 +132,5 @@ func (o *SignOptions) AddFlags(cmd *cobra.Command) {
132132
cmd.Flags().StringVar(&o.SignContainerIdentity, "sign-container-identity", "",
133133
"manually set the .critical.docker-reference field for the signed identity, which is useful when image proxies are being used where the pull reference should match the signature")
134134

135-
cmd.Flags().BoolVar(&o.HonorCreateTimestamp, "honor-create-timestamp", false, "honor the create timestamp in the signature artefact to be pushed to the OCI registry")
135+
cmd.Flags().BoolVar(&o.RecordCreationTimestamp, "record-creation-timestamp", false, "set the createdAt timestamp in the signature artifact to the time it was created; by default, cosign sets this to the zero value")
136136
}

cmd/cosign/cli/sign/sign.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ func signDigest(ctx context.Context, digest name.Digest, payload []byte, ko opti
329329
}
330330

331331
// Attach the signature to the entity.
332-
newSE, err := mutate.AttachSignatureToEntity(se, ociSig, mutate.WithDupeDetector(dd), mutate.WithHonorCreationTimestamp(signOpts.HonorCreateTimestamp))
332+
newSE, err := mutate.AttachSignatureToEntity(se, ociSig, mutate.WithDupeDetector(dd), mutate.WithHonorCreationTimestamp(signOpts.RecordCreationTimestamp))
333333
if err != nil {
334334
return err
335335
}

doc/cosign_sign.md

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/oci/mutate/mutate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,5 +377,5 @@ func (so *signOpts) dedupeAndReplace(sig oci.Signature, basefn func() (oci.Signa
377377
}
378378
return ReplaceSignatures(replace)
379379
}
380-
return AppendSignatures(base, so.hct, sig)
380+
return AppendSignatures(base, so.rct, sig)
381381
}

pkg/oci/mutate/options.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type SignOption func(*signOpts)
3535
type signOpts struct {
3636
dd DupeDetector
3737
ro ReplaceOp
38-
hct bool
38+
rct bool
3939
}
4040

4141
func makeSignOpts(opts ...SignOption) *signOpts {
@@ -60,9 +60,9 @@ func WithReplaceOp(ro ReplaceOp) SignOption {
6060
}
6161
}
6262

63-
func WithHonorCreationTimestamp(hct bool) SignOption {
63+
func WithHonorCreationTimestamp(rct bool) SignOption {
6464
return func(so *signOpts) {
65-
so.hct = hct
65+
so.rct = rct
6666
}
6767
}
6868

pkg/oci/mutate/signatures.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525

2626
// AppendSignatures produces a new oci.Signatures with the provided signatures
2727
// appended to the provided base signatures.
28-
func AppendSignatures(base oci.Signatures, honorTimestamp bool, sigs ...oci.Signature) (oci.Signatures, error) {
28+
func AppendSignatures(base oci.Signatures, recordCreationTimestamp bool, sigs ...oci.Signature) (oci.Signatures, error) {
2929
adds := make([]mutate.Addendum, 0, len(sigs))
3030
for _, sig := range sigs {
3131
ann, err := sig.Annotations()
@@ -43,7 +43,7 @@ func AppendSignatures(base oci.Signatures, honorTimestamp bool, sigs ...oci.Sign
4343
return nil, err
4444
}
4545

46-
if honorTimestamp {
46+
if recordCreationTimestamp {
4747
t, err := now.Now()
4848
if err != nil {
4949
return nil, err

pkg/oci/static/file.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func NewFile(payload []byte, opts ...Option) (oci.File, error) {
4949
// Add annotations from options
5050
img = mutate.Annotations(img, o.Annotations).(v1.Image)
5151

52-
if o.HonorCreateTimestamp {
52+
if o.RecordCreationTimestamp {
5353
t, err := now.Now()
5454
if err != nil {
5555
return nil, err

pkg/oci/static/file_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func TestNewFile(t *testing.T) {
3232
t.Fatalf("NewFile() = %v", err)
3333
}
3434

35-
timestampedFile, err := NewFile([]byte(payload), WithLayerMediaType("foo"), WithAnnotations(map[string]string{"foo": "bar"}), WithHonorCreationTimestamp(true))
35+
timestampedFile, err := NewFile([]byte(payload), WithLayerMediaType("foo"), WithAnnotations(map[string]string{"foo": "bar"}), WithRecordCreationTimestamp(true))
3636

3737
if err != nil {
3838
t.Fatalf("NewFile() = %v", err)

pkg/oci/static/options.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ import (
2727
type Option func(*options)
2828

2929
type options struct {
30-
LayerMediaType types.MediaType
31-
ConfigMediaType types.MediaType
32-
Bundle *bundle.RekorBundle
33-
RFC3161Timestamp *bundle.RFC3161Timestamp
34-
Cert []byte
35-
Chain []byte
36-
Annotations map[string]string
37-
HonorCreateTimestamp bool
30+
LayerMediaType types.MediaType
31+
ConfigMediaType types.MediaType
32+
Bundle *bundle.RekorBundle
33+
RFC3161Timestamp *bundle.RFC3161Timestamp
34+
Cert []byte
35+
Chain []byte
36+
Annotations map[string]string
37+
RecordCreationTimestamp bool
3838
}
3939

4040
func makeOptions(opts ...Option) (*options, error) {
@@ -114,9 +114,9 @@ func WithCertChain(cert, chain []byte) Option {
114114
}
115115
}
116116

117-
// WithHonorCreationTimestamp sets the feature flag to honor the creation timestamp to time of running
118-
func WithHonorCreationTimestamp(hct bool) Option {
117+
// WithRecordCreationTimestamp sets the feature flag to honor the creation timestamp to time of running
118+
func WithRecordCreationTimestamp(rct bool) Option {
119119
return func(o *options) {
120-
o.HonorCreateTimestamp = hct
120+
o.RecordCreationTimestamp = rct
121121
}
122122
}

0 commit comments

Comments
 (0)