Skip to content

Commit

Permalink
PR fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jakeschuurmans committed Sep 25, 2024
1 parent 324f17a commit 3c72ce8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
22 changes: 10 additions & 12 deletions internal/bioscfg/bioscfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ var (
type BiosCfg struct {
cfg *config.Configuration
logger *logrus.Entry
ctx context.Context
fleetdb *fleetdb.Store
nc *ctrl.NatsController
}
Expand All @@ -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
}
Expand All @@ -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,
Expand All @@ -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
}
Expand All @@ -60,21 +58,21 @@ 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")
}

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,
Expand All @@ -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
Expand All @@ -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,
)
Expand Down
2 changes: 1 addition & 1 deletion internal/bioscfg/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
4 changes: 2 additions & 2 deletions internal/store/fleetdb/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3c72ce8

Please sign in to comment.