mirror of
https://github.com/coder/coder.git
synced 2025-07-13 21:36:50 +00:00
fix(codersdk): handle API older than client for startup script behavior (#7933)
This commit is contained in:
committed by
GitHub
parent
30a635aa5f
commit
e4744686ec
@ -1126,7 +1126,7 @@ func convertWorkspaceAgent(derpMap *tailcfg.DERPMap, coordinator tailnet.Coordin
|
|||||||
ConnectionTimeoutSeconds: dbAgent.ConnectionTimeoutSeconds,
|
ConnectionTimeoutSeconds: dbAgent.ConnectionTimeoutSeconds,
|
||||||
TroubleshootingURL: troubleshootingURL,
|
TroubleshootingURL: troubleshootingURL,
|
||||||
LifecycleState: codersdk.WorkspaceAgentLifecycle(dbAgent.LifecycleState),
|
LifecycleState: codersdk.WorkspaceAgentLifecycle(dbAgent.LifecycleState),
|
||||||
LoginBeforeReady: dbAgent.StartupScriptBehavior == database.StartupScriptBehaviorNonBlocking,
|
LoginBeforeReady: dbAgent.StartupScriptBehavior != database.StartupScriptBehaviorBlocking,
|
||||||
StartupScriptBehavior: codersdk.WorkspaceAgentStartupScriptBehavior(dbAgent.StartupScriptBehavior),
|
StartupScriptBehavior: codersdk.WorkspaceAgentStartupScriptBehavior(dbAgent.StartupScriptBehavior),
|
||||||
StartupScriptTimeoutSeconds: dbAgent.StartupScriptTimeoutSeconds,
|
StartupScriptTimeoutSeconds: dbAgent.StartupScriptTimeoutSeconds,
|
||||||
ShutdownScript: dbAgent.ShutdownScript.String,
|
ShutdownScript: dbAgent.ShutdownScript.String,
|
||||||
|
@ -375,7 +375,18 @@ func (c *Client) WorkspaceAgent(ctx context.Context, id uuid.UUID) (WorkspaceAge
|
|||||||
return WorkspaceAgent{}, ReadBodyAsError(res)
|
return WorkspaceAgent{}, ReadBodyAsError(res)
|
||||||
}
|
}
|
||||||
var workspaceAgent WorkspaceAgent
|
var workspaceAgent WorkspaceAgent
|
||||||
return workspaceAgent, json.NewDecoder(res.Body).Decode(&workspaceAgent)
|
err = json.NewDecoder(res.Body).Decode(&workspaceAgent)
|
||||||
|
if err != nil {
|
||||||
|
return WorkspaceAgent{}, err
|
||||||
|
}
|
||||||
|
// Backwards compatibility for cases where the API is older then the client.
|
||||||
|
if workspaceAgent.StartupScriptBehavior == "" {
|
||||||
|
workspaceAgent.StartupScriptBehavior = WorkspaceAgentStartupScriptBehaviorNonBlocking
|
||||||
|
if !workspaceAgent.LoginBeforeReady {
|
||||||
|
workspaceAgent.StartupScriptBehavior = WorkspaceAgentStartupScriptBehaviorBlocking
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return workspaceAgent, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type IssueReconnectingPTYSignedTokenRequest struct {
|
type IssueReconnectingPTYSignedTokenRequest struct {
|
||||||
|
Reference in New Issue
Block a user