Skip to content

Commit 5b6f264

Browse files
committed
Rename LogSourceID -> SourceID
1 parent 7cf6f0c commit 5b6f264

File tree

13 files changed

+102
-80
lines changed

13 files changed

+102
-80
lines changed

coderd/apidoc/docs.go

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/workspaceagents.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2256,6 +2256,7 @@ func convertWorkspaceAgentLog(logEntry database.WorkspaceAgentLog) codersdk.Work
22562256
CreatedAt: logEntry.CreatedAt,
22572257
Output: logEntry.Output,
22582258
Level: codersdk.LogLevel(logEntry.Level),
2259+
SourceID: logEntry.LogSourceID,
22592260
}
22602261
}
22612262

codersdk/workspaceagents.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -765,11 +765,11 @@ const (
765765
)
766766

767767
type WorkspaceAgentLog struct {
768-
ID int64 `json:"id"`
769-
CreatedAt time.Time `json:"created_at" format:"date-time"`
770-
Output string `json:"output"`
771-
Level LogLevel `json:"level"`
772-
LogSourceID uuid.UUID `json:"log_source_id" format:"uuid"`
768+
ID int64 `json:"id"`
769+
CreatedAt time.Time `json:"created_at" format:"date-time"`
770+
Output string `json:"output"`
771+
Level LogLevel `json:"level"`
772+
SourceID uuid.UUID `json:"source_id" format:"uuid"`
773773
}
774774

775775
type AgentSubsystem string

docs/api/agents.md

Lines changed: 20 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/api/schemas.md

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

site/src/api/typesGenerated.ts

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

site/src/components/Logs/Logs.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const lines = MockWorkspaceBuildLogs.map((log) => ({
1414
time: log.created_at,
1515
output: log.output,
1616
level: "info" as LogLevel,
17+
source_id: log.log_source,
1718
}))
1819
export const Example = Template.bind({})
1920
Example.args = {

site/src/components/Logs/Logs.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export interface Line {
1111
time: string
1212
output: string
1313
level: LogLevel
14+
source_id: string
1415
}
1516

1617
export interface LogsProps {

site/src/components/Resources/AgentStatus.tsx

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -250,39 +250,34 @@ const OffLifecycle: React.FC = () => {
250250
const ConnectedStatus: React.FC<{
251251
agent: WorkspaceAgent
252252
}> = ({ agent }) => {
253-
switch (agent.startup_script_behavior) {
254-
case "non-blocking":
255-
return <ReadyLifecycle />
256-
case "blocking":
257-
return (
258-
<ChooseOne>
259-
<Cond condition={agent.lifecycle_state === "ready"}>
260-
<ReadyLifecycle />
261-
</Cond>
262-
<Cond condition={agent.lifecycle_state === "start_timeout"}>
263-
<StartTimeoutLifecycle agent={agent} />
264-
</Cond>
265-
<Cond condition={agent.lifecycle_state === "start_error"}>
266-
<StartErrorLifecycle agent={agent} />
267-
</Cond>
268-
<Cond condition={agent.lifecycle_state === "shutting_down"}>
269-
<ShuttingDownLifecycle />
270-
</Cond>
271-
<Cond condition={agent.lifecycle_state === "shutdown_timeout"}>
272-
<ShutdownTimeoutLifecycle agent={agent} />
273-
</Cond>
274-
<Cond condition={agent.lifecycle_state === "shutdown_error"}>
275-
<ShutdownErrorLifecycle agent={agent} />
276-
</Cond>
277-
<Cond condition={agent.lifecycle_state === "off"}>
278-
<OffLifecycle />
279-
</Cond>
280-
<Cond>
281-
<StartingLifecycle />
282-
</Cond>
283-
</ChooseOne>
284-
)
285-
}
253+
return (
254+
<ChooseOne>
255+
<Cond condition={agent.lifecycle_state === "ready"}>
256+
<ReadyLifecycle />
257+
</Cond>
258+
<Cond condition={agent.lifecycle_state === "start_timeout"}>
259+
<StartTimeoutLifecycle agent={agent} />
260+
</Cond>
261+
<Cond condition={agent.lifecycle_state === "start_error"}>
262+
<StartErrorLifecycle agent={agent} />
263+
</Cond>
264+
<Cond condition={agent.lifecycle_state === "shutting_down"}>
265+
<ShuttingDownLifecycle />
266+
</Cond>
267+
<Cond condition={agent.lifecycle_state === "shutdown_timeout"}>
268+
<ShutdownTimeoutLifecycle agent={agent} />
269+
</Cond>
270+
<Cond condition={agent.lifecycle_state === "shutdown_error"}>
271+
<ShutdownErrorLifecycle agent={agent} />
272+
</Cond>
273+
<Cond condition={agent.lifecycle_state === "off"}>
274+
<OffLifecycle />
275+
</Cond>
276+
<Cond>
277+
<StartingLifecycle />
278+
</Cond>
279+
</ChooseOne>
280+
)
286281
}
287282

288283
const DisconnectedStatus: React.FC = () => {

site/src/components/WorkspaceBuildLogs/WorkspaceBuildLogs.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ export const WorkspaceBuildLogs: FC<WorkspaceBuildLogsProps> = ({
7272
time: log.created_at,
7373
output: log.output,
7474
level: log.log_level,
75+
source_id: log.log_source,
7576
}))
7677
const duration = getStageDurationInSeconds(logs)
7778
const shouldDisplayDuration = duration !== undefined

site/src/testHelpers/entities.ts

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,25 @@ export const MockWorkspaceApp: TypesGen.WorkspaceApp = {
536536
},
537537
}
538538

539+
export const MockWorkspaceAgentLogSource: TypesGen.WorkspaceAgentLogSource = {
540+
created_at: "2023-05-04T11:30:41.402072Z",
541+
id: "dc790496-eaec-4f88-a53f-8ce1f61a1fff",
542+
display_name: "Startup Script",
543+
icon: "",
544+
workspace_agent_id: "",
545+
};
546+
547+
export const MockWorkspaceAgentScript: TypesGen.WorkspaceAgentScript = {
548+
log_source_id: MockWorkspaceAgentLogSource.id,
549+
cron: "",
550+
log_path: "",
551+
run_on_start: true,
552+
run_on_stop: false,
553+
source: "echo 'hello world'",
554+
start_blocks_login: false,
555+
timeout_seconds: 0,
556+
};
557+
539558
export const MockWorkspaceAgent: TypesGen.WorkspaceAgent = {
540559
apps: [MockWorkspaceApp],
541560
architecture: "amd64",
@@ -557,12 +576,10 @@ export const MockWorkspaceAgent: TypesGen.WorkspaceAgent = {
557576
connection_timeout_seconds: 120,
558577
troubleshooting_url: "https://coder.com/troubleshoot",
559578
lifecycle_state: "starting",
560-
login_before_ready: false, // Deprecated.
561-
startup_script_behavior: "blocking",
562579
logs_length: 0,
563580
logs_overflowed: false,
564-
startup_script_timeout_seconds: 120,
565-
shutdown_script_timeout_seconds: 120,
581+
log_sources: [MockWorkspaceAgentLogSource],
582+
scripts: [MockWorkspaceAgentScript],
566583
subsystems: ["envbox", "exectrace"],
567584
health: {
568585
healthy: true,
@@ -2131,25 +2148,29 @@ export const MockWorkspaceAgentLogs: TypesGen.WorkspaceAgentLog[] = [
21312148
created_at: "2023-05-04T11:30:41.402072Z",
21322149
output: "+ curl -fsSL https://code-server.dev/install.sh",
21332150
level: "info",
2151+
source_id: MockWorkspaceAgentLogSource.id,
21342152
},
21352153
{
21362154
id: 166664,
21372155
created_at: "2023-05-04T11:30:41.40228Z",
21382156
output:
21392157
"+ sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.8.3",
21402158
level: "info",
2159+
source_id: MockWorkspaceAgentLogSource.id,
21412160
},
21422161
{
21432162
id: 166665,
21442163
created_at: "2023-05-04T11:30:42.590731Z",
21452164
output: "Ubuntu 22.04.2 LTS",
21462165
level: "info",
2166+
source_id: MockWorkspaceAgentLogSource.id,
21472167
},
21482168
{
21492169
id: 166666,
21502170
created_at: "2023-05-04T11:30:42.593686Z",
21512171
output: "Installing v4.8.3 of the amd64 release from GitHub.",
21522172
level: "info",
2173+
source_id: MockWorkspaceAgentLogSource.id,
21532174
},
21542175
]
21552176

site/src/xServices/workspaceAgentLogs/workspaceAgentLogsXService.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export const workspaceAgentLogsMachine = createMachine(
8181
level: log.level || "info",
8282
output: log.output,
8383
time: log.created_at,
84+
source_id: log.source_id,
8485
})),
8586
),
8687
streamLogs: (ctx) => async (callback) => {
@@ -99,6 +100,7 @@ export const workspaceAgentLogsMachine = createMachine(
99100
level: log.level || "info",
100101
output: log.output,
101102
time: log.created_at,
103+
source_id: log.source_id,
102104
})),
103105
})
104106
},

0 commit comments

Comments
 (0)