-
Notifications
You must be signed in to change notification settings - Fork 155
Full access to image url and digest in StorageOpts #589
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,7 +33,14 @@ type Signable interface { | |
| StorageBackend(cfg config.Config) sets.String | ||
| Signer(cfg config.Config) string | ||
| PayloadFormat(cfg config.Config) formats.PayloadType | ||
| Key(interface{}) string | ||
| // FullKey returns the full identifier for a signable artifact. | ||
| // - For OCI artifact, it is the full representation in the format of `<NAME>@sha256:<DIGEST>`. | ||
| // - For TaskRun/PipelineRun artifact, it is `<GROUP>-<VERSION>-<KIND>-<UID>` | ||
| FullKey(interface{}) string | ||
| // ShortKey returns the short version of an artifact identifier. | ||
| // - For OCI artifact, it is first 12 chars of the image digest. | ||
| // - For TaskRun/PipelineRun artifact, it is `<KIND>-<UID>`. | ||
| ShortKey(interface{}) string | ||
| Type() string | ||
| Enabled(cfg config.Config) bool | ||
| } | ||
|
|
@@ -42,11 +49,19 @@ type TaskRunArtifact struct { | |
| Logger *zap.SugaredLogger | ||
| } | ||
|
|
||
| func (ta *TaskRunArtifact) Key(obj interface{}) string { | ||
| var _ Signable = &TaskRunArtifact{} | ||
|
|
||
| func (ta *TaskRunArtifact) ShortKey(obj interface{}) string { | ||
| tro := obj.(*objects.TaskRunObject) | ||
| return "taskrun-" + string(tro.UID) | ||
| } | ||
|
|
||
| func (ta *TaskRunArtifact) FullKey(obj interface{}) string { | ||
| tro := obj.(*objects.TaskRunObject) | ||
| gvk := tro.GetGroupVersionKind() | ||
| return fmt.Sprintf("%s-%s-%s-%s", gvk.Group, gvk.Version, gvk.Kind, tro.UID) | ||
| } | ||
|
|
||
| func (ta *TaskRunArtifact) ExtractObjects(obj objects.TektonObject) []interface{} { | ||
| return []interface{}{obj} | ||
| } | ||
|
|
@@ -75,11 +90,19 @@ type PipelineRunArtifact struct { | |
| Logger *zap.SugaredLogger | ||
| } | ||
|
|
||
| func (pa *PipelineRunArtifact) Key(obj interface{}) string { | ||
| var _ Signable = &PipelineRunArtifact{} | ||
|
|
||
| func (pa *PipelineRunArtifact) ShortKey(obj interface{}) string { | ||
| pro := obj.(*objects.PipelineRunObject) | ||
| return "pipelinerun-" + string(pro.UID) | ||
| } | ||
|
|
||
| func (pa *PipelineRunArtifact) FullKey(obj interface{}) string { | ||
| pro := obj.(*objects.PipelineRunObject) | ||
| gvk := pro.GetGroupVersionKind() | ||
| return fmt.Sprintf("%s-%s-%s-%s", gvk.Group, gvk.Version, gvk.Kind, pro.UID) | ||
| } | ||
|
|
||
| func (pa *PipelineRunArtifact) ExtractObjects(obj objects.TektonObject) []interface{} { | ||
| return []interface{}{obj} | ||
| } | ||
|
|
@@ -109,6 +132,8 @@ type OCIArtifact struct { | |
| Logger *zap.SugaredLogger | ||
| } | ||
|
|
||
| var _ Signable = &OCIArtifact{} | ||
|
|
||
| type image struct { | ||
| url string | ||
| digest string | ||
|
|
@@ -291,11 +316,16 @@ func (oa *OCIArtifact) Signer(cfg config.Config) string { | |
| return cfg.Artifacts.OCI.Signer | ||
| } | ||
|
|
||
| func (oa *OCIArtifact) Key(obj interface{}) string { | ||
| func (oa *OCIArtifact) ShortKey(obj interface{}) string { | ||
| v := obj.(name.Digest) | ||
| return strings.TrimPrefix(v.DigestStr(), "sha256:")[:12] | ||
| } | ||
|
|
||
| func (oa *OCIArtifact) FullKey(obj interface{}) string { | ||
| v := obj.(name.Digest) | ||
| return v.Name() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should double check the behavior here for annotation based storage - we should probably preserve the old behavior there since IIRC labels/annotations have a fixed key size, and including the full digest may cause issues.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| } | ||
|
|
||
| func (oa *OCIArtifact) Enabled(cfg config.Config) bool { | ||
| return cfg.Artifacts.OCI.Enabled() | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bikeshed: I'm okay with Key/ShortKey. I know we've been lax about this, but we should also add godoc describing the difference between the 2 (you can generalize instead of going into the specifics of each impl).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I've added godoc in the struct that contains those the shortKey and fullKey field. Please take a look and let me know what you think. Happy to update it further if needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want docs here as well since this is where Signable implementors / IDEs are going to look for documentation for the type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see. Added! Please take a look! Thanks