Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

feat: add provider name and repo name to envs ls #286

Merged
merged 4 commits into from
Mar 12, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixup! feat: add provider name and repo name to envs ls
  • Loading branch information
cmoog committed Mar 12, 2021
commit 4af33c293523899e4b12970aa554c7016fc5192c
15 changes: 12 additions & 3 deletions internal/coderutil/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
"net/url"
"sync"

"golang.org/x/sync/errgroup"
"golang.org/x/xerrors"
"nhooyr.io/websocket"

"cdr.dev/coder-cli/coder-sdk"
"cdr.dev/coder-cli/pkg/clog"
)

// DialEnvWsep dials the executor endpoint using the https://github.com/cdr/wsep message protocol.
Expand Down Expand Up @@ -125,13 +125,22 @@ func EnvsHumanTable(ctx context.Context, client coder.Client, envs []coder.Envir
}

func makeImageMap(ctx context.Context, client coder.Client, envs []coder.Environment) (map[string]*coder.Image, error) {
var mu sync.Mutex
var egroup errgroup.Group
var (
mu sync.Mutex
egroup = clog.LoggedErrGroup()
)
imageMap := make(map[string]*coder.Image)
for _, e := range envs {
// put all the image IDs into a map to remove duplicates
imageMap[e.ImageID] = nil
}
ids := make([]string, 0, len(imageMap))
for id := range imageMap {
// put the deduplicated back into a slice
// so we can write to the map while iterating
ids = append(ids, id)
}
for _, id := range ids {
id := id
egroup.Go(func() error {
img, err := client.ImageByID(ctx, id)
Expand Down