Skip to content

Commit

Permalink
fixes for linter
Browse files Browse the repository at this point in the history
  • Loading branch information
leehinman committed Oct 17, 2024
1 parent 1fb1489 commit 968dbf6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
6 changes: 2 additions & 4 deletions libbeat/cfgfile/cfgfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ var (
defaults *config.C
homePath *string
configPath *string
dataPath *string
logsPath *string
allowedBackwardsCompatibleFlags []string
)

Expand All @@ -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")
})
}
Expand Down
20 changes: 10 additions & 10 deletions libbeat/cmd/keystore.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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 {

Check failure on line 142 in libbeat/cmd/keystore.go

View workflow job for this annotation

GitHub Actions / lint (linux)

S1002: should omit comparison to bool constant, can be simplified to `!force` (gosimple)
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)

Check failure on line 150 in libbeat/cmd/keystore.go

View workflow job for this annotation

GitHub Actions / lint (linux)

use of `fmt.Printf` forbidden by pattern `fmt.Print.*` (forbidigo)
return nil
}
} else {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 968dbf6

Please sign in to comment.