fix: implement repository pkg
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@ -10,7 +9,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/volker-raschek/flucky/pkg/internal/format"
|
||||
"github.com/volker-raschek/flucky/pkg/storage"
|
||||
|
||||
uuid "github.com/satori/go.uuid"
|
||||
"github.com/volker-raschek/flucky/pkg/types"
|
||||
@ -159,12 +157,7 @@ func (cnf *Config) GetSensorByID(id string) *types.Sensor {
|
||||
// RemoveSensor deletes a sensor by its name or its unique UUID, If definitive
|
||||
// is set to true, the sensor will not only be removed in the configuration file
|
||||
// but also in the backend.
|
||||
func (cnf *Config) RemoveSensor(name string, definitive bool) error {
|
||||
|
||||
backend, err := storage.New(cnf.StorageEndpoint, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
func (cnf *Config) RemoveSensor(name string) error {
|
||||
|
||||
for i, sensor := range cnf.Sensors {
|
||||
// remove machted name
|
||||
@ -172,13 +165,6 @@ func (cnf *Config) RemoveSensor(name string, definitive bool) error {
|
||||
sensor.Name == name {
|
||||
cnf.Sensors = append(cnf.Sensors[:i], cnf.Sensors[i+1:]...)
|
||||
|
||||
if definitive {
|
||||
err = backend.RemoveSensorByName(context.Background(), name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
// remove machted uuid
|
||||
@ -186,13 +172,6 @@ func (cnf *Config) RemoveSensor(name string, definitive bool) error {
|
||||
sensor.ID == name {
|
||||
cnf.Sensors = append(cnf.Sensors[:i], cnf.Sensors[i+1:]...)
|
||||
|
||||
if definitive {
|
||||
err = backend.RemoveSensorByID(context.Background(), name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user