Skip to content

Commit c6d9c89

Browse files
authored
feat: expose container image tag (#798)
Signed-off-by: Miguel Martinez Trivino <[email protected]>
1 parent bfe0422 commit c6d9c89

File tree

10 files changed

+197
-150
lines changed

10 files changed

+197
-150
lines changed

app/cli/cmd/attestation_status.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright 2023 The Chainloop Authors.
2+
// Copyright 2024 The Chainloop Authors.
33
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
55
// you may not use this file except in compliance with the License.
@@ -157,7 +157,11 @@ func materialsTable(status *action.AttestationStatusResult) error {
157157

158158
if full {
159159
if m.Value != "" {
160-
mt.AppendRow(table.Row{"Value", wrap.String(m.Value, 100)})
160+
v := m.Value
161+
if m.Tag != "" {
162+
v = fmt.Sprintf("%s:%s", v, m.Tag)
163+
}
164+
mt.AppendRow(table.Row{"Value", wrap.String(v, 100)})
161165
}
162166

163167
if m.Hash != "" {

app/cli/cmd/workflow_workflow_run_describe.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright 2023 The Chainloop Authors.
2+
// Copyright 2024 The Chainloop Authors.
33
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
55
// you may not use this file except in compliance with the License.
@@ -155,8 +155,12 @@ func predicateV1Table(att *action.WorkflowRunAttestationItem) {
155155
}
156156

157157
// We do not want to show the value if it is a file
158-
if !m.EmbeddedInline && m.UploadedToCAS {
159-
mt.AppendRow(table.Row{"Value", wrap.String(m.Value, 100)})
158+
if !m.EmbeddedInline && m.UploadedToCAS || m.Type == "CONTAINER_IMAGE" {
159+
v := m.Value
160+
if m.Tag != "" {
161+
v = fmt.Sprintf("%s:%s", v, m.Tag)
162+
}
163+
mt.AppendRow(table.Row{"Value", wrap.String(v, 100)})
160164
}
161165

162166
if m.Hash != "" {

app/cli/internal/action/attestation_status.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright 2023 The Chainloop Authors.
2+
// Copyright 2024 The Chainloop Authors.
33
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
55
// you may not use this file except in compliance with the License.
@@ -115,6 +115,7 @@ func (action *AttestationStatus) Run(ctx context.Context, attestationID string)
115115
return nil, err
116116
}
117117
materialResult.Set = true
118+
materialResult.Tag = cm.GetContainerImage().GetTag()
118119
}
119120

120121
res.Materials = append(res.Materials, *materialResult)

app/cli/internal/action/workflow_run_describe.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright 2023 The Chainloop Authors.
2+
// Copyright 2024 The Chainloop Authors.
33
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
55
// you may not use this file except in compliance with the License.
@@ -55,6 +55,7 @@ type Material struct {
5555
Name string `json:"name"`
5656
Value string `json:"value"`
5757
Hash string `json:"hash"`
58+
Tag string `json:"tag"`
5859
Filename string `json:"filename"`
5960
Type string `json:"type"`
6061
Annotations []*Annotation `json:"annotations,omitempty"`
@@ -173,6 +174,7 @@ func materialPBToAction(in *pb.AttestationItem_Material) *Material {
173174
Value: in.Value,
174175
Type: in.Type,
175176
Hash: in.Hash,
177+
Tag: in.Tag,
176178
UploadedToCAS: in.UploadedToCas,
177179
Filename: in.Filename,
178180
EmbeddedInline: in.EmbeddedInline,

app/controlplane/api/controlplane/v1/response_messages.pb.go

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

app/controlplane/api/controlplane/v1/response_messages.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ message AttestationItem {
9797
// Material type, i.e ARTIFACT
9898
string type = 3;
9999
map<string, string> annotations = 4;
100+
// in the case of a container image, the tag of the attested image
101+
string tag = 9;
100102
string hash = 5;
101103
// it's been uploaded to an actual CAS backend
102104
bool uploaded_to_cas = 6;

app/controlplane/api/gen/frontend/controlplane/v1/response_messages.ts

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

app/controlplane/internal/service/attestation.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ func extractMaterials(in []*chainloop.NormalizedMaterial) ([]*cpAPI.AttestationI
417417
Value: m.Value,
418418
UploadedToCas: m.UploadedToCAS,
419419
EmbeddedInline: m.EmbeddedInline,
420+
Tag: m.Tag,
420421
}
421422

422423
if m.Hash != nil {

internal/attestation/renderer/chainloop/chainloop.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ type NormalizedMaterial struct {
5353
Value string
5454
// Hash of the Material
5555
Hash *crv1.Hash
56+
// Tag of the container image
57+
Tag string
5658
// Whether the Material was uploaded and available for download from CAS
5759
UploadedToCAS bool
5860
// Whether the Material was embedded inline in the attestation

internal/attestation/renderer/chainloop/v02.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,11 @@ func normalizeMaterial(material *intoto.ResourceDescriptor) (*NormalizedMaterial
329329
m.EmbeddedInline = true
330330
}
331331

332+
// Extract the container image tag if it's set in the annotations
333+
if v, ok := mAnnotationsMap[annotationContainerTag]; ok && v.GetStringValue() != "" {
334+
m.Tag = v.GetStringValue()
335+
}
336+
332337
// In the case of an artifact type or derivative the filename is set and the inline content if any
333338
if m.EmbeddedInline || m.UploadedToCAS {
334339
m.Filename = material.Name

0 commit comments

Comments
 (0)