From 562611a65d2b96d1907d475c254e705f2e703d1a Mon Sep 17 00:00:00 2001 From: Michele Costa Date: Tue, 20 Jun 2023 10:13:04 +0100 Subject: [PATCH] Fix spellings and typos --- doc/implementing_a_collector.md | 12 ++++++------ pkg/collectors/collector.go | 4 ++-- pkg/collectors/devices/fetcher.go | 2 +- pkg/collectors/devices/ptp_devices.go | 16 ++++++++-------- pkg/collectors/gps_ubx_collector.go | 10 +++++----- pkg/collectors/ptp_collector.go | 16 ++++++++-------- pkg/runner/runner.go | 14 +++++++------- 7 files changed, 37 insertions(+), 37 deletions(-) diff --git a/doc/implementing_a_collector.md b/doc/implementing_a_collector.md index 392ad8a1..55ba9e06 100644 --- a/doc/implementing_a_collector.md +++ b/doc/implementing_a_collector.md @@ -19,7 +19,7 @@ type CollectionConstuctor struct { ... ``` -In `collectors/anouncement_collector.go` you should define your collector and a constuctor method on `CollectionConstuctor` +In `collectors/anouncement_collector.go` you should define your collector and aconstructor method on `CollectionConstuctor` ```go package collectors @@ -63,12 +63,12 @@ func (anouncer *AnouncementCollector) CleanUp(key string) error { } func (constuctor *CollectionConstuctor) NewAnouncementCollector() (*AnouncementCollector, error) { - anouncer := AnouncementCollector{callback: constuctor.Callback, msg: constuctor.Msg} + anouncer := AnouncementCollector{callback:constructor.Callback, msg:constructor.Msg} return &anouncer, nil } ``` -In runner/runner.go Call the `NewAnouncementCollector` constuctor in the `initialise` method of CollectorRunner and append `"Anouncer"` to `collectorNames` in the `NewCollectorRunner` function. +In runner/runner.go Call the `NewAnouncementCollector`constructor in the `initialise` method of CollectorRunner and append `"Anouncer"` to `collectorNames` in the `NewCollectorRunner` function. ```go func NewCollectorRunner() CollectorRunner { ... @@ -78,12 +78,12 @@ func NewCollectorRunner() CollectorRunner { func (runner *CollectorRunner) initialise(...){ ... - for _, constuctorName := range runner.collectorNames { + for _,constructorName := range runner.collectorNames { var newCollector collectors.Collector - switch constuctorName { + switchconstructorName { ... case "Anouncer": //nolint: goconst // This is just for ilustrative purposes - NewAnouncerCollector, err := constuctor.NewAnouncementCollector() + NewAnouncerCollector, err :=constructor.NewAnouncementCollector() // Handle error... utils.IfErrorPanic(err) newCollector = NewAnouncerCollector diff --git a/pkg/collectors/collector.go b/pkg/collectors/collector.go index 7dfd956e..1a350a78 100644 --- a/pkg/collectors/collector.go +++ b/pkg/collectors/collector.go @@ -15,8 +15,8 @@ type Collector interface { GetPollCount() int // Returns the number of completed poll } -// A union of all values required to be passed into all constuctions -type CollectionConstuctor struct { +// A union of all values required to be passed into allconstructions +type CollectionConstructor struct { Callback callbacks.Callback Clientset *clients.Clientset PTPInterface string diff --git a/pkg/collectors/devices/fetcher.go b/pkg/collectors/devices/fetcher.go index 219e14e6..615794a3 100644 --- a/pkg/collectors/devices/fetcher.go +++ b/pkg/collectors/devices/fetcher.go @@ -65,7 +65,7 @@ func unmarshall(result map[string]string, pack interface{}) error { f.SetString(res) } default: - return fmt.Errorf("fetcher unmarshal not implmented for type: %s", field.Type.Name()) + return fmt.Errorf("fetcher unmarshal not implemented for type: %s", field.Type.Name()) } } } diff --git a/pkg/collectors/devices/ptp_devices.go b/pkg/collectors/devices/ptp_devices.go index 5ac8d2df..45e592d2 100644 --- a/pkg/collectors/devices/ptp_devices.go +++ b/pkg/collectors/devices/ptp_devices.go @@ -85,14 +85,14 @@ func BuildPTPDeviceInfo(interfaceName string) error { func GetPTPDeviceInfo(interfaceName string, ctx clients.ContainerContext) (PTPDeviceInfo, error) { devInfo := PTPDeviceInfo{} // Find the dev for the GNSS for this interface - fetcherInst, fetchedInstaceOk := devFetcher[interfaceName] - if !fetchedInstaceOk { + fetcherInst, fetchedInstanceOk := devFetcher[interfaceName] + if !fetchedInstanceOk { err := BuildPTPDeviceInfo(interfaceName) if err != nil { return devInfo, err } - fetcherInst, fetchedInstaceOk = devFetcher[interfaceName] - if !fetchedInstaceOk { + fetcherInst, fetchedInstanceOk = devFetcher[interfaceName] + if !fetchedInstanceOk { return devInfo, errors.New("failed to create fetcher for PTPDeviceInfo") } } @@ -149,14 +149,14 @@ func BuildDPLLInfoFetcher(interfaceName string) error { // GetDevDPLLInfo returns the device DPLL info for an interface. func GetDevDPLLInfo(ctx clients.ContainerContext, interfaceName string) (DevDPLLInfo, error) { dpllInfo := DevDPLLInfo{} - fetcherInst, fetchedInstaceOk := dpllFetcher[interfaceName] - if !fetchedInstaceOk { + fetcherInst, fetchedInstanceOk := dpllFetcher[interfaceName] + if !fetchedInstanceOk { err := BuildDPLLInfoFetcher(interfaceName) if err != nil { return dpllInfo, err } - fetcherInst, fetchedInstaceOk = dpllFetcher[interfaceName] - if !fetchedInstaceOk { + fetcherInst, fetchedInstanceOk = dpllFetcher[interfaceName] + if !fetchedInstanceOk { return dpllInfo, errors.New("failed to create fetcher for DPLLInfo") } } diff --git a/pkg/collectors/gps_ubx_collector.go b/pkg/collectors/gps_ubx_collector.go index 450f1b90..bb9fcdf7 100644 --- a/pkg/collectors/gps_ubx_collector.go +++ b/pkg/collectors/gps_ubx_collector.go @@ -95,21 +95,21 @@ func (gps *GPSCollector) GetPollCount() int { return int(atomic.LoadUint32(&gps.count)) } -// Returns a new PTPCollector from the CollectionConstuctor Factory +// Returns a new PTPCollector from the CollectionConstructor Factory // It will set the lastPoll one polling time in the past such that the initial // request to ShouldPoll should return True -func (constuctor *CollectionConstuctor) NewGPSCollector() (*GPSCollector, error) { - ctx, err := clients.NewContainerContext(constuctor.Clientset, PTPNamespace, PodNamePrefix, GPSContainer) +func (constructor *CollectionConstructor) NewGPSCollector() (*GPSCollector, error) { + ctx, err := clients.NewContainerContext(constructor.Clientset, PTPNamespace, PodNamePrefix, GPSContainer) if err != nil { return &GPSCollector{}, fmt.Errorf("could not create container context %w", err) } collector := GPSCollector{ - interfaceName: constuctor.PTPInterface, + interfaceName: constructor.PTPInterface, ctx: ctx, DataTypes: ubxCollectables, running: false, - callback: constuctor.Callback, + callback: constructor.Callback, } return &collector, nil diff --git a/pkg/collectors/ptp_collector.go b/pkg/collectors/ptp_collector.go index ff6b27cf..2fce90b0 100644 --- a/pkg/collectors/ptp_collector.go +++ b/pkg/collectors/ptp_collector.go @@ -150,27 +150,27 @@ func (ptpDev *PTPCollector) GetPollCount() int { return int(atomic.LoadUint32(&ptpDev.count)) } -// Returns a new PTPCollector from the CollectionConstuctor Factory +// Returns a new PTPCollector from the CollectionConstructor Factory // It will set the lastPoll one polling time in the past such that the initial // request to ShouldPoll should return True -func (constuctor *CollectionConstuctor) NewPTPCollector() (*PTPCollector, error) { - ctx, err := clients.NewContainerContext(constuctor.Clientset, PTPNamespace, PodNamePrefix, PTPContainer) +func (constructor *CollectionConstructor) NewPTPCollector() (*PTPCollector, error) { + ctx, err := clients.NewContainerContext(constructor.Clientset, PTPNamespace, PodNamePrefix, PTPContainer) if err != nil { return &PTPCollector{}, fmt.Errorf("could not create container context %w", err) } // Build DPPInfoFetcher ahead of time call to GetPTPDeviceInfo will build the other - err = devices.BuildPTPDeviceInfo(constuctor.PTPInterface) + err = devices.BuildPTPDeviceInfo(constructor.PTPInterface) if err != nil { return &PTPCollector{}, fmt.Errorf("failed to build fetcher for PTPDeviceInfo %w", err) } - err = devices.BuildDPLLInfoFetcher(constuctor.PTPInterface) + err = devices.BuildDPLLInfoFetcher(constructor.PTPInterface) if err != nil { return &PTPCollector{}, fmt.Errorf("failed to build fetcher for DPLLInfo %w", err) } - ptpDevInfo, err := devices.GetPTPDeviceInfo(constuctor.PTPInterface, ctx) + ptpDevInfo, err := devices.GetPTPDeviceInfo(constructor.PTPInterface, ctx) if err != nil { return &PTPCollector{}, fmt.Errorf("failed to fetch initial DeviceInfo %w", err) } @@ -179,11 +179,11 @@ func (constuctor *CollectionConstuctor) NewPTPCollector() (*PTPCollector, error) } collector := PTPCollector{ - interfaceName: constuctor.PTPInterface, + interfaceName: constructor.PTPInterface, ctx: ctx, DataTypes: ptpCollectables, running: make(map[string]bool), - callback: constuctor.Callback, + callback: constructor.Callback, } return &collector, nil diff --git a/pkg/runner/runner.go b/pkg/runner/runner.go index e3a4f7c6..511f9780 100644 --- a/pkg/runner/runner.go +++ b/pkg/runner/runner.go @@ -67,7 +67,7 @@ func NewCollectorRunner() *CollectorRunner { } } -// initialise will call the constuctor for each +// initialise will call theconstructor for each // value in collector name, it will panic if a collector name is not known. func (runner *CollectorRunner) initialise( callback callbacks.Callback, @@ -79,23 +79,23 @@ func (runner *CollectorRunner) initialise( runner.pollRate = pollRate runner.pollCount = pollCount - constuctor := collectors.CollectionConstuctor{ + constructor := collectors.CollectionConstructor{ Callback: callback, PTPInterface: ptpInterface, Clientset: clientset, PollRate: pollRate, } - for _, constuctorName := range runner.collectorNames { + for _, constructorName := range runner.collectorNames { var newCollector collectors.Collector - switch constuctorName { + switch constructorName { case collectors.PTPCollectorName: - NewPTPCollector, err := constuctor.NewPTPCollector() + NewPTPCollector, err := constructor.NewPTPCollector() utils.IfErrorPanic(err) newCollector = NewPTPCollector log.Debug("PTP Collector") case collectors.GPSCollectorName: - NewGPSCollector, err := constuctor.NewGPSCollector() + NewGPSCollector, err := constructor.NewGPSCollector() utils.IfErrorPanic(err) newCollector = NewGPSCollector log.Debug("PTP Collector") @@ -104,7 +104,7 @@ func (runner *CollectorRunner) initialise( panic("Unknown collector") } if newCollector != nil { - runner.collecterInstances[constuctorName] = &newCollector + runner.collecterInstances[constructorName] = &newCollector log.Debugf("Added collector %T, %v", newCollector, newCollector) } }