Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use a different, less segfault-y path to pass configuration
Browse files Browse the repository at this point in the history
Signed-off-by: James Lamb <[email protected]>
jameslamb committed Jul 31, 2024

Verified

This commit was signed with the committer’s verified signature.
jameslamb James Lamb
1 parent be22c62 commit bc8f4e6
Showing 2 changed files with 30 additions and 23 deletions.
30 changes: 16 additions & 14 deletions internal/validator/tui.go
Original file line number Diff line number Diff line change
@@ -28,19 +28,20 @@ import (
)

type model struct {
sub chan checkResult
container container.ContainerInterface
containerStarted bool
results []checkResult
allChecksPassed bool
spinner spinner.Model
progress progress.Model
debug bool
image string
validator *canaryv1.Validator
configPath string
err error
tty bool
sub chan checkResult
container container.ContainerInterface
containerStarted bool
containerStartupTimeout int
results []checkResult
allChecksPassed bool
spinner spinner.Model
progress progress.Model
debug bool
image string
validator *canaryv1.Validator
configPath string
err error
tty bool
}

func (m model) Init() tea.Cmd {
@@ -133,7 +134,8 @@ func handleConfigLoaded(m model, msg configLoaded) (model, tea.Cmd) {
if !m.tty {
commands = append(commands, tea.Printf("Starting container"))
}
commands = append(commands, startContainer(m.image, m.validator, m.container.GetStartupTimeout()))
// right here... m.container isn't set yet
commands = append(commands, startContainer(m.image, m.validator, m.containerStartupTimeout))
return m, tea.Batch(commands...)
}

23 changes: 14 additions & 9 deletions internal/validator/validator.go
Original file line number Diff line number Diff line change
@@ -69,16 +69,21 @@ func Validate(image string, configPath string, cmd *cobra.Command, debug bool) (
tty = bufio.NewReader(os.Stdin)
isTty = false
}
startupTimeout, err := cmd.Flags().GetInt("startup-timeout")
if err != nil {
return false, err
}
m := model{
sub: make(chan checkResult),
configPath: configPath,
containerStarted: false,
spinner: spinner.New(),
progress: progress.New(progress.WithSolidFill("#f2e63a")),
allChecksPassed: true,
debug: debug,
image: image,
tty: isTty,
sub: make(chan checkResult),
configPath: configPath,
containerStarted: false,
containerStartupTimeout: startupTimeout,
spinner: spinner.New(),
progress: progress.New(progress.WithSolidFill("#f2e63a")),
allChecksPassed: true,
debug: debug,
image: image,
tty: isTty,
}
p := tea.NewProgram(m, tea.WithInput(tty), tea.WithOutput(cmd.OutOrStderr()))
out, err := p.Run()

0 comments on commit bc8f4e6

Please sign in to comment.