@@ -37,7 +37,6 @@ func (a *agent) apiHandler() (http.Handler, func() error) {
3737 cacheDuration : cacheDuration ,
3838 }
3939
40- var containerAPI * agentcontainers.API
4140 if a .experimentalDevcontainersEnabled {
4241 containerAPIOpts := []agentcontainers.Option {
4342 agentcontainers .WithExecer (a .execer ),
@@ -53,9 +52,8 @@ func (a *agent) apiHandler() (http.Handler, func() error) {
5352 // Append after to allow the agent options to override the default options.
5453 containerAPIOpts = append (containerAPIOpts , a .containerAPIOptions ... )
5554
56- containerAPI = agentcontainers .NewAPI (a .logger .Named ("containers" ), containerAPIOpts ... )
57-
58- r .Mount ("/api/v0/containers" , containerAPI .Routes ())
55+ a .containerAPI = agentcontainers .NewAPI (a .logger .Named ("containers" ), containerAPIOpts ... )
56+ r .Mount ("/api/v0/containers" , a .containerAPI .Routes ())
5957 } else {
6058 r .HandleFunc ("/api/v0/containers" , func (w http.ResponseWriter , r * http.Request ) {
6159 httpapi .Write (r .Context (), w , http .StatusNotFound , codersdk.Response {
@@ -77,8 +75,8 @@ func (a *agent) apiHandler() (http.Handler, func() error) {
7775 r .Get ("/debug/prometheus" , promHandler .ServeHTTP )
7876
7977 return r , func () error {
80- if containerAPI != nil {
81- return containerAPI .Close ()
78+ if a . containerAPI != nil {
79+ return a . containerAPI .Close ()
8280 }
8381 return nil
8482 }
0 commit comments