feat(agent,command): add show-thumbprint command

This commit is contained in:
wpetit 2023-03-10 11:52:42 +01:00
parent 258d0bc158
commit 55db21ad23
2 changed files with 31 additions and 0 deletions

View File

@ -14,6 +14,7 @@ func Root() *cli.Command {
openwrt.Root(), openwrt.Root(),
config.Root(), config.Root(),
RunCommand(), RunCommand(),
ShowThumbprintCommand(),
}, },
} }
} }

View File

@ -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
},
}
}