Skip to content
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

add option to register only for an eab setup #2062

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import "github.com/urfave/cli/v2"
// CreateCommands Creates all CLI commands.
func CreateCommands() []*cli.Command {
return []*cli.Command{
createRegister(),
createRun(),
createRevoke(),
createRenew(),
Expand Down
44 changes: 44 additions & 0 deletions cmd/cmd_register.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package cmd

import (
"fmt"

"github.com/go-acme/lego/v4/log"
"github.com/urfave/cli/v2"
)

func createRegister() *cli.Command {
return &cli.Command{
Name: "register",
Usage: "Register an account",
Before: func(ctx *cli.Context) error {
return nil
},
Action: registerAction,
Flags: []cli.Flag{},
}
}

func registerAction(ctx *cli.Context) error {
accountsStorage := NewAccountsStorage(ctx)

account, client := setup(ctx, accountsStorage)
setupChallenges(ctx, client)

if account.Registration == nil {
reg, err := register(ctx, client)
if err != nil {
log.Fatalf("Could not complete registration\n\t%v", err)
}

account.Registration = reg
if err = accountsStorage.Save(account); err != nil {
log.Fatal(err)
}

fmt.Printf(rootPathWarningMessage, accountsStorage.GetRootPath())
return err
}

return nil
}
2 changes: 1 addition & 1 deletion cmd/cmd_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
func createRun() *cli.Command {
return &cli.Command{
Name: "run",
Usage: "Register an account, then create and install a certificate",
Usage: "Register an account (if not registered), then create and install a certificate",
Before: func(ctx *cli.Context) error {
// we require either domains or csr, but not both
hasDomains := len(ctx.StringSlice("domains")) > 0
Expand Down