Skip to content

Commit

Permalink
feat: support falling back when the image cannot be found
Browse files Browse the repository at this point in the history
  • Loading branch information
kylecarbs committed Jul 4, 2023
1 parent 2828dea commit 952ca7c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion envbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,13 +393,17 @@ func Run(ctx context.Context, options Options) error {
case strings.Contains(err.Error(), "error building stage"):
fallback = true
fallbackErr = err
// This occurs when the image cannot be found!
case strings.Contains(err.Error(), "authentication required"):
fallback = true
fallbackErr = err
case strings.Contains(err.Error(), "unexpected status code 401 Unauthorized"):
logf(codersdk.LogLevelError, "Unable to pull the provided image. Ensure your registry credentials are correct!")
}
if !fallback {
return err
}
logf(codersdk.LogLevelError, "Failed to build with the provided context: %s", err)
logf(codersdk.LogLevelError, "Failed to build: %s", err)
logf(codersdk.LogLevelError, "Falling back to the default image...")
err = defaultBuildParams()
if err != nil {
Expand Down

0 comments on commit 952ca7c

Please sign in to comment.