-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Minor refactorings Signed-off-by: Volkan Ozcelik <[email protected]> * Fixed unit tests. Signed-off-by: Volkan Ozcelik <[email protected]> * Add version number to docs. Signed-off-by: Volkan Ozcelik <[email protected]> * Minor change. Signed-off-by: Volkan Ozcelik <[email protected]> * Doc update. Signed-off-by: Volkan Ozcelik <[email protected]> * Inline comment update Signed-off-by: Volkan Ozcelik <[email protected]> * Add newline Signed-off-by: Volkan Ozcelik <[email protected]> --------- Signed-off-by: Volkan Ozcelik <[email protected]>
- Loading branch information
Showing
11 changed files
with
76 additions
and
54 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
| Protect your secrets, protect your sensitive data. | ||
: Explore VMware Secrets Manager docs at https://vsecm.com/ | ||
</ | ||
<>/ keep your secrets... secret | ||
>/ | ||
<>/' Copyright 2023-present VMware Secrets Manager contributors. | ||
>/' SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
||
package template | ||
|
||
import "strings" | ||
|
||
const separator = "," | ||
const delimiter = ":" | ||
|
||
// empty is a constant string representing an empty value. | ||
// This value is generated by the go templating engine | ||
// when a key-value pair has no value. Don't change this value. | ||
const empty = "<no value>" | ||
|
||
// removeKeyValueWithNoValue takes an input string containing key-value pairs | ||
// and filters out pairs where the value is "<no value>". It splits the input | ||
// string into key-value pairs, iterates through them, and retains only the | ||
// pairs with values that are not equal to "<no value>". | ||
// The function then joins the filtered pairs back into a string and returns the | ||
// resulting string. This function effectively removes key-value pairs with | ||
// "<no value>" from the input string. Helpful for data cleaning and filtering | ||
// when you want to omit certain key/value pairs from a template. | ||
func removeKeyValueWithNoValue(input string) string { | ||
// Split the input string into key-value pairs | ||
pairs := strings.Split(input, separator) | ||
|
||
// Initialize a slice to store the filtered pairs | ||
var filteredPairs []string | ||
|
||
for _, pair := range pairs { | ||
keyValue := strings.SplitN(pair, delimiter, 2) | ||
if len(keyValue) == 2 && keyValue[1] != empty { | ||
// Add the pair to the filtered pairs if the value is not | ||
// "<no value>" | ||
filteredPairs = append(filteredPairs, pair) | ||
} | ||
} | ||
|
||
// Join the filtered pairs back into a string | ||
result := strings.Join(filteredPairs, ",") | ||
return result | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,4 @@ smart_punctuation = true | |
|
||
[extra] | ||
author = "VMware Secrets Manager Contributors" | ||
version = "0.25.4" |
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