MCPcopy Create free account
hub / github.com/cli/cli / getDevContainer

Function getDevContainer

pkg/cmd/codespace/ports.go:189–218  ·  view source on GitHub ↗
(ctx context.Context, apiClient apiClient, codespace *api.Codespace)

Source from the content-addressed store, hash-verified

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

Callers 1

ListPortsMethod · 0.85

Calls 4

normalizeJSONFunction · 0.85
ValidMethod · 0.80
ErrorfMethod · 0.65

Tested by

no test coverage detected