Skip to content

Commit 387a7db

Browse files
committed
feat: Add links for registering git key
1 parent a6ea995 commit 387a7db

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

cli/publickey.go

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
package cli
22

33
import (
4+
"strings"
5+
46
"github.com/spf13/cobra"
57
"golang.org/x/xerrors"
68

9+
"github.com/coder/coder/cli/cliui"
710
"github.com/coder/coder/codersdk"
811
)
912

1013
func publickey() *cobra.Command {
1114
return &cobra.Command{
12-
Use: "publickey",
15+
Use: "publickey",
16+
Aliases: []string{"pubkey"},
1317
RunE: func(cmd *cobra.Command, args []string) error {
1418
client, err := createClient(cmd)
1519
if err != nil {
@@ -21,7 +25,16 @@ func publickey() *cobra.Command {
2125
return xerrors.Errorf("create codersdk client: %w", err)
2226
}
2327

24-
cmd.Println(key.PublicKey)
28+
cmd.Println(cliui.Styles.Wrap.Render(
29+
"This is your public key for using " + cliui.Styles.Field.Render("git") + " in " +
30+
"Coder. All clones with SSH will be authenticated automatically 🪄.",
31+
))
32+
cmd.Println()
33+
cmd.Println("Add to GitHub and GitLab:")
34+
cmd.Println(cliui.Styles.Prompt.String() + "https://github.com/settings/ssh/new")
35+
cmd.Println(cliui.Styles.Prompt.String() + "https://gitlab.com/-/profile/keys")
36+
cmd.Println()
37+
cmd.Println(cliui.Styles.Code.Render(strings.TrimSpace(key.PublicKey)))
2538

2639
return nil
2740
},

provisionerd/provisionerd_test.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,15 @@ func TestProvisionerd(t *testing.T) {
210210
didAcquireJob atomic.Bool
211211
didDryRun atomic.Bool
212212
)
213+
var complete sync.Once
213214
completeChan := make(chan struct{})
214215
closer := createProvisionerd(t, func(ctx context.Context) (proto.DRPCProvisionerDaemonClient, error) {
215216
return createProvisionerDaemonClient(t, provisionerDaemonTestServer{
216217
acquireJob: func(ctx context.Context, _ *proto.Empty) (*proto.AcquiredJob, error) {
217218
if didAcquireJob.Load() {
218-
close(completeChan)
219+
complete.Do(func() {
220+
close(completeChan)
221+
})
219222
return &proto.AcquiredJob{}, nil
220223
}
221224
didAcquireJob.Store(true)

0 commit comments

Comments
 (0)