-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
465 additions
and
69 deletions.
There are no files selected for viewing
This file contains 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,26 @@ | ||
package attributes | ||
|
||
import "strings" | ||
|
||
type VarHandler func(k string, v string) | ||
|
||
func ParseOTELResourceVariable(envVar string, handler VarHandler) { | ||
// split all the comma-separated key=value entries | ||
for _, entry := range strings.Split(envVar, ",") { | ||
// split only by the first '=' appearance, as values might | ||
// have base64 '=' padding symbols | ||
keyVal := strings.SplitN(entry, "=", 2) | ||
if len(keyVal) < 2 { | ||
continue | ||
} | ||
|
||
k := strings.TrimSpace(keyVal[0]) | ||
v := strings.TrimSpace(keyVal[1]) | ||
|
||
if k == "" || v == "" { | ||
continue | ||
} | ||
|
||
handler(strings.TrimSpace(keyVal[0]), strings.TrimSpace(keyVal[1])) | ||
} | ||
} |
This file contains 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 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 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 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 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
Oops, something went wrong.