Skip to content

Commit 8fadcc2

Browse files
authored
feat: show attestation digest in notifications (#332)
Signed-off-by: Miguel Martinez Trivino <[email protected]>
1 parent 70cbda9 commit 8fadcc2

File tree

10 files changed

+140
-117
lines changed

10 files changed

+140
-117
lines changed

app/controlplane/internal/dispatcher/dispatcher.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ func (d *FanOutDispatcher) Run(ctx context.Context, opts *RunOpts) error {
126126
},
127127
}
128128

129+
if wfRun.Attestation != nil {
130+
workflowMetadata.WorkflowRun.AttestationDigest = wfRun.Attestation.Digest
131+
}
132+
129133
// Dispatch the integrations
130134
for _, item := range queue {
131135
req := generateRequest(item, workflowMetadata)

app/controlplane/plugins/sdk/v1/fanout.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,13 @@ type ChainloopMetadata struct {
120120
}
121121

122122
type ChainloopMetadataWorkflowRun struct {
123-
ID string
124-
State string
125-
StartedAt time.Time
126-
FinishedAt time.Time
127-
RunnerType string
128-
RunURL string
123+
ID string
124+
State string
125+
StartedAt time.Time
126+
FinishedAt time.Time
127+
RunnerType string
128+
RunURL string
129+
AttestationDigest string
129130
}
130131

131132
type ChainloopMetadataWorkflow struct {

app/controlplane/plugins/sdk/v1/helpers.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ func (r *renderer) summaryTable(m *ChainloopMetadata, predicate chainloop.Normal
105105
tw.AppendRow(table.Row{"Workflow Run"})
106106
tw.AppendSeparator()
107107
tw.AppendRow(table.Row{"ID", wr.ID})
108+
tw.AppendRow(table.Row{"Attestation", wr.AttestationDigest})
108109
tw.AppendRow(table.Row{"Started At", wr.StartedAt.Format(time.RFC822)})
109110
tw.AppendRow(table.Row{"Finished At", wr.FinishedAt.Format(time.RFC822)})
110111
tw.AppendRow(table.Row{"State", wr.State})
@@ -141,7 +142,7 @@ func (r *renderer) summaryTable(m *ChainloopMetadata, predicate chainloop.Normal
141142
}
142143
mt.AppendRow(table.Row{"Value", wrap.String(value, 100)})
143144
if m.Hash != nil {
144-
mt.AppendRow(table.Row{"Digest", m.Hash.Hex})
145+
mt.AppendRow(table.Row{"Digest", m.Hash.String()})
145146
}
146147

147148
if annotations := m.Annotations; len(annotations) > 0 {

app/controlplane/plugins/sdk/v1/helpers_test.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,13 @@ func (s *helperTestSuite) SetupTest() {
102102
Team: "test-team",
103103
},
104104
WorkflowRun: &ChainloopMetadataWorkflowRun{
105-
ID: "beefdead",
106-
State: "success",
107-
StartedAt: date,
108-
FinishedAt: date.Add(10 * time.Minute),
109-
RunnerType: "github-actions",
110-
RunURL: "chainloop.dev/runner",
105+
ID: "beefdead",
106+
State: "success",
107+
StartedAt: date,
108+
FinishedAt: date.Add(10 * time.Minute),
109+
RunnerType: "github-actions",
110+
RunURL: "chainloop.dev/runner",
111+
AttestationDigest: "sha256:deadbeef",
111112
},
112113
}
113114
}

app/controlplane/plugins/sdk/v1/plugin/api/fanout.pb.go

Lines changed: 68 additions & 57 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/controlplane/plugins/sdk/v1/plugin/api/fanout.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ message ExecuteRequest {
133133
string run_url = 4;
134134
google.protobuf.Timestamp started_at = 5;
135135
google.protobuf.Timestamp finished_at = 6;
136+
string attestation_digest = 7;
136137
}
137138
}
138139
}

app/controlplane/plugins/sdk/v1/plugin/api/translation.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,12 @@ func MetadataSDKToProto(in *sdk.ChainloopMetadata) *ExecuteRequest_Metadata {
118118
Team: in.Workflow.Team,
119119
},
120120
WorkflowRun: &ExecuteRequest_Metadata_WorkflowRun{
121-
Id: in.WorkflowRun.ID,
122-
State: in.WorkflowRun.State,
123-
RunnerType: in.WorkflowRun.RunnerType,
124-
RunUrl: in.WorkflowRun.RunURL,
125-
StartedAt: timestamppb.New(in.WorkflowRun.StartedAt),
121+
Id: in.WorkflowRun.ID,
122+
State: in.WorkflowRun.State,
123+
RunnerType: in.WorkflowRun.RunnerType,
124+
RunUrl: in.WorkflowRun.RunURL,
125+
StartedAt: timestamppb.New(in.WorkflowRun.StartedAt),
126+
AttestationDigest: in.WorkflowRun.AttestationDigest,
126127
},
127128
}
128129

@@ -142,11 +143,12 @@ func MetadataProtoToSDK(in *ExecuteRequest_Metadata) *sdk.ChainloopMetadata {
142143
Team: in.Workflow.Team,
143144
},
144145
WorkflowRun: &sdk.ChainloopMetadataWorkflowRun{
145-
ID: in.WorkflowRun.Id,
146-
State: in.WorkflowRun.State,
147-
RunnerType: in.WorkflowRun.RunnerType,
148-
RunURL: in.WorkflowRun.RunUrl,
149-
StartedAt: in.WorkflowRun.StartedAt.AsTime(),
146+
ID: in.WorkflowRun.Id,
147+
State: in.WorkflowRun.State,
148+
RunnerType: in.WorkflowRun.RunnerType,
149+
RunURL: in.WorkflowRun.RunUrl,
150+
StartedAt: in.WorkflowRun.StartedAt.AsTime(),
151+
AttestationDigest: in.WorkflowRun.AttestationDigest,
150152
},
151153
}
152154

app/controlplane/plugins/sdk/v1/testdata/attestations/full.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
| Project | test-project |
66
| Workflow Run | |
77
| ID | beefdead |
8+
| Attestation | sha256:deadbeef |
89
| Started At | 22 Nov 21 00:00 UTC |
910
| Finished At | 22 Nov 21 00:10 UTC |
1011
| State | success |
@@ -16,17 +17,17 @@
1617
| Name | image |
1718
| Type | CONTAINER_IMAGE |
1819
| Value | index.docker.io/bitnami/nginx |
19-
| Digest | 264f55a6ff9cec2f4742a9faacc033b29f65c04dd4480e71e23579d484288d61 |
20+
| Digest | sha256:264f55a6ff9cec2f4742a9faacc033b29f65c04dd4480e71e23579d484288d61 |
2021
| Name | skynet-sbom |
2122
| Type | SBOM_CYCLONEDX_JSON |
2223
| Value | sbom.cyclonedx.json |
23-
| Digest | 16159bb881eb4ab7eb5d8afc5350b0feeed1e31c0a268e355e74f9ccbe885e0c |
24+
| Digest | sha256:16159bb881eb4ab7eb5d8afc5350b0feeed1e31c0a268e355e74f9ccbe885e0c |
2425
| Annotations | ------ |
2526
| | component: nginx |
2627
| Name | skynet2-sbom |
2728
| Type | SBOM_CYCLONEDX_JSON |
2829
| Value | sbom.cyclonedx.json |
29-
| Digest | 16159bb881eb4ab7eb5d8afc5350b0feeed1e31c0a268e355e74f9ccbe885e0c |
30+
| Digest | sha256:16159bb881eb4ab7eb5d8afc5350b0feeed1e31c0a268e355e74f9ccbe885e0c |
3031
# Environment Variables
3132
| Name | Value |
3233
| --- | --- |

0 commit comments

Comments
 (0)