@@ -27,6 +27,7 @@ import (
27
27
"github.com/go-openapi/loads"
28
28
"github.com/go-openapi/spec"
29
29
"gopkg.in/yaml.v2"
30
+ "k8s.io/kubernetes/test/conformance/behaviors"
30
31
)
31
32
32
33
type options struct {
@@ -67,19 +68,19 @@ func main() {
67
68
defMap [d .Ref .String ()] = d
68
69
}
69
70
70
- var suites []Suite
71
- var suiteMapping = make (map [string ]* Suite )
71
+ var suites []behaviors. Suite
72
+ var suiteMapping = make (map [string ]* behaviors. Suite )
72
73
73
74
for _ , v := range defs {
74
75
if ! v .TopLevel || o .resource != v .Name {
75
76
continue
76
77
}
77
78
name := trimObjectName (v .Name )
78
79
79
- defaultsuite := Suite {
80
+ defaultsuite := behaviors. Suite {
80
81
Suite : o .area + "/spec" ,
81
82
Description : "Base suite for " + o .area ,
82
- Behaviors : []Behavior {},
83
+ Behaviors : []behaviors. Behavior {},
83
84
}
84
85
85
86
_ = defaultsuite
@@ -89,10 +90,10 @@ func main() {
89
90
90
91
if propSchema .Ref .String () != "" || propSchema .Type [0 ] == "array" {
91
92
if _ , ok := suiteMapping [id ]; ! ok {
92
- newsuite := Suite {
93
+ newsuite := behaviors. Suite {
93
94
Suite : o .area + "/" + p ,
94
95
Description : "Suite for " + o .area + "/" + p ,
95
- Behaviors : []Behavior {},
96
+ Behaviors : []behaviors. Behavior {},
96
97
}
97
98
suiteMapping [id ] = & newsuite
98
99
}
@@ -101,10 +102,10 @@ func main() {
101
102
suiteMapping [id ].Behaviors = behaviors
102
103
} else {
103
104
if _ , ok := suiteMapping ["default" ]; ! ok {
104
- newsuite := Suite {
105
+ newsuite := behaviors. Suite {
105
106
Suite : o .area + "/spec" ,
106
107
Description : "Base suite for " + o .area ,
107
- Behaviors : []Behavior {},
108
+ Behaviors : []behaviors. Behavior {},
108
109
}
109
110
suiteMapping ["default" ] = & newsuite
110
111
}
@@ -122,12 +123,12 @@ func main() {
122
123
break
123
124
}
124
125
125
- var area Area = Area {o .area , suites }
126
+ var area behaviors. Area = behaviors. Area {Area : o .area , Suites : suites }
126
127
countFields (suites )
127
128
printYAML (o .behaviorsDir + o .area , area )
128
129
}
129
130
130
- func printYAML (fileName string , areaO Area ) {
131
+ func printYAML (fileName string , areaO behaviors. Area ) {
131
132
f , err := os .Create (fileName + ".yaml" )
132
133
if err != nil {
133
134
fmt .Printf ("ERROR: %s\n " , err .Error ())
@@ -147,7 +148,7 @@ func printYAML(fileName string, areaO Area) {
147
148
}
148
149
}
149
150
150
- func countFields (suites []Suite ) {
151
+ func countFields (suites []behaviors. Suite ) {
151
152
var fieldsMapping map [string ]int
152
153
fieldsMapping = make (map [string ]int )
153
154
for _ , suite := range suites {
@@ -174,43 +175,43 @@ func trimObjectName(name string) string {
174
175
return name
175
176
}
176
177
177
- func objectBehaviors (id string , s * spec.Schema ) []Behavior {
178
+ func objectBehaviors (id string , s * spec.Schema ) []behaviors. Behavior {
178
179
if strings .Contains (id , "openAPIV3Schema" ) || strings .Contains (id , "JSONSchema" ) || strings .Contains (s .Ref .String (), "JSONSchema" ) {
179
- return []Behavior {}
180
+ return []behaviors. Behavior {}
180
181
}
181
182
182
183
ref , ok := defMap [s .Ref .String ()]
183
184
if ! ok {
184
- return []Behavior {}
185
+ return []behaviors. Behavior {}
185
186
}
186
187
187
188
return schemaBehaviors (id , trimObjectName (ref .Name ), ref .Schema )
188
189
}
189
190
190
- func schemaBehaviors (base , apiObject string , s * spec.Schema ) []Behavior {
191
- var behaviors []Behavior
191
+ func schemaBehaviors (base , apiObject string , s * spec.Schema ) []behaviors. Behavior {
192
+ var behaviors []behaviors. Behavior
192
193
for p , propSchema := range s .Properties {
193
194
b := schemaBehavior (base , apiObject , p , propSchema )
194
195
behaviors = append (behaviors , b ... )
195
196
}
196
197
return behaviors
197
198
}
198
199
199
- func schemaBehavior (base , apiObject , p string , propSchema spec.Schema ) []Behavior {
200
+ func schemaBehavior (base , apiObject , p string , propSchema spec.Schema ) []behaviors. Behavior {
200
201
201
202
id := strings .Join ([]string {base , p }, "/" )
202
203
if propSchema .Ref .String () != "" {
203
204
if apiObject == trimObjectName (propSchema .Ref .String ()) {
204
- return []Behavior {}
205
+ return []behaviors. Behavior {}
205
206
}
206
207
return objectBehaviors (id , & propSchema )
207
208
}
208
- var b []Behavior
209
+ var b []behaviors. Behavior
209
210
switch propSchema .Type [0 ] {
210
211
case "array" :
211
212
b = objectBehaviors (id , propSchema .Items .Schema )
212
213
case "boolean" :
213
- b = []Behavior {
214
+ b = []behaviors. Behavior {
214
215
{
215
216
ID : id ,
216
217
APIObject : apiObject ,
@@ -227,7 +228,7 @@ func schemaBehavior(base, apiObject, p string, propSchema spec.Schema) []Behavio
227
228
},
228
229
}
229
230
default :
230
- b = []Behavior {{
231
+ b = []behaviors. Behavior {{
231
232
ID : id ,
232
233
APIObject : apiObject ,
233
234
APIField : p ,
0 commit comments