Skip to content

Commit 97bd704

Browse files
AdanUrbanReyesArmoryDigital On Us
and
Digital On Us
authored
chore(mapConvertions): Add basic types while converting to string map (#44)
* chore(mapConvertions): Add basic types while converting to string map * test(mapConvertions): Add basic types while converting to string map unit test Co-authored-by: Digital On Us <[email protected]>
1 parent fac44ad commit 97bd704

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

pkg/yaml/yaml.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func convertToStringMap(m map[interface{}]interface{}) map[string]interface{} {
7171
switch vv.(type) {
7272
case map[interface{}]interface{}:
7373
collection = append(collection, convertToStringMap(vv.(map[interface{}]interface{})))
74-
case string:
74+
case string, int, bool, float64:
7575
collection = append(collection, fmt.Sprintf("%v", vv))
7676
}
7777
}

pkg/yaml/yaml_test.go

+13
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,19 @@ func TestResolver(t *testing.T) {
112112
//empty url
113113
project := google["primaryCredentials"].(map[string]interface{})["project"]
114114
assert.Equal(t, "", project)
115+
116+
//interface array basic types
117+
aa := services["agent"].(map[string]interface{})
118+
ak := aa["kubernetes"].(map[string]interface{})
119+
aas := ak["accounts"].([]interface{})
120+
aap := aas[0].(map[string]interface{})["permissions"].(map[string]interface{})
121+
arp := aap["READ"].([]interface{})
122+
assert.Equal(t, "123", arp[0])
123+
assert.Equal(t, "45.6", arp[1])
124+
assert.Equal(t, "false", arp[2])
125+
assert.Equal(t, "true", arp[3])
126+
assert.Equal(t, "develop", arp[4])
127+
115128
}
116129

117130
func TestResolverCollections(t *testing.T) {

test/spinnaker-armory.yml

+11
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ services:
66
clouddriver:
77
host: ${DEFAULT_DNS_NAME:clouddriver}
88

9+
agent:
10+
kubernetes:
11+
accounts:
12+
- permissions:
13+
READ:
14+
- 123
15+
- 45.6
16+
- false
17+
- true
18+
- develop
19+
920
echo:
1021
host: ${DEFAULT_DNS_NAME:echo}
1122
slackApiKey: encrypted:noop!mynotsosecretstring

0 commit comments

Comments
 (0)