@@ -1158,20 +1158,8 @@ func (a *agent) handleManifest(manifestOK *checkpoint) func(ctx context.Context,
1158
1158
}
1159
1159
}
1160
1160
1161
- var (
1162
- scripts = manifest .Scripts
1163
- scriptRunnerOpts []agentscripts.InitOption
1164
- devcontainerScripts map [uuid.UUID ]codersdk.WorkspaceAgentScript
1165
- )
1166
- if a .devcontainers {
1167
- a .containerAPI .Init (
1168
- agentcontainers .WithManifestInfo (manifest .OwnerName , manifest .WorkspaceName , manifest .AgentName ),
1169
- agentcontainers .WithDevcontainers (manifest .Devcontainers , scripts ),
1170
- agentcontainers .WithSubAgentClient (agentcontainers .NewSubAgentClientFromAPI (a .logger , aAPI )),
1171
- )
1172
-
1173
- scripts , devcontainerScripts = agentcontainers .ExtractDevcontainerScripts (manifest .Devcontainers , scripts )
1174
- }
1161
+ var scriptRunnerOpts []agentscripts.InitOption
1162
+ scripts , devcontainerScripts := agentcontainers .ExtractDevcontainerScripts (manifest .Devcontainers , manifest .Scripts )
1175
1163
err = a .scriptRunner .Init (scripts , aAPI .ScriptCompleted , scriptRunnerOpts ... )
1176
1164
if err != nil {
1177
1165
return xerrors .Errorf ("init script runner: %w" , err )
@@ -1190,9 +1178,17 @@ func (a *agent) handleManifest(manifestOK *checkpoint) func(ctx context.Context,
1190
1178
// autostarted devcontainer will be included in this time.
1191
1179
err := a .scriptRunner .Execute (a .gracefulCtx , agentscripts .ExecuteStartScripts )
1192
1180
1193
- for _ , dc := range manifest .Devcontainers {
1194
- cErr := a .createDevcontainer (ctx , aAPI , dc , devcontainerScripts [dc .ID ])
1195
- err = errors .Join (err , cErr )
1181
+ if a .containerAPI != nil {
1182
+ a .containerAPI .Init (
1183
+ agentcontainers .WithManifestInfo (manifest .OwnerName , manifest .WorkspaceName , manifest .AgentName ),
1184
+ agentcontainers .WithDevcontainers (manifest .Devcontainers , scripts ),
1185
+ agentcontainers .WithSubAgentClient (agentcontainers .NewSubAgentClientFromAPI (a .logger , aAPI )),
1186
+ )
1187
+
1188
+ for _ , dc := range manifest .Devcontainers {
1189
+ cErr := a .createDevcontainer (ctx , aAPI , dc , devcontainerScripts [dc .ID ])
1190
+ err = errors .Join (err , cErr )
1191
+ }
1196
1192
}
1197
1193
1198
1194
dur := time .Since (start ).Seconds ()
0 commit comments