-
Notifications
You must be signed in to change notification settings - Fork 8
fix(ci): update nanotdf create function signature to use options #374
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
base: main
Are you sure you want to change the base?
Conversation
Doom4535
left a comment
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 like the code cleanup; I believe the direct inclusion of the OpenTDF sdk can be avoided here by using the one that is already wrapped inside of the handler (although I have not tested these changes myself).
| // TODO: validate values are FQNs or return an error [https://github.com/opentdf/platform/issues/515] | ||
| _, err = h.sdk.CreateNanoTDF(enc, bytes.NewReader(b), *nanoTDFConfig) | ||
| _, err := h.sdk.CreateNanoTDF(enc, bytes.NewReader(b), options...) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| return enc, 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.
Slight code shortening:
if _, err := h.sdk.CreateNanoTDF(enc, bytes.NewReader(b), options...); err != nil {
return nil, err
}
return enc, nil| _, err := h.sdk.ReadNanoTDF(io.Writer(&outBuf), bytes.NewReader(toDecrypt)) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| return &outBuf, 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.
While we're here, we could shorten this spot a bit as well:
if _, err := h.sdk.ReadNanoTDF(io.Writer(&outBuf), bytes.NewReader(toDecrypt)); err != nil {
return nil, err
}
return &outBuf, nil| options := []sdk.NanoTDFOption{ | ||
| sdk.WithKasURL(h.platformEndpoint + kasUrlPath), | ||
| sdk.WithNanoDataAttributes(values), | ||
| } | ||
| if ecdsaBinding { | ||
| nanoTDFConfig.EnableECDSAPolicyBinding() | ||
| options = append(options, sdk.WithECDSAPolicyBinding()) | ||
| } |
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.
Is it possible to remove the need for the extra module inclusion of github.com/opentdf/platform/sdk by using the handler wrapped sdk? Something like:
options := []h.sdk.NanoTDFOption{
h.sdk.WithKasURL(h.platformEndpoint + kasUrlPath),
h.sdk.WithNanoDataAttributes(values),
}
if ecdsaBinding {
options = append(options, h.sdk.WithECDSAPolicyBinding())
}|
@sujankota I believe the commit name also needs to be updated, as this fix is not for the CI/CD environment; also don't forget to signoff on the commit to satisfy the DCO (part of the new committing process: https://github.com/opentdf/otdfctl/blob/main/CONTRIBUTING.md). |
No description provided.