mirror of
https://github.com/coder/coder.git
synced 2026-09-21 20:51:01 +08:00
feat: Add links for registering git key (#1125)
This commit is contained in:
+15
-2
@@ -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 {
|
||||
@@ -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
|
||||
},
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user