-
Notifications
You must be signed in to change notification settings - Fork 38
feat: inline CAS backend support in client #246
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -298,10 +298,15 @@ func bizAttestationToPb(att *biz.Attestation) (*cpAPI.AttestationItem, error) { | |
return nil, fmt.Errorf("error extracting predicate from attestation: %w", err) | ||
} | ||
|
||
materials, err := extractMaterials(predicate.GetMaterials()) | ||
if err != nil { | ||
return nil, fmt.Errorf("error extracting materials from attestation: %w", err) | ||
} | ||
|
||
return &cpAPI.AttestationItem{ | ||
Envelope: encodedAttestation, | ||
EnvVars: extractEnvVariables(predicate.GetEnvVars()), | ||
Materials: extractMaterials(predicate.GetMaterials()), | ||
Materials: materials, | ||
}, nil | ||
} | ||
|
||
|
@@ -319,18 +324,23 @@ func extractEnvVariables(in map[string]string) []*cpAPI.AttestationItem_EnvVaria | |
return res | ||
} | ||
|
||
func extractMaterials(in []*chainloop.NormalizedMaterial) []*cpAPI.AttestationItem_Material { | ||
func extractMaterials(in []*chainloop.NormalizedMaterial) ([]*cpAPI.AttestationItem_Material, error) { | ||
res := make([]*cpAPI.AttestationItem_Material, 0, len(in)) | ||
for _, m := range in { | ||
// Initialize simply with the value | ||
displayValue := m.Value | ||
// Override if there is a hash attached | ||
if m.Hash != nil { | ||
displayValue = fmt.Sprintf("%s@%s", m.Value, m.Hash) | ||
name := m.Value | ||
if m.EmbeddedInline || m.UploadedToCAS { | ||
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. I think this deserve a separate helper function like is_downloadable. 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. yeah, the problem is that embedded doesn't mean that can be downloaded. In fact artifact download doesn't work with embedded (inline) artifacts. We'd need to have an artifact-attestation mapping to make it work. 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. I mean, we can call it differently but we already use this "if m.EmbeddedInline || m.UploadedToCAS" in two places. |
||
name = m.Filename | ||
} | ||
|
||
displayValue = fmt.Sprintf("%s@%s", name, m.Hash) | ||
} | ||
|
||
res = append(res, &cpAPI.AttestationItem_Material{Name: m.Name, Value: displayValue, Type: m.Type}) | ||
} | ||
|
||
return res | ||
return res, nil | ||
} |
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.
I would keep a separate limit for inline and a default one like this for CAS. I think I would lower this value
Uh oh!
There was an error while loading. Please reload this page.
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.
Agreed, note that this is changing in #247
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.
re: reducing max size. Until we support changing it I'd not go lower than what we have today. We'd need to check the size of all our binaries and such to make sure they fit.