Merge branch 'main' into config-file

This commit is contained in:
David J. Allen 2024-05-07 14:57:34 -06:00
commit 2b421e8af5
No known key found for this signature in database
GPG key ID: 717C593FF60A2ACC
24 changed files with 618 additions and 298 deletions

View file

@ -1,10 +1,10 @@
package cmd
import (
magellan "github.com/bikeshack/magellan/internal"
"github.com/bikeshack/magellan/internal/api/smd"
"github.com/bikeshack/magellan/internal/db/sqlite"
"github.com/bikeshack/magellan/internal/log"
magellan "github.com/OpenCHAMI/magellan/internal"
"github.com/OpenCHAMI/magellan/internal/api/smd"
"github.com/OpenCHAMI/magellan/internal/db/sqlite"
"github.com/OpenCHAMI/magellan/internal/log"
"github.com/cznic/mathutil"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
@ -28,21 +28,31 @@ var collectCmd = &cobra.Command{
l.Log.Errorf("could not get states: %v", err)
}
// try to load access token either from env var, file, or config if var not set
if accessToken == "" {
var err error
accessToken, err = LoadAccessToken()
if err != nil {
l.Log.Errorf("failed to load access token: %v", err)
}
}
//
if threads <= 0 {
threads = mathutil.Clamp(len(probeStates), 1, 255)
}
q := &magellan.QueryParams{
User: user,
Pass: pass,
Protocol: protocol,
Drivers: drivers,
Preferred: preferredDriver,
Timeout: timeout,
Threads: threads,
Verbose: verbose,
WithSecureTLS: withSecureTLS,
OutputPath: outputPath,
ForceUpdate: forceUpdate,
User: user,
Pass: pass,
Protocol: protocol,
Drivers: drivers,
Preferred: preferredDriver,
Timeout: timeout,
Threads: threads,
Verbose: verbose,
CaCertPath: cacertPath,
OutputPath: outputPath,
ForceUpdate: forceUpdate,
}
magellan.CollectAll(&probeStates, l, q)
@ -81,6 +91,5 @@ func init() {
viper.BindPFlag("collect.secure-tls", collectCmd.Flags().Lookup("secure-tls"))
viper.BindPFlag("collect.cert-pool", collectCmd.Flags().Lookup("cert-pool"))
rootCmd.AddCommand(collectCmd)
}