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

Commit 9c085aa

Browse files
authored
chore: sort coder envs by name in ssh config (#257)
* chore: sort coder envs by name in ssh config * Fix doc comment * Use sort.Slice
1 parent 37dfbee commit 9c085aa

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

internal/cmd/configssh.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"os"
99
"os/user"
1010
"path/filepath"
11+
"sort"
1112
"strings"
1213

1314
"cdr.dev/coder-cli/pkg/clog"
@@ -176,6 +177,9 @@ func writeSSHKey(ctx context.Context, client coder.Client, privateKeyPath string
176177

177178
func makeNewConfigs(userName string, envs []coderutil.EnvWithWorkspaceProvider, privateKeyFilepath string) string {
178179
newConfig := fmt.Sprintf("\n%s\n%s\n\n", sshStartToken, sshStartMessage)
180+
181+
sort.Slice(envs, func(i, j int) bool { return envs[i].Env.Name < envs[j].Env.Name })
182+
179183
for _, env := range envs {
180184
if !env.WorkspaceProvider.SSHEnabled {
181185
clog.LogWarn(fmt.Sprintf("SSH is not enabled for workspace provider %q", env.WorkspaceProvider.Name),

0 commit comments

Comments
 (0)