From 55db21ad23b8bb5a7c5cdb6d7554be78595b2205 Mon Sep 17 00:00:00 2001 From: William Petit Date: Fri, 10 Mar 2023 11:52:42 +0100 Subject: [PATCH] feat(agent,command): add show-thumbprint command --- internal/command/agent/root.go | 1 + internal/command/agent/show_thumbprint.go | 30 +++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 internal/command/agent/show_thumbprint.go diff --git a/internal/command/agent/root.go b/internal/command/agent/root.go index 346a634..c5bd044 100644 --- a/internal/command/agent/root.go +++ b/internal/command/agent/root.go @@ -14,6 +14,7 @@ func Root() *cli.Command { openwrt.Root(), config.Root(), RunCommand(), + ShowThumbprintCommand(), }, } } diff --git a/internal/command/agent/show_thumbprint.go b/internal/command/agent/show_thumbprint.go new file mode 100644 index 0000000..f852c4f --- /dev/null +++ b/internal/command/agent/show_thumbprint.go @@ -0,0 +1,30 @@ +package agent + +import ( + "fmt" + + "forge.cadoles.com/Cadoles/emissary/internal/command/common" + "forge.cadoles.com/Cadoles/emissary/internal/machineid" + "github.com/pkg/errors" + "github.com/urfave/cli/v2" +) + +func ShowThumbprintCommand() *cli.Command { + flags := common.Flags() + + return &cli.Command{ + Name: "show-thumbprint", + Usage: "Show the current agent thumbprint", + Flags: flags, + Action: func(ctx *cli.Context) error { + thumbprint, err := machineid.Get() + if err != nil { + return errors.WithStack(err) + } + + fmt.Println(thumbprint) + + return nil + }, + } +}