forked from roboll/helmfile
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(roboll#344): add inherits explicit selectors
- Loading branch information
Showing
9 changed files
with
309 additions
and
23 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
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 |
---|---|---|
@@ -1,8 +1,18 @@ | ||
package app | ||
|
||
import ( | ||
"os" | ||
"strings" | ||
) | ||
|
||
const ( | ||
DefaultHelmfile = "helmfile.yaml" | ||
DeprecatedHelmfile = "charts.yaml" | ||
DefaultHelmfileDirectory = "helmfile.d" | ||
ExperimentalEnvVar = "EXPERIMENTAL" // environment variable for experimental features, expecting "true" lower case | ||
DefaultHelmfile = "helmfile.yaml" | ||
DeprecatedHelmfile = "charts.yaml" | ||
DefaultHelmfileDirectory = "helmfile.d" | ||
ExperimentalEnvVar = "EXPERIMENTAL" // environment variable for experimental features, expecting "true" lower case | ||
ExperimentalSelectorExplicit = "explicit-selector-inheritance" // value to remove default selector inheritance to sub-helmfiles and use the explicit one | ||
) | ||
|
||
func isExplicitSelectorInheritanceEnabled() bool { | ||
return os.Getenv(ExperimentalEnvVar) == "true" || strings.Contains(os.Getenv(ExperimentalEnvVar), ExperimentalSelectorExplicit) | ||
} |
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,27 @@ | ||
package app | ||
|
||
import ( | ||
. "gotest.tools/assert" | ||
is "gotest.tools/assert/cmp" | ||
"gotest.tools/env" | ||
"os" | ||
"testing" | ||
) | ||
|
||
func TestIsExplicitSelectorInheritanceEnabled(t *testing.T) { | ||
//env var ExperimentalEnvVar is set | ||
Assert(t, is.Equal(os.Getenv(ExperimentalEnvVar), "")) | ||
Check(t, !isExplicitSelectorInheritanceEnabled()) | ||
|
||
//check for env var ExperimentalEnvVar set to true | ||
defer env.Patch(t, ExperimentalEnvVar, "true")() | ||
Check(t, isExplicitSelectorInheritanceEnabled()) | ||
|
||
//check for env var ExperimentalEnvVar set to anything | ||
defer env.Patch(t, ExperimentalEnvVar, "foo")() | ||
Check(t, !isExplicitSelectorInheritanceEnabled()) | ||
|
||
//check for env var ExperimentalEnvVar set to ExperimentalSelectorExplicit | ||
defer env.Patch(t, ExperimentalEnvVar, ExperimentalSelectorExplicit)() | ||
Check(t, isExplicitSelectorInheritanceEnabled()) | ||
} |
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.