From a9c1c8d57bdf8674a52414a32858634840589c00 Mon Sep 17 00:00:00 2001 From: mitchell Date: Tue, 17 Sep 2024 14:52:40 -0400 Subject: [PATCH] Add ability for runners to ignore async runtimes. This is needed for `state refresh` and `state shell`. --- internal/runbits/runtime/runtime.go | 9 ++++++++- internal/runners/refresh/refresh.go | 2 +- internal/runners/shell/shell.go | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/internal/runbits/runtime/runtime.go b/internal/runbits/runtime/runtime.go index 0f820c4ebd..a872b8bd47 100644 --- a/internal/runbits/runtime/runtime.go +++ b/internal/runbits/runtime/runtime.go @@ -49,6 +49,7 @@ type Opts struct { Archive *checkout.Archive ValidateBuildscript bool + IgnoreAsync bool } type SetOpt func(*Opts) @@ -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 @@ -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 } diff --git a/internal/runners/refresh/refresh.go b/internal/runners/refresh/refresh.go index df8ac00ffb..683801c09c 100644 --- a/internal/runners/refresh/refresh.go +++ b/internal/runners/refresh/refresh.go @@ -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.") } diff --git a/internal/runners/shell/shell.go b/internal/runners/shell/shell.go index 43cc179806..3c469ddb8d 100644 --- a/internal/runners/shell/shell.go +++ b/internal/runners/shell/shell.go @@ -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.") }