(ctx context.Context, apiClient apiClient, codespace *api.Codespace)
| 186 | } |
| 187 | |
| 188 | func getDevContainer(ctx context.Context, apiClient apiClient, codespace *api.Codespace) <-chan devContainerResult { |
| 189 | ch := make(chan devContainerResult, 1) |
| 190 | go func() { |
| 191 | contents, err := apiClient.GetCodespaceRepositoryContents(ctx, codespace, ".devcontainer/devcontainer.json") |
| 192 | if err != nil { |
| 193 | ch <- devContainerResult{nil, fmt.Errorf("error getting content: %w", err)} |
| 194 | return |
| 195 | } |
| 196 | |
| 197 | if contents == nil { |
| 198 | ch <- devContainerResult{nil, nil} |
| 199 | return |
| 200 | } |
| 201 | |
| 202 | convertedJSON := normalizeJSON(jsonc.ToJSON(contents)) |
| 203 | if !jsonc.Valid(convertedJSON) { |
| 204 | ch <- devContainerResult{nil, errors.New("failed to convert json to standard json")} |
| 205 | return |
| 206 | } |
| 207 | |
| 208 | var container devContainer |
| 209 | if err := json.Unmarshal(convertedJSON, &container); err != nil { |
| 210 | ch <- devContainerResult{nil, fmt.Errorf("error unmarshalling: %w", err)} |
| 211 | return |
| 212 | } |
| 213 | |
| 214 | ch <- devContainerResult{&container, nil} |
| 215 | }() |
| 216 | return ch |
| 217 | } |
| 218 | |
| 219 | func newPortsVisibilityCmd(app *App, selector *CodespaceSelector) *cobra.Command { |
| 220 | return &cobra.Command{ |
no test coverage detected