Separated auth from util and fixed help strings

This commit is contained in:
David Allen 2024-08-12 13:05:28 -06:00
parent dce823c6d8
commit 3287d76588
No known key found for this signature in database
GPG key ID: 717C593FF60A2ACC
4 changed files with 10 additions and 11 deletions

View file

@ -17,10 +17,9 @@ import (
var crawlCmd = &cobra.Command{ var crawlCmd = &cobra.Command{
Use: "crawl [uri]", Use: "crawl [uri]",
Short: "Crawl a single BMC for inventory information", Short: "Crawl a single BMC for inventory information",
Long: "Crawl a single BMC for inventory information. This command does NOT store information" + 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'" + "store information about the scan into cache after completion. To do so, use the 'collect'\n" +
"command instead\n" + "command instead\n\n" +
"\n" +
"Examples:\n" + "Examples:\n" +
" magellan crawl https://bmc.example.com\n" + " magellan crawl https://bmc.example.com\n" +
" magellan crawl https://bmc.example.com -i -u username -p password", " magellan crawl https://bmc.example.com -i -u username -p password",

View file

@ -7,7 +7,7 @@ import (
"os" "os"
magellan "github.com/OpenCHAMI/magellan/internal" 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/lestrrat-go/jwx/jwt"
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -30,7 +30,7 @@ var loginCmd = &cobra.Command{
// check if we have a valid JWT before starting login // check if we have a valid JWT before starting login
if !forceLogin { if !forceLogin {
// try getting the access token from env var // try getting the access token from env var
testToken, err := util.LoadAccessToken(tokenPath) testToken, err := auth.LoadAccessToken(tokenPath)
if err != nil { if err != nil {
log.Error().Err(err).Msgf("failed to load access token") log.Error().Err(err).Msgf("failed to load access token")
} }

View file

@ -9,7 +9,7 @@ import (
magellan "github.com/OpenCHAMI/magellan/internal" magellan "github.com/OpenCHAMI/magellan/internal"
"github.com/OpenCHAMI/magellan/internal/cache/sqlite" "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/rs/zerolog/log"
"github.com/cznic/mathutil" "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" + "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" + "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" + "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" + "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" + "specified. The `--scheme` flag works similarly and the default value is 'https' in the host URL or with the\n" +
"'--protocol' flag.\n\n" + "'--protocol' flag.\n\n" +
@ -72,8 +72,8 @@ var scanCmd = &cobra.Command{
} }
// format and combine flag and positional args // format and combine flag and positional args
targetHosts = append(targetHosts, util.FormatHostUrls(args, ports, scheme, verbose)...) targetHosts = append(targetHosts, client.FormatHostUrls(args, ports, scheme, verbose)...)
targetHosts = append(targetHosts, util.FormatHostUrls(hosts, ports, scheme, verbose)...) targetHosts = append(targetHosts, client.FormatHostUrls(hosts, ports, scheme, verbose)...)
// add more hosts specified with `--subnet` flag // add more hosts specified with `--subnet` flag
if debug { if debug {

View file

@ -26,7 +26,7 @@ var (
var updateCmd = &cobra.Command{ var updateCmd = &cobra.Command{
Use: "update hosts...", Use: "update hosts...",
Short: "Update BMC node firmware", 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" + "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 --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", " magellan update --status --bmc.host 172.16.0.108 --bmc.port 443 --username bmc_username --password bmc_password",