From 3287d765880ae7f98ee057bf0493bb1649447a57 Mon Sep 17 00:00:00 2001 From: David Allen Date: Mon, 12 Aug 2024 13:05:28 -0600 Subject: [PATCH] Separated auth from util and fixed help strings --- cmd/crawl.go | 7 +++---- cmd/login.go | 4 ++-- cmd/scan.go | 8 ++++---- cmd/update.go | 2 +- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/cmd/crawl.go b/cmd/crawl.go index 2df487b..ac797a8 100644 --- a/cmd/crawl.go +++ b/cmd/crawl.go @@ -17,10 +17,9 @@ import ( var crawlCmd = &cobra.Command{ Use: "crawl [uri]", Short: "Crawl a single BMC for inventory information", - Long: "Crawl a single BMC for inventory information. This command does NOT store information" + - "store information about the scan into cache after completion. To do so, use the 'collect'" + - "command instead\n" + - "\n" + + Long: "Crawl a single BMC for inventory information. This command does NOT store information\n" + + "store information about the scan into cache after completion. To do so, use the 'collect'\n" + + "command instead\n\n" + "Examples:\n" + " magellan crawl https://bmc.example.com\n" + " magellan crawl https://bmc.example.com -i -u username -p password", diff --git a/cmd/login.go b/cmd/login.go index b0c0308..79a5243 100644 --- a/cmd/login.go +++ b/cmd/login.go @@ -7,7 +7,7 @@ import ( "os" magellan "github.com/OpenCHAMI/magellan/internal" - "github.com/OpenCHAMI/magellan/internal/util" + "github.com/OpenCHAMI/magellan/pkg/auth" "github.com/lestrrat-go/jwx/jwt" "github.com/rs/zerolog/log" "github.com/spf13/cobra" @@ -30,7 +30,7 @@ var loginCmd = &cobra.Command{ // check if we have a valid JWT before starting login if !forceLogin { // try getting the access token from env var - testToken, err := util.LoadAccessToken(tokenPath) + testToken, err := auth.LoadAccessToken(tokenPath) if err != nil { log.Error().Err(err).Msgf("failed to load access token") } diff --git a/cmd/scan.go b/cmd/scan.go index d246149..f8b4763 100644 --- a/cmd/scan.go +++ b/cmd/scan.go @@ -9,7 +9,7 @@ import ( magellan "github.com/OpenCHAMI/magellan/internal" "github.com/OpenCHAMI/magellan/internal/cache/sqlite" - "github.com/OpenCHAMI/magellan/internal/util" + "github.com/OpenCHAMI/magellan/pkg/client" "github.com/rs/zerolog/log" "github.com/cznic/mathutil" @@ -40,7 +40,7 @@ var scanCmd = &cobra.Command{ "by using the '--subnet' flag and providing an IP address on the subnet as well as a CIDR. If no CIDR is\n" + "provided, then the subnet mask specified with the '--subnet-mask' flag will be used instead (will use\n" + "default mask if not set).\n\n" + - "Similarly, any host provided with no port with use either the ports specified\n" + + "Similarly, any host provided with no port will use either the ports specified\n" + "with `--port` or the default port used with each specified protocol. The default protocol is 'tcp' unless\n" + "specified. The `--scheme` flag works similarly and the default value is 'https' in the host URL or with the\n" + "'--protocol' flag.\n\n" + @@ -72,8 +72,8 @@ var scanCmd = &cobra.Command{ } // format and combine flag and positional args - targetHosts = append(targetHosts, util.FormatHostUrls(args, ports, scheme, verbose)...) - targetHosts = append(targetHosts, util.FormatHostUrls(hosts, ports, scheme, verbose)...) + targetHosts = append(targetHosts, client.FormatHostUrls(args, ports, scheme, verbose)...) + targetHosts = append(targetHosts, client.FormatHostUrls(hosts, ports, scheme, verbose)...) // add more hosts specified with `--subnet` flag if debug { diff --git a/cmd/update.go b/cmd/update.go index 82e3106..66dcdc3 100644 --- a/cmd/update.go +++ b/cmd/update.go @@ -26,7 +26,7 @@ var ( var updateCmd = &cobra.Command{ Use: "update hosts...", Short: "Update BMC node firmware", - Long: "Perform an firmware update using Redfish by providing a remote firmware URL and component.\n" + + Long: "Perform an firmware update using Redfish by providing a remote firmware URL and component.\n\n" + "Examples:\n" + " magellan update --bmc.host 172.16.0.108 --bmc.port 443 --username bmc_username --password bmc_password --firmware-url http://172.16.0.200:8005/firmware/bios/image.RBU --component BIOS\n" + " magellan update --status --bmc.host 172.16.0.108 --bmc.port 443 --username bmc_username --password bmc_password",