mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-20 11:37:01 -07:00
feat(secrets): implement SecretStore interface and StaticStore/LocalStore for credential management
This commit is contained in:
parent
ccce61694b
commit
ee1fc327e2
13 changed files with 531 additions and 34 deletions
|
|
@ -8,6 +8,7 @@ import (
|
|||
urlx "github.com/OpenCHAMI/magellan/internal/url"
|
||||
magellan "github.com/OpenCHAMI/magellan/pkg"
|
||||
"github.com/OpenCHAMI/magellan/pkg/auth"
|
||||
"github.com/OpenCHAMI/magellan/pkg/secrets"
|
||||
"github.com/cznic/mathutil"
|
||||
magellan "github.com/davidallendj/magellan/internal"
|
||||
"github.com/davidallendj/magellan/internal/cache/sqlite"
|
||||
|
|
@ -59,10 +60,10 @@ var CollectCmd = &cobra.Command{
|
|||
if concurrency <= 0 {
|
||||
concurrency = mathutil.Clamp(len(scannedResults), 1, 10000)
|
||||
}
|
||||
// Create a StaticSecretStore to hold the username and password
|
||||
secrets := secrets.NewStaticStore(username, password)
|
||||
_, err = magellan.CollectInventory(&scannedResults, &magellan.CollectParams{
|
||||
URI: host,
|
||||
Username: username,
|
||||
Password: password,
|
||||
Timeout: timeout,
|
||||
Concurrency: concurrency,
|
||||
Verbose: verbose,
|
||||
|
|
@ -70,7 +71,7 @@ var CollectCmd = &cobra.Command{
|
|||
OutputPath: outputPath,
|
||||
ForceUpdate: forceUpdate,
|
||||
AccessToken: accessToken,
|
||||
})
|
||||
}, secrets)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msgf("failed to collect data")
|
||||
}
|
||||
|
|
|
|||
16
cmd/crawl.go
16
cmd/crawl.go
|
|
@ -5,8 +5,9 @@ import (
|
|||
"fmt"
|
||||
"log"
|
||||
|
||||
urlx "github.com/davidallendj/magellan/internal/url"
|
||||
"github.com/davidallendj/magellan/pkg/crawler"
|
||||
urlx "github.com/OpenCHAMI/magellan/internal/url"
|
||||
"github.com/OpenCHAMI/magellan/pkg/crawler"
|
||||
"github.com/OpenCHAMI/magellan/pkg/secrets"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
|
@ -35,11 +36,14 @@ var CrawlCmd = &cobra.Command{
|
|||
return nil
|
||||
},
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
staticStore := &secrets.StaticStore{
|
||||
Username: viper.GetString("crawl.username"),
|
||||
Password: viper.GetString("crawl.password"),
|
||||
}
|
||||
systems, err := crawler.CrawlBMCForSystems(crawler.CrawlerConfig{
|
||||
URI: args[0],
|
||||
Username: cmd.Flag("username").Value.String(),
|
||||
Password: cmd.Flag("password").Value.String(),
|
||||
Insecure: cmd.Flag("insecure").Value.String() == "true",
|
||||
URI: args[0],
|
||||
CredentialStore: staticStore,
|
||||
Insecure: cmd.Flag("insecure").Value.String() == "true",
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatalf("Error crawling BMC: %v", err)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue