Skip to content

Commit 7a63312

Browse files
committed
address subset of review comments
Signed-off-by: Etai Lev Ran <[email protected]>
1 parent b59264e commit 7a63312

File tree

2 files changed

+10
-26
lines changed

2 files changed

+10
-26
lines changed

pkg/epp/datalayer/datasource.go

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,13 @@ type DataSource interface {
3434
Start(ctx context.Context) error
3535

3636
// Stop stops the collection process.
37-
Stop() error
38-
39-
// OutputType returns the type of information collected.
40-
// TODO: this could be made private and excluded from the interface.
41-
// Use will likely be in the context of debugging/logging.
42-
OutputType() reflect.Type
37+
Stop()
4338

4439
// AddExtractor adds an extractor to the data source.
4540
// The extractor will be called whenever the data source might
4641
// have some new raw information regarding an endpoint.
47-
// The Extractor's expected input type is validated when it is
48-
// registered.
42+
// The Extractor's expected input type should be validated against
43+
// the data source output type upon registration.
4944
AddExtractor(extractor Extractor) error
5045

5146
// TODO: the following is useful for a data source that operates on
@@ -102,17 +97,17 @@ func (dsr *DataSourceRegistry) Register(src DataSource) error {
10297
}
10398

10499
// GetNamedSource returns the named data source, if found.
105-
func (dsr *DataSourceRegistry) GetNamedSource(name string) (DataSource, error) {
100+
func (dsr *DataSourceRegistry) GetNamedSource(name string) (DataSource, bool) {
106101
if name == "" {
107-
return nil, errors.New("unable to retrieve a data source without a name")
102+
return nil, false
108103
}
109104

110105
dsr.mu.RLock()
111106
defer dsr.mu.RUnlock()
112107
if ds, found := dsr.sources[name]; found {
113-
return ds, nil
108+
return ds, true
114109
}
115-
return nil, &NotFoundError{Name: name}
110+
return nil, false
116111
}
117112

118113
// AddEndpoint adds a new endpoint to all registered sources.
@@ -166,7 +161,7 @@ func RegisterSource(src DataSource) error {
166161

167162
// GetNamedSource returns the named source from the default registry,
168163
// if found.
169-
func GetNamedSource(name string) (DataSource, error) {
164+
func GetNamedSource(name string) (DataSource, bool) {
170165
return DefaultDataSources.GetNamedSource(name)
171166
}
172167

@@ -181,17 +176,6 @@ func RemoveEndpoint(ep Endpoint) error {
181176
return DefaultDataSources.RemoveEndpoint(ep)
182177
}
183178

184-
// NotFoundError is an explicit error value raised when a
185-
// source is not found in the requested registry.
186-
type NotFoundError struct {
187-
Name string
188-
}
189-
190-
// Error returns tha associated error string.
191-
func (e *NotFoundError) Error() string {
192-
return fmt.Sprintf("data source not found: %v", e.Name)
193-
}
194-
195179
// ValidateExtractorType checks if an extractor can handle
196180
// the collector's output.
197181
func ValidateExtractorType(collectorOutputType, extractorInputType reflect.Type) error {

pkg/epp/datalayer/podinfo.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ type PodInfo struct {
3030
Labels map[string]string
3131
}
3232

33-
// FromAPIPod converts a Kubernetes API Pod to its internal representation.
34-
func FromAPIPod(pod *corev1.Pod) *PodInfo {
33+
// ToPodInfo converts a Kubernetes API Pod to its internal representation.
34+
func ToPodInfo(pod *corev1.Pod) *PodInfo {
3535
labels := make(map[string]string, len(pod.GetLabels()))
3636
for key, value := range pod.GetLabels() {
3737
labels[key] = value

0 commit comments

Comments
 (0)