Skip to content

Commit

Permalink
fix: fail on target-init error
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Kotzbauer <[email protected]>
  • Loading branch information
ckotzbauer committed Oct 1, 2022
1 parent 9363729 commit 2601fea
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 8 deletions.
6 changes: 5 additions & 1 deletion internal/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ func (c *CronService) runBackgroundService() {

if !processor.HasJobImage() {
for _, t := range c.processor.Targets {
t.Initialize()
err := t.Initialize()
if err != nil {
logrus.Fatalf("Target could not be initialized: %w", err)
}

t.LoadImages()
}
}
Expand Down
5 changes: 4 additions & 1 deletion internal/processor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,10 @@ func (p *Processor) runInformerAsync(informer cache.SharedIndexInformer) {
go func() {
if !HasJobImage() {
for _, t := range p.Targets {
t.Initialize()
err := t.Initialize()
if err != nil {
logrus.Fatalf("Target could not be initialized: %w", err)
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion internal/target/configmap/configmap_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ func (g *ConfigMapTarget) ValidateConfig() error {
return nil
}

func (g *ConfigMapTarget) Initialize() {
func (g *ConfigMapTarget) Initialize() error {
return nil
}

func (g *ConfigMapTarget) ProcessSbom(ctx *target.TargetContext) error {
Expand Down
3 changes: 2 additions & 1 deletion internal/target/dtrack/dtrack_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ func (g *DependencyTrackTarget) ValidateConfig() error {
return nil
}

func (g *DependencyTrackTarget) Initialize() {
func (g *DependencyTrackTarget) Initialize() error {
return nil
}

func (g *DependencyTrackTarget) ProcessSbom(ctx *target.TargetContext) error {
Expand Down
4 changes: 2 additions & 2 deletions internal/target/git/git_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ func (g *GitTarget) ValidateConfig() error {
return nil
}

func (g *GitTarget) Initialize() {
g.gitAccount.PrepareRepository(g.repository, g.workingTree, g.branch)
func (g *GitTarget) Initialize() error {
return g.gitAccount.PrepareRepository(g.repository, g.workingTree, g.branch)
}

func (g *GitTarget) ProcessSbom(ctx *target.TargetContext) error {
Expand Down
3 changes: 2 additions & 1 deletion internal/target/oci/oci_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ func (g *OciTarget) ValidateConfig() error {
return nil
}

func (g *OciTarget) Initialize() {
func (g *OciTarget) Initialize() error {
return nil
}

func (g *OciTarget) ProcessSbom(ctx *target.TargetContext) error {
Expand Down
2 changes: 1 addition & 1 deletion internal/target/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type TargetContext struct {
}

type Target interface {
Initialize()
Initialize() error
ValidateConfig() error
ProcessSbom(ctx *TargetContext) error
LoadImages() []*oci.RegistryImage
Expand Down

0 comments on commit 2601fea

Please sign in to comment.