Skip to content

Commit

Permalink
Add ability for runners to ignore async runtimes.
Browse files Browse the repository at this point in the history
This is needed for `state refresh` and `state shell`.
  • Loading branch information
mitchell-as committed Sep 17, 2024
1 parent 56a1cb4 commit a9c1c8d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
9 changes: 8 additions & 1 deletion internal/runbits/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ type Opts struct {
Archive *checkout.Archive

ValidateBuildscript bool
IgnoreAsync bool
}

type SetOpt func(*Opts)
Expand Down Expand Up @@ -91,6 +92,12 @@ func WithArchive(archive *checkout.Archive) SetOpt {
}
}

func WithIgnoreAsync() SetOpt {
return func(opts *Opts) {
opts.IgnoreAsync = true
}
}

type primeable interface {
primer.Projecter
primer.Auther
Expand Down Expand Up @@ -216,7 +223,7 @@ func Update(

// Async runtimes should still do everything up to the actual update itself, because we still want to raise
// any errors regarding solves, buildscripts, etc.
if prime.Config().GetBool(constants.AsyncRuntimeConfig) {
if prime.Config().GetBool(constants.AsyncRuntimeConfig) && !opts.IgnoreAsync {
logging.Debug("Skipping runtime update due to async runtime")
return rt, nil
}
Expand Down
2 changes: 1 addition & 1 deletion internal/runners/refresh/refresh.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (r *Refresh) Run(params *Params) error {
return locale.NewInputError("refresh_runtime_uptodate")
}

rti, err := runtime_runbit.Update(r.prime, trigger.TriggerRefresh, runtime_runbit.WithoutHeaders())
rti, err := runtime_runbit.Update(r.prime, trigger.TriggerRefresh, runtime_runbit.WithoutHeaders(), runtime_runbit.WithIgnoreAsync())
if err != nil {
return locale.WrapError(err, "err_refresh_runtime_new", "Could not update runtime for this project.")
}
Expand Down
2 changes: 1 addition & 1 deletion internal/runners/shell/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (u *Shell) Run(params *Params) error {
return locale.NewInputError("err_shell_commit_id_mismatch")
}

rti, err := runtime_runbit.Update(u.prime, trigger.TriggerShell, runtime_runbit.WithoutHeaders())
rti, err := runtime_runbit.Update(u.prime, trigger.TriggerShell, runtime_runbit.WithoutHeaders(), runtime_runbit.WithIgnoreAsync())
if err != nil {
return locale.WrapExternalError(err, "err_shell_runtime_new", "Could not start a shell/prompt for this project.")
}
Expand Down

0 comments on commit a9c1c8d

Please sign in to comment.