Skip to content

Commit

Permalink
Fix spellings and typos
Browse files Browse the repository at this point in the history
  • Loading branch information
nocturnalastro committed Jun 21, 2023
1 parent 7155e3f commit 562611a
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 37 deletions.
12 changes: 6 additions & 6 deletions doc/implementing_a_collector.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 {
...
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pkg/collectors/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/collectors/devices/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions pkg/collectors/devices/ptp_devices.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
Expand Down Expand Up @@ -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")
}
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/collectors/gps_ubx_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions pkg/collectors/ptp_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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
Expand Down
14 changes: 7 additions & 7 deletions pkg/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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")
Expand All @@ -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)
}
}
Expand Down

0 comments on commit 562611a

Please sign in to comment.