mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
fix(cli/ssh): retry on autostart conflict (#16058)
This commit is contained in:
committed by
GitHub
parent
53d9c7ebe4
commit
ba6e84dec3
@ -33,6 +33,7 @@ import (
|
||||
|
||||
"cloud.google.com/go/compute/metadata"
|
||||
"github.com/fullsailor/pkcs7"
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/golang-jwt/jwt/v4"
|
||||
"github.com/google/uuid"
|
||||
"github.com/moby/moby/pkg/namesgenerator"
|
||||
@ -146,6 +147,11 @@ type Options struct {
|
||||
Database database.Store
|
||||
Pubsub pubsub.Pubsub
|
||||
|
||||
// APIMiddleware inserts middleware before api.RootHandler, this can be
|
||||
// useful in certain tests where you want to intercept requests before
|
||||
// passing them on to the API, e.g. for synchronization of execution.
|
||||
APIMiddleware func(http.Handler) http.Handler
|
||||
|
||||
ConfigSSH codersdk.SSHConfigResponse
|
||||
|
||||
SwaggerEndpoint bool
|
||||
@ -555,7 +561,14 @@ func NewWithAPI(t testing.TB, options *Options) (*codersdk.Client, io.Closer, *c
|
||||
setHandler, cancelFunc, serverURL, newOptions := NewOptions(t, options)
|
||||
// We set the handler after server creation for the access URL.
|
||||
coderAPI := coderd.New(newOptions)
|
||||
setHandler(coderAPI.RootHandler)
|
||||
rootHandler := coderAPI.RootHandler
|
||||
if options.APIMiddleware != nil {
|
||||
r := chi.NewRouter()
|
||||
r.Use(options.APIMiddleware)
|
||||
r.Mount("/", rootHandler)
|
||||
rootHandler = r
|
||||
}
|
||||
setHandler(rootHandler)
|
||||
var provisionerCloser io.Closer = nopcloser{}
|
||||
if options.IncludeProvisionerDaemon {
|
||||
provisionerCloser = NewTaggedProvisionerDaemon(t, coderAPI, "test", options.ProvisionerDaemonTags)
|
||||
|
Reference in New Issue
Block a user