Skip to content

Commit b1b96b7

Browse files
committed
improve plugins names
1 parent ec0311f commit b1b96b7

18 files changed

+75
-75
lines changed

tools/openapi2crd/config.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ spec:
2323
plugins:
2424
- base
2525
- major_version
26-
- parameter
26+
- parameters
2727
- entry
2828
- status
29-
- sensitive_property
30-
- skipped_property
31-
- read_only_property
32-
- read_write_property
33-
- reference
34-
- reference_metadata
29+
- sensitive_properties
30+
- skipped_properties
31+
- read_only_properties
32+
- read_write_properties
33+
- references
34+
- references_metadata
3535
- mutual_exclusive_major_versions
3636
- atlas_sdk_version
3737

tools/openapi2crd/pkg/plugins/catalog.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,20 +122,20 @@ func NewCatalog() *Catalog {
122122
},
123123
mapping: map[string]MappingPlugin{
124124
"major_version": &MajorVersion{},
125-
"parameter": &Parameter{},
125+
"parameters": &Parameters{},
126126
"entry": &Entry{},
127127
"status": &Status{},
128-
"reference": &Reference{},
128+
"references": &References{},
129129
},
130130
property: map[string]PropertyPlugin{
131-
"sensitive_property": &SensitiveProperty{},
132-
"skipped_property": &SkippedProperty{},
133-
"read_only_property": &ReadOnlyProperty{},
134-
"read_write_property": &ReadWriteProperty{},
131+
"sensitive_properties": &SensitiveProperties{},
132+
"skipped_properties": &SkippedProperties{},
133+
"read_only_properties": &ReadOnlyProperties{},
134+
"read_write_properties": &ReadWriteProperties{},
135135
},
136136
extension: map[string]ExtensionPlugin{
137-
"atlas_sdk_version": &AtlasSdkVersionPlugin{},
138-
"reference_metadata": &ReferenceMetadata{},
137+
"atlas_sdk_version": &AtlasSdkVersionPlugin{},
138+
"references_metadata": &ReferencesMetadata{},
139139
},
140140
}
141141
}

tools/openapi2crd/pkg/plugins/catalog_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ func TestBuildSets(t *testing.T) {
4141
Name: "set-2",
4242
Default: false,
4343
CRD: []CRDPlugin{&Base{}},
44-
Mapping: []MappingPlugin{&Entry{}, &Status{}, &Reference{}},
45-
Property: []PropertyPlugin{&ReadOnlyProperty{}, &ReadWriteProperty{}},
44+
Mapping: []MappingPlugin{&Entry{}, &Status{}, &References{}},
45+
Property: []PropertyPlugin{&ReadOnlyProperties{}, &ReadWriteProperties{}},
4646
Extension: []ExtensionPlugin{},
4747
},
4848
},
@@ -69,15 +69,15 @@ func TestBuildSets(t *testing.T) {
6969
CRD: []CRDPlugin{&Base{}},
7070
Mapping: []MappingPlugin{&Entry{}, &Status{}},
7171
Property: []PropertyPlugin{},
72-
Extension: []ExtensionPlugin{&ReferenceMetadata{}},
72+
Extension: []ExtensionPlugin{&ReferencesMetadata{}},
7373
},
7474
{
7575
Name: "set-2",
7676
Default: false,
7777
CRD: []CRDPlugin{&Base{}},
78-
Mapping: []MappingPlugin{&Entry{}, &Status{}, &Reference{}},
79-
Property: []PropertyPlugin{&ReadOnlyProperty{}, &ReadWriteProperty{}},
80-
Extension: []ExtensionPlugin{&ReferenceMetadata{}},
78+
Mapping: []MappingPlugin{&Entry{}, &Status{}, &References{}},
79+
Property: []PropertyPlugin{&ReadOnlyProperties{}, &ReadWriteProperties{}},
80+
Extension: []ExtensionPlugin{&ReferencesMetadata{}},
8181
},
8282
},
8383
expectedErr: nil,
@@ -153,8 +153,8 @@ func TestGetPluginSet(t *testing.T) {
153153
Name: "set-2",
154154
Default: false,
155155
CRD: []CRDPlugin{&Base{}},
156-
Mapping: []MappingPlugin{&Entry{}, &Status{}, &Reference{}},
157-
Property: []PropertyPlugin{&ReadOnlyProperty{}, &ReadWriteProperty{}},
156+
Mapping: []MappingPlugin{&Entry{}, &Status{}, &References{}},
157+
Property: []PropertyPlugin{&ReadOnlyProperties{}, &ReadWriteProperties{}},
158158
Extension: []ExtensionPlugin{},
159159
},
160160
},
@@ -163,8 +163,8 @@ func TestGetPluginSet(t *testing.T) {
163163
Name: "set-2",
164164
Default: false,
165165
CRD: []CRDPlugin{&Base{}},
166-
Mapping: []MappingPlugin{&Entry{}, &Status{}, &Reference{}},
167-
Property: []PropertyPlugin{&ReadOnlyProperty{}, &ReadWriteProperty{}},
166+
Mapping: []MappingPlugin{&Entry{}, &Status{}, &References{}},
167+
Property: []PropertyPlugin{&ReadOnlyProperties{}, &ReadWriteProperties{}},
168168
Extension: []ExtensionPlugin{},
169169
},
170170
expectedError: nil,
@@ -183,8 +183,8 @@ func TestGetPluginSet(t *testing.T) {
183183
Name: "set-2",
184184
Default: false,
185185
CRD: []CRDPlugin{&Base{}},
186-
Mapping: []MappingPlugin{&Entry{}, &Status{}, &Reference{}},
187-
Property: []PropertyPlugin{&ReadOnlyProperty{}, &ReadWriteProperty{}},
186+
Mapping: []MappingPlugin{&Entry{}, &Status{}, &References{}},
187+
Property: []PropertyPlugin{&ReadOnlyProperties{}, &ReadWriteProperties{}},
188188
Extension: []ExtensionPlugin{},
189189
},
190190
},
@@ -213,8 +213,8 @@ func TestGetPluginSet(t *testing.T) {
213213
Name: "set-2",
214214
Default: false,
215215
CRD: []CRDPlugin{&Base{}},
216-
Mapping: []MappingPlugin{&Entry{}, &Status{}, &Reference{}},
217-
Property: []PropertyPlugin{&ReadOnlyProperty{}, &ReadWriteProperty{}},
216+
Mapping: []MappingPlugin{&Entry{}, &Status{}, &References{}},
217+
Property: []PropertyPlugin{&ReadOnlyProperties{}, &ReadWriteProperties{}},
218218
Extension: []ExtensionPlugin{},
219219
},
220220
},

tools/openapi2crd/pkg/plugins/parameter.go renamed to tools/openapi2crd/pkg/plugins/parameters.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ import (
99
"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions"
1010
)
1111

12-
// Parameter adds parameters from the OpenAPI spec to the CRD schema.
12+
// Parameters adds parameters from the OpenAPI spec to the CRD schema.
1313
// It requires base and major version plugins to be run before.
14-
type Parameter struct{}
14+
type Parameters struct{}
1515

16-
func (p *Parameter) Name() string {
17-
return "parameter"
16+
func (p *Parameters) Name() string {
17+
return "parameters"
1818
}
1919

20-
func (p *Parameter) Process(req *MappingProcessorRequest) error {
20+
func (p *Parameters) Process(req *MappingProcessorRequest) error {
2121
majorVersionSpec := req.CRD.Spec.Validation.OpenAPIV3Schema.Properties["spec"].Properties[req.MappingConfig.MajorVersion]
2222

2323
if req.MappingConfig.ParametersMapping.Path.Name != "" {

tools/openapi2crd/pkg/plugins/parameter_test.go renamed to tools/openapi2crd/pkg/plugins/parameters_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
)
1616

1717
func TestParameterName(t *testing.T) {
18-
p := &Parameter{}
18+
p := &Parameters{}
1919
assert.Equal(t, "parameter", p.Name())
2020
}
2121

@@ -124,7 +124,7 @@ func TestParameterProcess(t *testing.T) {
124124
}
125125
for name, tt := range tests {
126126
t.Run(name, func(t *testing.T) {
127-
p := &Parameter{}
127+
p := &Parameters{}
128128
err := p.Process(tt.request)
129129
assert.Equal(t, tt.expectedErr, err)
130130
versionSpec := tt.request.CRD.Spec.Validation.OpenAPIV3Schema.Properties["spec"].Properties[tt.request.MappingConfig.MajorVersion]

tools/openapi2crd/pkg/plugins/plugin.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ var _ CRDPlugin = &Base{}
4949
var _ CRDPlugin = &MutualExclusiveMajorVersions{}
5050
var _ MappingPlugin = &Entry{}
5151
var _ MappingPlugin = &Status{}
52-
var _ MappingPlugin = &Parameter{}
53-
var _ MappingPlugin = &Reference{}
52+
var _ MappingPlugin = &Parameters{}
53+
var _ MappingPlugin = &References{}
5454
var _ MappingPlugin = &MajorVersion{}
55-
var _ PropertyPlugin = &ReadOnlyProperty{}
56-
var _ PropertyPlugin = &ReadWriteProperty{}
57-
var _ PropertyPlugin = &SensitiveProperty{}
58-
var _ PropertyPlugin = &SkippedProperty{}
55+
var _ PropertyPlugin = &ReadOnlyProperties{}
56+
var _ PropertyPlugin = &ReadWriteProperties{}
57+
var _ PropertyPlugin = &SensitiveProperties{}
58+
var _ PropertyPlugin = &SkippedProperties{}
5959
var _ ExtensionPlugin = &AtlasSdkVersionPlugin{}
60-
var _ ExtensionPlugin = &ReferenceMetadata{}
60+
var _ ExtensionPlugin = &ReferencesMetadata{}

tools/openapi2crd/pkg/plugins/read_only_property.go renamed to tools/openapi2crd/pkg/plugins/read_only_properties.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import (
66
"k8s.io/apimachinery/pkg/util/sets"
77
)
88

9-
type ReadOnlyProperty struct{}
9+
type ReadOnlyProperties struct{}
1010

11-
func (p *ReadOnlyProperty) Name() string {
12-
return "read_only_property"
11+
func (p *ReadOnlyProperties) Name() string {
12+
return "read_only_properties"
1313
}
1414

15-
func (p *ReadOnlyProperty) Process(req *PropertyProcessorRequest) error {
15+
func (p *ReadOnlyProperties) Process(req *PropertyProcessorRequest) error {
1616
if req.PropertyConfig == nil || !req.PropertyConfig.Filters.ReadOnly {
1717
return nil
1818
}

tools/openapi2crd/pkg/plugins/read_only_property_test.go renamed to tools/openapi2crd/pkg/plugins/read_only_properties_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
)
1111

1212
func TestReadOnlyPropertyName(t *testing.T) {
13-
p := &ReadOnlyProperty{}
13+
p := &ReadOnlyProperties{}
1414
assert.Equal(t, "read_only_property", p.Name())
1515
}
1616

@@ -127,7 +127,7 @@ func TestReadOnlyPropertyProcess(t *testing.T) {
127127
}
128128
for name, test := range tests {
129129
t.Run(name, func(t *testing.T) {
130-
p := &ReadOnlyProperty{}
130+
p := &ReadOnlyProperties{}
131131
err := p.Process(test.request)
132132
assert.Equal(t, test.expectedError, err)
133133
assert.Equal(t, test.expectedProps, test.request.Property)

tools/openapi2crd/pkg/plugins/read_write_property.go renamed to tools/openapi2crd/pkg/plugins/read_write_properties.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import (
66
"k8s.io/apimachinery/pkg/util/sets"
77
)
88

9-
type ReadWriteProperty struct{}
9+
type ReadWriteProperties struct{}
1010

11-
func (p *ReadWriteProperty) Name() string {
11+
func (p *ReadWriteProperties) Name() string {
1212
return "read_write_property"
1313
}
1414

15-
func (p *ReadWriteProperty) Process(req *PropertyProcessorRequest) error {
15+
func (p *ReadWriteProperties) Process(req *PropertyProcessorRequest) error {
1616
if req.PropertyConfig == nil || !req.PropertyConfig.Filters.ReadWriteOnly {
1717
return nil
1818
}

tools/openapi2crd/pkg/plugins/read_write_property_test.go renamed to tools/openapi2crd/pkg/plugins/read_write_properties_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
)
1111

1212
func TestReadWritePropertyName(t *testing.T) {
13-
p := &ReadWriteProperty{}
13+
p := &ReadWriteProperties{}
1414
assert.Equal(t, "read_write_property", p.Name())
1515
}
1616

@@ -106,7 +106,7 @@ func TestReadWritePropertyProcess(t *testing.T) {
106106
}
107107
for name, tc := range tests {
108108
t.Run(name, func(t *testing.T) {
109-
p := &ReadWriteProperty{}
109+
p := &ReadWriteProperties{}
110110
err := p.Process(tc.request)
111111
assert.Equal(t, tc.expectedError, err)
112112
assert.Equal(t, tc.expectedProps, tc.request.Property)

0 commit comments

Comments
 (0)