Skip to content

Commit

Permalink
fix: Do not run empty process lists (#691)
Browse files Browse the repository at this point in the history
Reviewed-by: Jakub Ciolek <[email protected]>
Approved-by: Jakub Ciolek <[email protected]>
  • Loading branch information
jake-ciolek authored Aug 25, 2023
2 parents c8d847c + c712f5a commit f6ae3a5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cmd/kraft/pkg/pkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,19 @@ func (opts *Pkg) Run(cmd *cobra.Command, args []string) error {
}
}

if len(tree) == 0 {
switch true {
case len(opts.Target) > 0:
return fmt.Errorf("no matching targets found for: %s", opts.Target)
case len(opts.Architecture) > 0 && len(opts.Platform) == 0:
return fmt.Errorf("no matching targets found for architecture: %s", opts.Architecture)
case len(opts.Architecture) == 0 && len(opts.Platform) > 0:
return fmt.Errorf("no matching targets found for platform: %s", opts.Platform)
default:
return fmt.Errorf("no matching targets found for: %s/%s", opts.Platform, opts.Architecture)
}
}

model, err := processtree.NewProcessTree(
ctx,
[]processtree.ProcessTreeOption{
Expand Down
5 changes: 5 additions & 0 deletions tui/processtree/processtree.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package processtree

import (
"context"
"fmt"
"os"
"strings"
"time"
Expand Down Expand Up @@ -77,6 +78,10 @@ type ProcessTree struct {
}

func NewProcessTree(ctx context.Context, opts []ProcessTreeOption, tree ...*ProcessTreeItem) (*ProcessTree, error) {
if len(tree) == 0 {
return nil, fmt.Errorf("cannot instantiate process tree without sub processes")
}

pt := &ProcessTree{
tree: tree,
ctx: ctx,
Expand Down

0 comments on commit f6ae3a5

Please sign in to comment.