mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
refactor: deprecate login_before_ready in favor of startup_script_behavior (#7837)
Fixes #7758
This commit is contained in:
@@ -1092,6 +1092,7 @@ export interface WorkspaceAgent {
|
||||
readonly connection_timeout_seconds: number
|
||||
readonly troubleshooting_url: string
|
||||
readonly login_before_ready: boolean
|
||||
readonly startup_script_behavior: WorkspaceAgentStartupScriptBehavior
|
||||
readonly startup_script_timeout_seconds: number
|
||||
readonly shutdown_script?: string
|
||||
readonly shutdown_script_timeout_seconds: number
|
||||
@@ -1562,6 +1563,11 @@ export const WorkspaceAgentLifecycles: WorkspaceAgentLifecycle[] = [
|
||||
"starting",
|
||||
]
|
||||
|
||||
// From codersdk/workspaceagents.go
|
||||
export type WorkspaceAgentStartupScriptBehavior = "blocking" | "non-blocking"
|
||||
export const WorkspaceAgentStartupScriptBehaviors: WorkspaceAgentStartupScriptBehavior[] =
|
||||
["blocking", "non-blocking"]
|
||||
|
||||
// From codersdk/workspaceagents.go
|
||||
export type WorkspaceAgentStatus =
|
||||
| "connected"
|
||||
|
||||
@@ -252,44 +252,39 @@ const OffLifecycle: React.FC = () => {
|
||||
const ConnectedStatus: React.FC<{
|
||||
agent: WorkspaceAgent
|
||||
}> = ({ agent }) => {
|
||||
// NOTE(mafredri): Keep this behind feature flag for the time-being,
|
||||
// if login_before_ready is false, the user has updated to
|
||||
// terraform-provider-coder v0.6.10 and opted in to the functionality.
|
||||
//
|
||||
// Remove check once documentation is in place and we do a breaking
|
||||
// release indicating startup script behavior has changed.
|
||||
// https://github.com/coder/coder/issues/5749
|
||||
if (agent.login_before_ready) {
|
||||
return <ReadyLifecycle />
|
||||
switch (agent.startup_script_behavior) {
|
||||
case "non-blocking":
|
||||
return <ReadyLifecycle />
|
||||
case "blocking":
|
||||
return (
|
||||
<ChooseOne>
|
||||
<Cond condition={agent.lifecycle_state === "ready"}>
|
||||
<ReadyLifecycle />
|
||||
</Cond>
|
||||
<Cond condition={agent.lifecycle_state === "start_timeout"}>
|
||||
<StartTimeoutLifecycle agent={agent} />
|
||||
</Cond>
|
||||
<Cond condition={agent.lifecycle_state === "start_error"}>
|
||||
<StartErrorLifecycle agent={agent} />
|
||||
</Cond>
|
||||
<Cond condition={agent.lifecycle_state === "shutting_down"}>
|
||||
<ShuttingDownLifecycle />
|
||||
</Cond>
|
||||
<Cond condition={agent.lifecycle_state === "shutdown_timeout"}>
|
||||
<ShutdownTimeoutLifecycle agent={agent} />
|
||||
</Cond>
|
||||
<Cond condition={agent.lifecycle_state === "shutdown_error"}>
|
||||
<ShutdownErrorLifecycle agent={agent} />
|
||||
</Cond>
|
||||
<Cond condition={agent.lifecycle_state === "off"}>
|
||||
<OffLifecycle />
|
||||
</Cond>
|
||||
<Cond>
|
||||
<StartingLifecycle />
|
||||
</Cond>
|
||||
</ChooseOne>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<ChooseOne>
|
||||
<Cond condition={agent.lifecycle_state === "ready"}>
|
||||
<ReadyLifecycle />
|
||||
</Cond>
|
||||
<Cond condition={agent.lifecycle_state === "start_timeout"}>
|
||||
<StartTimeoutLifecycle agent={agent} />
|
||||
</Cond>
|
||||
<Cond condition={agent.lifecycle_state === "start_error"}>
|
||||
<StartErrorLifecycle agent={agent} />
|
||||
</Cond>
|
||||
<Cond condition={agent.lifecycle_state === "shutting_down"}>
|
||||
<ShuttingDownLifecycle />
|
||||
</Cond>
|
||||
<Cond condition={agent.lifecycle_state === "shutdown_timeout"}>
|
||||
<ShutdownTimeoutLifecycle agent={agent} />
|
||||
</Cond>
|
||||
<Cond condition={agent.lifecycle_state === "shutdown_error"}>
|
||||
<ShutdownErrorLifecycle agent={agent} />
|
||||
</Cond>
|
||||
<Cond condition={agent.lifecycle_state === "off"}>
|
||||
<OffLifecycle />
|
||||
</Cond>
|
||||
<Cond>
|
||||
<StartingLifecycle />
|
||||
</Cond>
|
||||
</ChooseOne>
|
||||
)
|
||||
}
|
||||
|
||||
const DisconnectedStatus: React.FC = () => {
|
||||
|
||||
@@ -498,7 +498,8 @@ export const MockWorkspaceAgent: TypesGen.WorkspaceAgent = {
|
||||
connection_timeout_seconds: 120,
|
||||
troubleshooting_url: "https://coder.com/troubleshoot",
|
||||
lifecycle_state: "starting",
|
||||
login_before_ready: false,
|
||||
login_before_ready: false, // Deprecated.
|
||||
startup_script_behavior: "blocking",
|
||||
startup_logs_length: 0,
|
||||
startup_logs_overflowed: false,
|
||||
startup_script_timeout_seconds: 120,
|
||||
|
||||
Reference in New Issue
Block a user