@@ -22,19 +22,19 @@ type Image struct {
22
22
23
23
Tags []string
24
24
25
- ContainerFormat * string
26
- DiskFormat * string
25
+ ContainerFormat string
26
+ DiskFormat string
27
27
28
- MinDiskGigabytes * int
29
- MinRAMMegabytes * int
28
+ MinDiskGigabytes int
29
+ MinRAMMegabytes int
30
30
31
- Owner * string
31
+ Owner string
32
32
33
33
Protected bool
34
34
Visibility ImageVisibility
35
35
36
- Checksum * string
37
- SizeBytes * int
36
+ Checksum string
37
+ SizeBytes int
38
38
39
39
Metadata map [string ]string
40
40
Properties map [string ]string
@@ -68,37 +68,37 @@ func asString(any interface{}, key string) (string, error) {
68
68
return "" , fmt .Errorf ("expected string value for key '%s', but found: %#v" , key , any )
69
69
}
70
70
71
- func asNoneableString (any interface {}, key string ) (* string , error ) {
71
+ func asNoneableString (any interface {}, key string ) (string , error ) {
72
72
// JSON null values could be also returned according to behaviour https://bugs.launchpad.net/glance/+bug/1481512
73
73
if any == nil {
74
- return nil , nil
74
+ return "" , nil
75
75
}
76
76
if str , ok := any .(string ); ok {
77
77
if str == "None" || & str == nil {
78
- return nil , nil
78
+ return "" , nil
79
79
}
80
- return & str , nil
80
+ return str , nil
81
81
}
82
- return nil , fmt .Errorf ("expected string value for key '%s', but found: %#v" , key , any )
82
+ return "" , fmt .Errorf ("expected string value for key '%s', but found: %#v" , key , any )
83
83
}
84
84
85
- func asNoneableInteger (any interface {}, key string ) (* int , error ) {
85
+ func asNoneableInteger (any interface {}, key string ) (int , error ) {
86
86
// FIXME problem here is that provider_client.go uses: json.NewDecoder(resp.Body).Decode(options.JSONResponse)
87
87
// which apparently converts integers in JSON to float64 values
88
88
// JSON null values could be also returned according to behaviour https://bugs.launchpad.net/glance/+bug/1481512
89
89
if any == nil {
90
- return nil , nil
90
+ return 0 , nil
91
91
}
92
92
if f , ok := any .(float64 ); ok {
93
93
i := int (f )
94
- return & i , nil
94
+ return i , nil
95
95
} else if s , ok := any .(string ); ok {
96
96
if s == "None" {
97
- return nil , nil
97
+ return 0 , nil
98
98
}
99
- return nil , fmt .Errorf ("expected \" None\" or integer value for key '%s', but found unexpected string: \" %s\" " , key , s )
99
+ return 0 , fmt .Errorf ("expected \" None\" or integer value for key '%s', but found unexpected string: \" %s\" " , key , s )
100
100
}
101
- return nil , fmt .Errorf ("expected \" None\" or integer value for key '%s', but found: %T(%#v)" , key , any , any )
101
+ return 0 , fmt .Errorf ("expected \" None\" or integer value for key '%s', but found: %T(%#v)" , key , any , any )
102
102
}
103
103
104
104
func asMapStringString (any interface {}) (map [string ]string , error ) {
@@ -129,18 +129,18 @@ func extractStringAtKey(m map[string]interface{}, k string) (string, error) {
129
129
return "" , fmt .Errorf ("expected key \" %s\" in map, but this key is not present" , k )
130
130
}
131
131
132
- func extractNoneableStringAtKey (m map [string ]interface {}, k string ) (* string , error ) {
132
+ func extractNoneableStringAtKey (m map [string ]interface {}, k string ) (string , error ) {
133
133
if any , ok := m [k ]; ok {
134
134
return asNoneableString (any , k )
135
135
}
136
- return nil , fmt .Errorf ("expected key \" %s\" in map, but this key is not present" , k )
136
+ return "" , fmt .Errorf ("expected key \" %s\" in map, but this key is not present" , k )
137
137
}
138
138
139
- func extractNoneableIntegerAtKey (m map [string ]interface {}, k string ) (* int , error ) {
139
+ func extractNoneableIntegerAtKey (m map [string ]interface {}, k string ) (int , error ) {
140
140
if any , ok := m [k ]; ok {
141
141
return asNoneableInteger (any , k )
142
142
}
143
- return nil , fmt .Errorf ("expected key \" %s\" in map, but this key is not present" , k )
143
+ return 0 , fmt .Errorf ("expected key \" %s\" in map, but this key is not present" , k )
144
144
}
145
145
146
146
func extractStringSliceAtKey (m map [string ]interface {}, key string ) ([]string , error ) {
0 commit comments