Skip to content

Commit 33dc6d6

Browse files
committed
Refactored configuration DataLayer Extractor elements
Signed-off-by: Shmuel Kallner <kallner@il.ibm.com>
1 parent 48c51a9 commit 33dc6d6

File tree

4 files changed

+59
-21
lines changed

4 files changed

+59
-21
lines changed

apix/config/v1alpha1/endpointpickerconfig_types.go

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ import (
2929
type EndpointPickerConfig struct {
3030
metav1.TypeMeta `json:",inline"`
3131

32+
// +optional
33+
// FeatureGates is a set of flags that enable various experimental features with the EPP.
34+
// If omitted non of these experimental features will be enabled.
35+
FeatureGates FeatureGates `json:"featureGates,omitempty"`
36+
3237
// +required
3338
// +kubebuilder:validation:Required
3439
// Plugins is the list of plugins that will be instantiated.
@@ -40,11 +45,6 @@ type EndpointPickerConfig struct {
4045
// that will be created.
4146
SchedulingProfiles []SchedulingProfile `json:"schedulingProfiles"`
4247

43-
// +optional
44-
// FeatureGates is a set of flags that enable various experimental features with the EPP.
45-
// If omitted non of these experimental features will be enabled.
46-
FeatureGates FeatureGates `json:"featureGates,omitempty"`
47-
4848
// +optional
4949
// SaturationDetector when present specifies the configuration of the
5050
// Saturation detector. If not present, default values are used.
@@ -57,11 +57,11 @@ type EndpointPickerConfig struct {
5757

5858
func (cfg EndpointPickerConfig) String() string {
5959
return fmt.Sprintf(
60-
"{Plugins: %v, SchedulingProfiles: %v, Data: %v, FeatureGates: %v, SaturationDetector: %v}",
60+
"{FeatureGates: %v, Plugins: %v, SchedulingProfiles: %v, Data: %v, SaturationDetector: %v}",
61+
cfg.FeatureGates,
6162
cfg.Plugins,
6263
cfg.SchedulingProfiles,
6364
cfg.Data,
64-
cfg.FeatureGates,
6565
cfg.SaturationDetector,
6666
)
6767
}
@@ -209,6 +209,7 @@ func (dlc DataLayerConfig) String() string {
209209
return fmt.Sprintf("{Sources: %v}", dlc.Sources)
210210
}
211211

212+
// DataLayerSource contains the configuration of a DataSource of the V2 DataLayer feature
212213
type DataLayerSource struct {
213214
// +required
214215
// +kubebuilder:validation:Required
@@ -222,9 +223,23 @@ type DataLayerSource struct {
222223
// Extractors specifies the list of Plugin instances to be associated with
223224
// this Source. The entries are references to the names of entries of the Plugins
224225
// defined in the configuration's Plugins section
225-
Extractors []string `json:"extractors"`
226+
Extractors []DataLayerExtractor `json:"extractors"`
226227
}
227228

228229
func (dls DataLayerSource) String() string {
229230
return fmt.Sprintf("{PluginRef: %s, Extractors: %v}", dls.PluginRef, dls.Extractors)
230231
}
232+
233+
// DataLayerExtractor contains the configuration of an Extractor of the V2 DataLayer feature
234+
type DataLayerExtractor struct {
235+
// +required
236+
// +kubebuilder:validation:Required
237+
// PluginRef specifies a partiular Plugin instance to be associated with
238+
// this Extractor. The reference is to the name of an entry of the Plugins
239+
// defined in the configuration's Plugins section
240+
PluginRef string `json:"pluginRef"`
241+
}
242+
243+
func (dle DataLayerExtractor) String() string {
244+
return "{PluginRef: " + dle.PluginRef + "}"
245+
}

apix/config/v1alpha1/zz_generated.deepcopy.go

Lines changed: 21 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/epp/config/loader/configloader.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ func loadDataLayerConfig(rawDataConfig *configapi.DataLayerConfig, rawFeatureGat
196196
Extractors: []datalayer.Extractor{},
197197
}
198198
for _, extractor := range source.Extractors {
199-
if extractorPlugin, ok := handle.Plugin(extractor).(datalayer.Extractor); ok {
199+
if extractorPlugin, ok := handle.Plugin(extractor.PluginRef).(datalayer.Extractor); ok {
200200
sourceConfig.Extractors = append(sourceConfig.Extractors, extractorPlugin)
201201
} else {
202202
return nil, fmt.Errorf("the plugin %s is not a datalayer.Extractor", source.PluginRef)

pkg/epp/config/loader/configloader_test.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,12 @@ func TestLoadRawConfiguration(t *testing.T) {
112112
Data: &configapi.DataLayerConfig{
113113
Sources: []configapi.DataLayerSource{
114114
{
115-
PluginRef: "test-source",
116-
Extractors: []string{"test-extractor"},
115+
PluginRef: "test-source",
116+
Extractors: []configapi.DataLayerExtractor{
117+
{
118+
PluginRef: "test-extractor",
119+
},
120+
},
117121
},
118122
},
119123
},
@@ -234,8 +238,12 @@ func TestLoadRawConfigurationWithDefaults(t *testing.T) {
234238
Data: &configapi.DataLayerConfig{
235239
Sources: []configapi.DataLayerSource{
236240
{
237-
PluginRef: "test-source",
238-
Extractors: []string{"test-extractor"},
241+
PluginRef: "test-source",
242+
Extractors: []configapi.DataLayerExtractor{
243+
{
244+
PluginRef: "test-extractor",
245+
},
246+
},
239247
},
240248
},
241249
},
@@ -638,7 +646,7 @@ data:
638646
sources:
639647
- pluginRef: test-source
640648
extractors:
641-
- test-extractor
649+
- pluginRef: test-extractor
642650
featureGates:
643651
- dataLayer
644652
saturationDetector:
@@ -884,7 +892,7 @@ data:
884892
sources:
885893
- pluginRef: test-source
886894
extractors:
887-
- test-one
895+
- pluginRef: test-one
888896
featureGates:
889897
- dataLayer
890898
`

0 commit comments

Comments
 (0)