diff --git a/Dockerfile b/Dockerfile index db3b617..cd75cbd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM alpine:latest -ENTRYPOINT ["/usr/sbin/bioscfg"] - COPY bioscfg /usr/sbin/bioscfg RUN chmod +x /usr/sbin/bioscfg + +ENTRYPOINT ["/usr/sbin/bioscfg"] \ No newline at end of file diff --git a/internal/bioscfg/bioscfg.go b/internal/bioscfg/bioscfg.go index 15ede94..50a1d9a 100644 --- a/internal/bioscfg/bioscfg.go +++ b/internal/bioscfg/bioscfg.go @@ -19,7 +19,6 @@ var ( type BiosCfg struct { cfg *config.Configuration logger *logrus.Entry - ctx context.Context fleetdb *fleetdb.Store nc *ctrl.NatsController } @@ -29,10 +28,9 @@ func New(ctx context.Context, cfg *config.Configuration, logger *logrus.Entry) ( bc := &BiosCfg{ cfg: cfg, logger: logger, - ctx: ctx, } - err := bc.initDependences() + err := bc.initDependences(ctx) if err != nil { return nil, err } @@ -41,7 +39,7 @@ func New(ctx context.Context, cfg *config.Configuration, logger *logrus.Entry) ( } // Listen listen to Nats for tasks -func (bc *BiosCfg) Listen() error { +func (bc *BiosCfg) Listen(ctx context.Context) error { handleFactory := func() ctrl.TaskHandler { return &TaskHandler{ cfg: bc.cfg, @@ -51,7 +49,7 @@ func (bc *BiosCfg) Listen() error { } } - err := bc.nc.ListenEvents(bc.ctx, handleFactory) + err := bc.nc.ListenEvents(ctx, handleFactory) if err != nil { return err } @@ -60,13 +58,13 @@ func (bc *BiosCfg) Listen() error { } // initDependences Initialize network dependencies -func (bc *BiosCfg) initDependences() error { - err := bc.initNats() +func (bc *BiosCfg) initDependences(ctx context.Context) error { + err := bc.initNats(ctx) if err != nil { return errors.Wrap(err, "failed to initialize connection to nats") } - err = bc.initFleetDB() + err = bc.initFleetDB(ctx) if err != nil { return errors.Wrap(err, "failed to initialize connection to fleetdb") } @@ -74,7 +72,7 @@ func (bc *BiosCfg) initDependences() error { return nil } -func (bc *BiosCfg) initNats() error { +func (bc *BiosCfg) initNats(ctx context.Context) error { bc.nc = ctrl.NewNatsController( string(rctypes.BiosControl), bc.cfg.FacilityCode, @@ -88,7 +86,7 @@ func (bc *BiosCfg) initNats() error { ctrl.WithConnectionTimeout(bc.cfg.Endpoints.Nats.ConnectTimeout), ) - err := bc.nc.Connect(bc.ctx) + err := bc.nc.Connect(ctx) if err != nil { bc.logger.Error(err) return err @@ -97,9 +95,9 @@ func (bc *BiosCfg) initNats() error { return nil } -func (bc *BiosCfg) initFleetDB() error { +func (bc *BiosCfg) initFleetDB(ctx context.Context) error { store, err := fleetdb.New( - bc.ctx, + ctx, &bc.cfg.Endpoints.FleetDB, bc.logger.Logger, ) diff --git a/internal/bioscfg/run.go b/internal/bioscfg/run.go index 79ad1af..5b8d19a 100644 --- a/internal/bioscfg/run.go +++ b/internal/bioscfg/run.go @@ -48,5 +48,5 @@ func Run(ctx context.Context, configFile, logLevel string, enableProfiling bool) loggerEntry.Infof("Success! %s is starting to listen for conditions", model.Name) - return controller.Listen() + return controller.Listen(ctx) } diff --git a/internal/store/fleetdb/client.go b/internal/store/fleetdb/client.go index 3e15ffd..731e1a0 100644 --- a/internal/store/fleetdb/client.go +++ b/internal/store/fleetdb/client.go @@ -85,8 +85,8 @@ func newFleetDBClientWithOAuthOtel(ctx context.Context, cfg *Config, logger *log return nil, err } - // clientID defaults to 'flipflop' - clientID := "flipflop" + // clientID defaults to 'bioscfg' + clientID := "bioscfg" if cfg.OidcClientID != "" { clientID = cfg.OidcClientID