-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some refactoring, call prepareKubeConfig only once per RG
- Loading branch information
Showing
8 changed files
with
151 additions
and
43 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,45 @@ | ||
package config | ||
|
||
import "testing" | ||
|
||
func TestGetByPath(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
vars Variables | ||
path string | ||
want any | ||
found bool | ||
}{ | ||
{ | ||
name: "simple", | ||
vars: Variables{ | ||
"key": "value", | ||
}, | ||
path: "key", | ||
want: "value", | ||
found: true, | ||
}, | ||
{ | ||
name: "nested", | ||
vars: Variables{ | ||
"key": Variables{ | ||
"key": "value", | ||
}, | ||
}, | ||
path: "key.key", | ||
want: "value", | ||
found: true, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got, found := tt.vars.GetByPath(tt.path) | ||
if got != tt.want { | ||
t.Errorf("Variables.GetByPath() got = %v, want %v", got, tt.want) | ||
} | ||
if found != tt.found { | ||
t.Errorf("Variables.GetByPath() found = %v, want %v", found, tt.found) | ||
} | ||
}) | ||
} | ||
} |
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,16 @@ | ||
package utils | ||
|
||
import "fmt" | ||
|
||
func AnyToString(value any) string { | ||
switch v := value.(type) { | ||
case string: | ||
return v | ||
case int: | ||
return fmt.Sprintf("%d", v) | ||
case bool: | ||
return fmt.Sprintf("%t", v) | ||
default: | ||
return fmt.Sprintf("%v", v) | ||
} | ||
} |
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,4 @@ | ||
deploy: | ||
echo ${DRY_RUN} | ||
|
||
.PHONE: deploy |
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