Skip to content

feat: Add links for registering git key #1125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
17 changes: 15 additions & 2 deletions cli/publickey.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
package cli

import (
"strings"

"github.com/spf13/cobra"
"golang.org/x/xerrors"

"github.com/coder/coder/cli/cliui"
"github.com/coder/coder/codersdk"
)

func publickey() *cobra.Command {
return &cobra.Command{
Use: "publickey",
Use: "publickey",
Aliases: []string{"pubkey"},
RunE: func(cmd *cobra.Command, args []string) error {
client, err := createClient(cmd)
if err != nil {
Expand All @@ -21,7 +25,16 @@ func publickey() *cobra.Command {
return xerrors.Errorf("create codersdk client: %w", err)
}

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

return nil
},
Expand Down
5 changes: 4 additions & 1 deletion provisionerd/provisionerd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,15 @@ func TestProvisionerd(t *testing.T) {
didAcquireJob atomic.Bool
didDryRun atomic.Bool
)
var complete sync.Once
completeChan := make(chan struct{})
closer := createProvisionerd(t, func(ctx context.Context) (proto.DRPCProvisionerDaemonClient, error) {
return createProvisionerDaemonClient(t, provisionerDaemonTestServer{
acquireJob: func(ctx context.Context, _ *proto.Empty) (*proto.AcquiredJob, error) {
if didAcquireJob.Load() {
close(completeChan)
complete.Do(func() {
close(completeChan)
})
return &proto.AcquiredJob{}, nil
}
didAcquireJob.Store(true)
Expand Down