MCPcopy Index your code
hub / github.com/cli/cli / getDevContainer

Function getDevContainer

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

Source from the content-addressed store, hash-verified

186}
187
188func 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
219func newPortsVisibilityCmd(app *App, selector *CodespaceSelector) *cobra.Command {
220 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