| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package swarming | 5 package swarming |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "bytes" | 8 "bytes" |
| 9 "encoding/json" | 9 "encoding/json" |
| 10 "fmt" | 10 "fmt" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 // TaskBotDied means task started but bot died. | 42 // TaskBotDied means task started but bot died. |
| 43 TaskBotDied = "BOT_DIED" | 43 TaskBotDied = "BOT_DIED" |
| 44 // TaskCanceled means the task was canceled. See CompletedTs to determin
e whether it was started. | 44 // TaskCanceled means the task was canceled. See CompletedTs to determin
e whether it was started. |
| 45 TaskCanceled = "CANCELED" | 45 TaskCanceled = "CANCELED" |
| 46 // TaskCompleted means task is complete. | 46 // TaskCompleted means task is complete. |
| 47 TaskCompleted = "COMPLETED" | 47 TaskCompleted = "COMPLETED" |
| 48 ) | 48 ) |
| 49 | 49 |
| 50 func getSwarmingClient(c context.Context, server string) (*swarming.Service, err
or) { | 50 func getSwarmingClient(c context.Context, server string) (*swarming.Service, err
or) { |
| 51 c, _ = context.WithTimeout(c, 60*time.Second) | 51 c, _ = context.WithTimeout(c, 60*time.Second) |
| 52 » client := transport.GetClient(client.UseServiceAccountTransport( | 52 » client := transport.GetClient(client.UseServiceAccountTransport(c, nil,
nil)) |
| 53 » » c, []string{"https://www.googleapis.com/auth/userinfo.email"}, n
il)) | |
| 54 sc, err := swarming.New(client) | 53 sc, err := swarming.New(client) |
| 55 if err != nil { | 54 if err != nil { |
| 56 return nil, err | 55 return nil, err |
| 57 } | 56 } |
| 58 sc.BasePath = fmt.Sprintf("https://%s/_ah/api/swarming/v1/", server) | 57 sc.BasePath = fmt.Sprintf("https://%s/_ah/api/swarming/v1/", server) |
| 59 return sc, nil | 58 return sc, nil |
| 60 } | 59 } |
| 61 | 60 |
| 62 func getDebugTaskOutput(taskID string) (string, error) { | 61 func getDebugTaskOutput(taskID string) (string, error) { |
| 63 // Read the debug file instead. | 62 // Read the debug file instead. |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 // Supports server aliases. | 339 // Supports server aliases. |
| 341 func taskPageURL(swarmingHostname, taskID string) string { | 340 func taskPageURL(swarmingHostname, taskID string) string { |
| 342 return fmt.Sprintf("https://%s/user/task/%s", swarmingHostname, taskID) | 341 return fmt.Sprintf("https://%s/user/task/%s", swarmingHostname, taskID) |
| 343 } | 342 } |
| 344 | 343 |
| 345 // botPageURL returns a URL to a human-consumable page of a swarming bot. | 344 // botPageURL returns a URL to a human-consumable page of a swarming bot. |
| 346 // Supports server aliases. | 345 // Supports server aliases. |
| 347 func botPageURL(swarmingHostname, botID string) string { | 346 func botPageURL(swarmingHostname, botID string) string { |
| 348 return fmt.Sprintf("https://%s/restricted/bot/%s", swarmingHostname, bot
ID) | 347 return fmt.Sprintf("https://%s/restricted/bot/%s", swarmingHostname, bot
ID) |
| 349 } | 348 } |
| OLD | NEW |