Skip to content

Commit 2ff72da

Browse files
authored
feat: expose inline material content (#343)
Signed-off-by: Miguel Martinez Trivino <[email protected]>
1 parent 84929ca commit 2ff72da

File tree

7 files changed

+169
-125
lines changed

7 files changed

+169
-125
lines changed

app/cli/cmd/workflow_workflow_run_describe.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,15 @@ func predicateV1Table(att *action.WorkflowRunAttestationItem) {
145145
for _, m := range materials {
146146
mt.AppendRow(table.Row{"Name", m.Name})
147147
mt.AppendRow(table.Row{"Type", m.Type})
148-
mt.AppendRow(table.Row{"Value", wrap.String(m.Value, 100)})
148+
if m.Filename != "" {
149+
mt.AppendRow(table.Row{"Filename", m.Filename})
150+
}
151+
152+
// We do not want to show the value if it is a file
153+
if !m.EmbeddedInline && m.UploadedToCAS {
154+
mt.AppendRow(table.Row{"Value", wrap.String(m.Value, 100)})
155+
}
156+
149157
if m.Hash != "" {
150158
mt.AppendRow(table.Row{"Digest", m.Hash})
151159
}

app/cli/internal/action/workflow_run_describe.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ type WorkflowRunAttestationItem struct {
5555
}
5656

5757
type Material struct {
58-
Name string `json:"name"`
59-
// filename, container image name, string value, ...
58+
Name string `json:"name"`
6059
Value string `json:"value"`
6160
Hash string `json:"hash"`
61+
Filename string `json:"filename"`
6262
Type string `json:"type"`
6363
Annotations []*Annotation `json:"annotations,omitempty"`
6464
UploadedToCAS bool `json:"uploadedToCAS,omitempty"`
@@ -170,6 +170,7 @@ func materialPBToAction(in *pb.AttestationItem_Material) *Material {
170170
Type: in.Type,
171171
Hash: in.Hash,
172172
UploadedToCAS: in.UploadedToCas,
173+
Filename: in.Filename,
173174
EmbeddedInline: in.EmbeddedInline,
174175
}
175176

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

Lines changed: 127 additions & 116 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.pb.validate.go

Lines changed: 2 additions & 0 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
@@ -74,6 +74,8 @@ message AttestationItem {
7474
string name = 1;
7575
// This might be the raw value, the container image name, the filename and so on
7676
string value = 2;
77+
// filename of the artifact that was either uploaded or injected inline in "value"
78+
string filename = 8;
7779
// Material type, i.e ARTIFACT
7880
string type = 3;
7981
map<string, string> annotations = 4;

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

Lines changed: 25 additions & 1 deletion
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 & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ func extractMaterials(in []*chainloop.NormalizedMaterial) ([]*cpAPI.AttestationI
389389
materialItem := &cpAPI.AttestationItem_Material{
390390
Name: m.Name,
391391
Type: m.Type,
392+
Filename: m.Filename,
392393
Annotations: m.Annotations,
393394
Value: m.Value,
394395
UploadedToCas: m.UploadedToCAS,
@@ -399,11 +400,6 @@ func extractMaterials(in []*chainloop.NormalizedMaterial) ([]*cpAPI.AttestationI
399400
materialItem.Hash = m.Hash.String()
400401
}
401402

402-
// Override the value for the filename of the item uploaded
403-
if m.EmbeddedInline || m.UploadedToCAS {
404-
materialItem.Value = m.Filename
405-
}
406-
407403
res = append(res, materialItem)
408404
}
409405

0 commit comments

Comments
 (0)