Skip to content

Commit 94f2c15

Browse files
committed
move experimental flag to internal package
needed to expose in a separate package so can be accessed from v3 tests
1 parent b0e2000 commit 94f2c15

File tree

14 files changed

+56
-24
lines changed

14 files changed

+56
-24
lines changed

pkg/internal/flags.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
Copyright 2021 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package internal
18+
19+
// Used by tests to selectively disable experimental JSON unmarshaler
20+
var UseExperimentalJSONUnmarshaling bool = true

pkg/validation/spec/header.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919

2020
jsonv2 "github.com/go-json-experiment/json"
2121
"github.com/go-openapi/swag"
22+
"k8s.io/kube-openapi/pkg/internal"
2223
)
2324

2425
const (
@@ -63,7 +64,7 @@ func (h Header) MarshalJSON() ([]byte, error) {
6364

6465
// UnmarshalJSON unmarshals this header from JSON
6566
func (h *Header) UnmarshalJSON(data []byte) error {
66-
if UseExperimentalJSONUnmarshaling {
67+
if internal.UseExperimentalJSONUnmarshaling {
6768
return jsonv2.Unmarshal(data, h)
6869
}
6970

pkg/validation/spec/info.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020

2121
jsonv2 "github.com/go-json-experiment/json"
2222
"github.com/go-openapi/swag"
23+
"k8s.io/kube-openapi/pkg/internal"
2324
)
2425

2526
// Extensions vendor specific extensions
@@ -193,7 +194,7 @@ func (i Info) MarshalJSON() ([]byte, error) {
193194

194195
// UnmarshalJSON marshal this from JSON
195196
func (i *Info) UnmarshalJSON(data []byte) error {
196-
if UseExperimentalJSONUnmarshaling {
197+
if internal.UseExperimentalJSONUnmarshaling {
197198
return jsonv2.Unmarshal(data, i)
198199
}
199200

pkg/validation/spec/items.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919

2020
jsonv2 "github.com/go-json-experiment/json"
2121
"github.com/go-openapi/swag"
22+
"k8s.io/kube-openapi/pkg/internal"
2223
)
2324

2425
const (
@@ -65,7 +66,7 @@ type Items struct {
6566

6667
// UnmarshalJSON hydrates this items instance with the data from JSON
6768
func (i *Items) UnmarshalJSON(data []byte) error {
68-
if UseExperimentalJSONUnmarshaling {
69+
if internal.UseExperimentalJSONUnmarshaling {
6970
return jsonv2.Unmarshal(data, i)
7071
}
7172

pkg/validation/spec/operation.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919

2020
jsonv2 "github.com/go-json-experiment/json"
2121
"github.com/go-openapi/swag"
22+
"k8s.io/kube-openapi/pkg/internal"
2223
)
2324

2425
// OperationProps describes an operation
@@ -76,7 +77,7 @@ type Operation struct {
7677

7778
// UnmarshalJSON hydrates this items instance with the data from JSON
7879
func (o *Operation) UnmarshalJSON(data []byte) error {
79-
if UseExperimentalJSONUnmarshaling {
80+
if internal.UseExperimentalJSONUnmarshaling {
8081
return jsonv2.Unmarshal(data, o)
8182
}
8283

pkg/validation/spec/parameter.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919

2020
jsonv2 "github.com/go-json-experiment/json"
2121
"github.com/go-openapi/swag"
22+
"k8s.io/kube-openapi/pkg/internal"
2223
)
2324

2425
// ParamProps describes the specific attributes of an operation parameter
@@ -76,7 +77,7 @@ type Parameter struct {
7677

7778
// UnmarshalJSON hydrates this items instance with the data from JSON
7879
func (p *Parameter) UnmarshalJSON(data []byte) error {
79-
if UseExperimentalJSONUnmarshaling {
80+
if internal.UseExperimentalJSONUnmarshaling {
8081
return jsonv2.Unmarshal(data, p)
8182
}
8283

pkg/validation/spec/path_item.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919

2020
jsonv2 "github.com/go-json-experiment/json"
2121
"github.com/go-openapi/swag"
22+
"k8s.io/kube-openapi/pkg/internal"
2223
)
2324

2425
// PathItemProps the path item specific properties
@@ -47,7 +48,7 @@ type PathItem struct {
4748

4849
// UnmarshalJSON hydrates this items instance with the data from JSON
4950
func (p *PathItem) UnmarshalJSON(data []byte) error {
50-
if UseExperimentalJSONUnmarshaling {
51+
if internal.UseExperimentalJSONUnmarshaling {
5152
return jsonv2.Unmarshal(data, p)
5253
}
5354

pkg/validation/spec/paths.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121

2222
jsonv2 "github.com/go-json-experiment/json"
2323
"github.com/go-openapi/swag"
24+
"k8s.io/kube-openapi/pkg/internal"
2425
)
2526

2627
// Paths holds the relative paths to the individual endpoints.
@@ -36,7 +37,7 @@ type Paths struct {
3637

3738
// UnmarshalJSON hydrates this items instance with the data from JSON
3839
func (p *Paths) UnmarshalJSON(data []byte) error {
39-
if UseExperimentalJSONUnmarshaling {
40+
if internal.UseExperimentalJSONUnmarshaling {
4041
return jsonv2.Unmarshal(data, p)
4142
}
4243

pkg/validation/spec/response.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919

2020
jsonv2 "github.com/go-json-experiment/json"
2121
"github.com/go-openapi/swag"
22+
"k8s.io/kube-openapi/pkg/internal"
2223
)
2324

2425
// ResponseProps properties specific to a response
@@ -40,7 +41,7 @@ type Response struct {
4041

4142
// UnmarshalJSON hydrates this items instance with the data from JSON
4243
func (r *Response) UnmarshalJSON(data []byte) error {
43-
if UseExperimentalJSONUnmarshaling {
44+
if internal.UseExperimentalJSONUnmarshaling {
4445
return jsonv2.Unmarshal(data, r)
4546
}
4647

pkg/validation/spec/responses.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222

2323
jsonv2 "github.com/go-json-experiment/json"
2424
"github.com/go-openapi/swag"
25+
"k8s.io/kube-openapi/pkg/internal"
2526
)
2627

2728
// Responses is a container for the expected responses of an operation.
@@ -92,7 +93,7 @@ func (r ResponsesProps) MarshalJSON() ([]byte, error) {
9293

9394
// UnmarshalJSON unmarshals responses from JSON
9495
func (r *ResponsesProps) UnmarshalJSON(data []byte) error {
95-
if UseExperimentalJSONUnmarshaling {
96+
if internal.UseExperimentalJSONUnmarshaling {
9697
return jsonv2.Unmarshal(data, r)
9798
}
9899

0 commit comments

Comments
 (0)