Skip to content

Add backwards compatible changes to ParsePath for extra behaviors#154

Merged
sgmiller merged 5 commits intomainfrom
sgm/parsepath-options
Jan 16, 2025
Merged

Add backwards compatible changes to ParsePath for extra behaviors#154
sgmiller merged 5 commits intomainfrom
sgm/parsepath-options

Conversation

@sgmiller
Copy link
Copy Markdown
Contributor

go-kms-wrapping wants to use ParsePath to supply sensitive values from out
of band means. But there are three differences that could cause the
inability to supply a value exactly as stored in a file or ENV var with the
existing mechanism or debug misconfigured uses.

  1. Trims all values at the moment, and leading/trailing spaces
    could be significant.
  2. Silently provides "" for an env var that's missing, making it
    difficult to debug mistaken env var names or unset env vars.
  3. (unlikely, but possible), it's not possible to actually supply a value
    that has one of the URL prefixes.

This PR adds an options pattern to solve #1 and #2 by being able to disable
trimming and enable error on missing env var. The status quo is unchanged.

Adds a "string://" url scheme that returns everything following that prefix
untouched, so you can write a value that contains a URL prefix supported by
ParsePath. This does have the limitation of not supporting leading/trailing
spaces in the value after string://, as that's invalid in the URL schema.

@sgmiller sgmiller requested a review from jefferai as a code owner January 13, 2025 21:03
@sgmiller sgmiller requested a review from a team January 14, 2025 19:01
Copy link
Copy Markdown
Contributor

@stevendpclark stevendpclark left a comment

Choose a reason for hiding this comment

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

👍

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.

3 participants