diff --git a/libbeat/cfgfile/cfgfile.go b/libbeat/cfgfile/cfgfile.go index f19ecad04216..2411bc028e07 100644 --- a/libbeat/cfgfile/cfgfile.go +++ b/libbeat/cfgfile/cfgfile.go @@ -39,8 +39,6 @@ var ( defaults *config.C homePath *string configPath *string - dataPath *string - logsPath *string allowedBackwardsCompatibleFlags []string ) @@ -66,9 +64,9 @@ func Initialize() { AddAllowedBackwardsCompatibleFlag("path.home") configPath = config.ConfigOverwriteFlag(nil, overwrites, "path.config", "path.config", "", "Configuration path") AddAllowedBackwardsCompatibleFlag("path.config") - dataPath = config.ConfigOverwriteFlag(nil, overwrites, "path.data", "path.data", "", "Data path") + _ = config.ConfigOverwriteFlag(nil, overwrites, "path.data", "path.data", "", "Data path") AddAllowedBackwardsCompatibleFlag("path.data") - logsPath = config.ConfigOverwriteFlag(nil, overwrites, "path.logs", "path.logs", "", "Logs path") + _ = config.ConfigOverwriteFlag(nil, overwrites, "path.logs", "path.logs", "", "Logs path") AddAllowedBackwardsCompatibleFlag("path.logs") }) } diff --git a/libbeat/cmd/keystore.go b/libbeat/cmd/keystore.go index 34a1ccc5c220..440d9a8d138f 100644 --- a/libbeat/cmd/keystore.go +++ b/libbeat/cmd/keystore.go @@ -21,13 +21,13 @@ import ( "bufio" "errors" "fmt" - "io/ioutil" + "io" "os" "strings" "syscall" "github.com/spf13/cobra" - tml "golang.org/x/crypto/ssh/terminal" + "golang.org/x/term" "github.com/elastic/beats/v7/libbeat/cfgfile" "github.com/elastic/beats/v7/libbeat/cmd/instance" @@ -39,7 +39,7 @@ import ( func getKeystore(settings instance.Settings) (keystore.Keystore, error) { b, err := instance.NewInitializedBeat(settings) if err != nil { - return nil, fmt.Errorf("error initializing beat: %s", err) + return nil, fmt.Errorf("error initializing beat: %w", err) } return b.Keystore(), nil @@ -136,18 +136,18 @@ func createKeystore(settings instance.Settings, force bool) error { writableKeystore, err := keystore.AsWritableKeystore(store) if err != nil { - return fmt.Errorf("error creating the keystore: %s", err) + return fmt.Errorf("error creating the keystore: %w", err) } - if store.IsPersisted() == true && force == false { + if store.IsPersisted() && force == false { response := terminal.PromptYesNo("A keystore already exists, Overwrite?", false) - if response == true { + if response { err := writableKeystore.Create(true) if err != nil { - return fmt.Errorf("error creating the keystore: %s", err) + return fmt.Errorf("error creating the keystore: %w", err) } } else { - fmt.Println("Exiting without creating keystore.") + fmt.Printf("Exiting without creating %s keystore.", settings.Name) return nil } } else { @@ -204,13 +204,13 @@ func addKey(store keystore.Keystore, keys []string, force, stdin bool) error { var keyValue []byte if stdin { reader := bufio.NewReader(os.Stdin) - keyValue, err = ioutil.ReadAll(reader) + keyValue, err = io.ReadAll(reader) if err != nil { return fmt.Errorf("could not read input from stdin") } } else { fmt.Printf("Enter value for %s: ", key) - keyValue, err = tml.ReadPassword(int(syscall.Stdin)) + keyValue, err = term.ReadPassword(int(syscall.Stdin)) fmt.Println() if err != nil { return fmt.Errorf("could not read value from the input, error: %s", err)