-
Notifications
You must be signed in to change notification settings - Fork 0
feat!: Send product metadata in custom header #62
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
Merged
liamhughes
merged 5 commits into
main
from
liamhughes/devex-43-send-product-metadata-from-provider-libraries
May 27, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| ".": "3.0.2" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "packages": { | ||
| ".": { | ||
| "release-type": "node", | ||
| "extra-files": ["src/version.ts"] | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| export * from "./octopusFeatureProvider"; | ||
| export * from "./productMetadata"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| import { ProductMetadata } from "./productMetadata"; | ||
|
|
||
| describe("ProductMetadata", () => { | ||
| describe("name", () => { | ||
| test("valid name characters are preserved unchanged", () => { | ||
| const metadata = new ProductMetadata("OctopusDeploy"); | ||
| expect(metadata.name).toBe("OctopusDeploy"); | ||
| }); | ||
|
|
||
| test("spaces and punctuation are stripped from name", () => { | ||
| const metadata = new ProductMetadata("My ,Product (v2.0)/release@2024:final"); | ||
| expect(metadata.name).toBe("MyProductv2.0release2024final"); | ||
| }); | ||
|
|
||
| test("hyphens are preserved in name", () => { | ||
| const metadata = new ProductMetadata("My-Product"); | ||
| expect(metadata.name).toBe("My-Product"); | ||
| }); | ||
|
|
||
| test("throws when name is whitespace only", () => { | ||
| expect(() => new ProductMetadata(" ")).toThrow("Product name"); | ||
| }); | ||
|
|
||
| test("throws when name becomes empty after stripping invalid chars", () => { | ||
| expect(() => new ProductMetadata(" @@@ ")).toThrow("Product name"); | ||
| }); | ||
| }); | ||
|
|
||
| describe("version", () => { | ||
| test("version is undefined when not provided", () => { | ||
| const metadata = new ProductMetadata("MyProduct"); | ||
| expect(metadata.version).toBeUndefined(); | ||
| }); | ||
|
|
||
| test("valid version characters are preserved unchanged", () => { | ||
| const metadata = new ProductMetadata("MyProduct", "2024.1.0"); | ||
| expect(metadata.version).toBe("2024.1.0"); | ||
| }); | ||
|
|
||
| test("unsupported chars in version are stripped", () => { | ||
| const metadata = new ProductMetadata("MyProduct", "2024.1 (beta)"); | ||
| expect(metadata.version).toBe("2024.1beta"); | ||
| }); | ||
|
|
||
| test("throws when version is whitespace only", () => { | ||
| expect(() => new ProductMetadata("MyProduct", " ")).toThrow("Product version"); | ||
| }); | ||
|
|
||
| test("throws when version becomes empty after stripping invalid chars", () => { | ||
| expect(() => new ProductMetadata("MyProduct", " @@@ ")).toThrow("Product version"); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| // RFC 9110 token characters: https://www.rfc-editor.org/rfc/rfc9110.html#name-tokens | ||
| const INVALID_TCHAR = /[^a-zA-Z0-9!#$%&'*+\-.^_`|~]/g; | ||
|
|
||
| function clean(value: string): string { | ||
| return value.replace(INVALID_TCHAR, ""); | ||
| } | ||
|
|
||
| export class ProductMetadata { | ||
| readonly name: string; | ||
| readonly version: string | undefined; | ||
|
|
||
| constructor(name: string); | ||
| constructor(name: string, version: string); | ||
| constructor(name: string, version?: string) { | ||
| this.name = clean(name); | ||
| this.validateName(); | ||
|
|
||
| if (version !== undefined) { | ||
| this.version = clean(version); | ||
| this.validateVersion(); | ||
| } else { | ||
| this.version = undefined; | ||
| } | ||
| } | ||
|
|
||
| private validateName(): void { | ||
| if (!this.name) { | ||
| throw new Error("Product name must contain at least one valid token character."); | ||
| } | ||
| } | ||
|
|
||
| private validateVersion(): void { | ||
| if (!this.version) { | ||
| throw new Error("Product version must contain at least one valid token character."); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export const PROVIDER_VERSION = "3.0.2"; // x-release-please-version |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
As an aside, I am aligning these between the three libraries.
https://openfeature.dev/specification/sections/providers/#requirement-211