Skip to content
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

Merged
merged 1 commit into from Apr 24, 2024

Conversation

puerco
Copy link
Member

@puerco puerco commented Apr 23, 2024

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 module

Documentation

@puerco puerco changed the title Add mediatype string builder Add mediatype string builder to bunndle package Apr 23, 2024
@puerco puerco changed the title Add mediatype string builder to bunndle package Add mediatype string builder to bundle package Apr 23, 2024
return "", fmt.Errorf("unable to build media type string, no version defined")
}

mtString := fmt.Sprintf("%s+json;version=%s", mediaTypeBase, strings.TrimPrefix(version, "v"))
Copy link
Contributor

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.

Copy link
Member Author

@puerco puerco Apr 23, 2024

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) <puerco@stacklok.com>
Copy link
Contributor

@haydentherapper haydentherapper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Member

@codysoyland codysoyland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@codysoyland codysoyland merged commit c1df1ba into sigstore:main Apr 24, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Avoid repeating media type strings
3 participants