-
Notifications
You must be signed in to change notification settings - Fork 26
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
Add mediatype string builder to bundle package #154
Conversation
23a2d8d
to
0a944d8
Compare
pkg/bundle/bundle.go
Outdated
return "", fmt.Errorf("unable to build media type string, no version defined") | ||
} | ||
|
||
mtString := fmt.Sprintf("%s+json;version=%s", mediaTypeBase, strings.TrimPrefix(version, "v")) |
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.
This is dependent on version now, since we made a change to be compliant with OCI as per sigstore/protobuf-specs#165.
v0.1 and v0.2 should be application/vnd.dev.sigstore.bundle+json;version=0.1
and application/vnd.dev.sigstore.bundle+json;version=0.2
respectively, and for v0.3 onwards, application/vnd.dev.sigstore.bundle.v0.%s+json
where %s
is the trimmed version.
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.
Ah thanks for the pointer @haydentherapper I was wondering if they were interchangeable. OK, now the function will return the old style for 0.1 - 0.2 and the new one for the rest. I've added cases to test them.
This commit adds a mediatype build string to generate media type strings Signed-off-by: Adolfo García Veytia (Puerco) <[email protected]>
0a944d8
to
8a63eb8
Compare
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.
Thanks!
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.
Nice!
Summary
This commit adds a media type string build function to handle the media type string in the module.
With the release of 0.3 all apps relying on the media type constants in
pkg/bundle
broke as the constants were removed in 20c2ce9. This PR introduces a function to generate the media type string from the module and avoid spreading media type strings on applications using the module.Fixes: #153
/cc @codysoyland
Release Note
Added a
bundle.MediaTypeString()
function to handle the media type strings from the bundle moduleDocumentation