fix(codersdk): handle API older than client for startup script behavior (#7933)

This commit is contained in:
Mathias Fredriksson
2023-06-09 16:01:56 +03:00
committed by GitHub
parent 30a635aa5f
commit e4744686ec
2 changed files with 13 additions and 2 deletions

View File

@ -375,7 +375,18 @@ func (c *Client) WorkspaceAgent(ctx context.Context, id uuid.UUID) (WorkspaceAge
return WorkspaceAgent{}, ReadBodyAsError(res)
}
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 {