From ca0e15eda37f04f8b7a634492617eb270ea77509 Mon Sep 17 00:00:00 2001 From: Hidde Beydals Date: Sat, 12 Aug 2023 01:54:34 +0200 Subject: [PATCH] *: solve `go vet` errors ``` stores/dotenv/store.go:74:12: github.com/getsops/sops/v3.Comment struct literal uses unkeyed fields stores/dotenv/store_test.go:29:10: github.com/getsops/sops/v3.Comment struct literal uses unkeyed fields keyservice/server.go:149:9: assignment copies lock value to key: github.com/getsops/sops/v3/keyservice.Key contains google.golang.org/protobuf/internal/impl.MessageState contains sync.Mutex keyservice/server.go:206:20: call of ks.prompt copies lock value: github.com/getsops/sops/v3/keyservice.Key contains google.golang.org/protobuf/internal/impl.MessageState contains sync.Mutex keyservice/server.go:214:22: keyToString passes lock by value: github.com/getsops/sops/v3/keyservice.Key contains google.golang.org/protobuf/internal/impl.MessageState contains sync.Mutex keyservice/server.go:231:29: prompt passes lock by value: github.com/getsops/sops/v3/keyservice.Key contains google.golang.org/protobuf/internal/impl.MessageState contains sync.Mutex keyservice/server.go:232:27: call of keyToString copies lock value: github.com/getsops/sops/v3/keyservice.Key contains google.golang.org/protobuf/internal/impl.MessageState contains sync.Mutex keyservice/server.go:251:9: assignment copies lock value to key: github.com/getsops/sops/v3/keyservice.Key contains google.golang.org/protobuf/internal/impl.MessageState contains sync.Mutex keyservice/server.go:308:20: call of ks.prompt copies lock value: github.com/getsops/sops/v3/keyservice.Key contains google.golang.org/protobuf/internal/impl.MessageState contains sync.Mutex stores/yaml/store_test.go:27:11: github.com/getsops/sops/v3.Comment struct literal uses unkeyed fields stores/yaml/store_test.go:39:11: github.com/getsops/sops/v3.Comment struct literal uses unkeyed fields stores/yaml/store_test.go:107:5: github.com/getsops/sops/v3.Comment struct literal uses unkeyed fields stores/yaml/store_test.go:139:13: github.com/getsops/sops/v3.Comment struct literal uses unkeyed fields decrypt/example_test.go:34:1: ExampleDecryptFile refers to unknown identifier: DecryptFile ``` Signed-off-by: Hidde Beydals --- decrypt/example_test.go | 2 +- keyservice/server.go | 8 ++++---- stores/dotenv/store.go | 2 +- stores/dotenv/store_test.go | 4 ++-- stores/yaml/store_test.go | 18 +++++++++--------- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/decrypt/example_test.go b/decrypt/example_test.go index 0ccdc87aa..dcdd33211 100644 --- a/decrypt/example_test.go +++ b/decrypt/example_test.go @@ -31,7 +31,7 @@ type configuration struct { AnEmptyValue string `json:"anEmptyValue"` } -func ExampleDecryptFile() { +func ExampleFile() { var ( confPath string = "./example.json" cfg configuration diff --git a/keyservice/server.go b/keyservice/server.go index 82c1a4855..480a66e8b 100644 --- a/keyservice/server.go +++ b/keyservice/server.go @@ -146,7 +146,7 @@ func (ks *Server) decryptWithAge(key *AgeKey, ciphertext []byte) ([]byte, error) // result func (ks Server) Encrypt(ctx context.Context, req *EncryptRequest) (*EncryptResponse, error) { - key := *req.Key + key := req.Key var response *EncryptResponse switch k := key.KeyType.(type) { case *Key_PgpKey: @@ -211,7 +211,7 @@ func (ks Server) Encrypt(ctx context.Context, return response, nil } -func keyToString(key Key) string { +func keyToString(key *Key) string { switch k := key.KeyType.(type) { case *Key_PgpKey: return fmt.Sprintf("PGP key with fingerprint %s", k.PgpKey.Fingerprint) @@ -228,7 +228,7 @@ func keyToString(key Key) string { } } -func (ks Server) prompt(key Key, requestType string) error { +func (ks Server) prompt(key *Key, requestType string) error { keyString := keyToString(key) var response string for response != "y" && response != "n" { @@ -248,7 +248,7 @@ func (ks Server) prompt(key Key, requestType string) error { // result func (ks Server) Decrypt(ctx context.Context, req *DecryptRequest) (*DecryptResponse, error) { - key := *req.Key + key := req.Key var response *DecryptResponse switch k := key.KeyType.(type) { case *Key_PgpKey: diff --git a/stores/dotenv/store.go b/stores/dotenv/store.go index 41124ab0f..fad0f3494 100644 --- a/stores/dotenv/store.go +++ b/stores/dotenv/store.go @@ -72,7 +72,7 @@ func (store *Store) LoadPlainFile(in []byte) (sops.TreeBranches, error) { } if line[0] == '#' { branch = append(branch, sops.TreeItem{ - Key: sops.Comment{string(line[1:])}, + Key: sops.Comment{Value: string(line[1:])}, Value: nil, }) } else { diff --git a/stores/dotenv/store_test.go b/stores/dotenv/store_test.go index dc0c2d1de..c234d4ea5 100644 --- a/stores/dotenv/store_test.go +++ b/stores/dotenv/store_test.go @@ -4,8 +4,8 @@ import ( "strings" "testing" - "github.com/stretchr/testify/assert" "github.com/getsops/sops/v3" + "github.com/stretchr/testify/assert" ) var PLAIN = []byte(strings.TrimLeft(` @@ -26,7 +26,7 @@ var BRANCH = sops.TreeBranch{ Value: "val2", }, sops.TreeItem{ - Key: sops.Comment{"comment"}, + Key: sops.Comment{Value: "comment"}, Value: nil, }, sops.TreeItem{ diff --git a/stores/yaml/store_test.go b/stores/yaml/store_test.go index bf0e1bfaa..f37e3deb4 100644 --- a/stores/yaml/store_test.go +++ b/stores/yaml/store_test.go @@ -3,8 +3,8 @@ package yaml import ( "testing" - "github.com/stretchr/testify/assert" "github.com/getsops/sops/v3" + "github.com/stretchr/testify/assert" ) var PLAIN = []byte(`--- @@ -24,7 +24,7 @@ key1_a: value var BRANCHES = sops.TreeBranches{ sops.TreeBranch{ sops.TreeItem{ - Key: sops.Comment{" comment 0"}, + Key: sops.Comment{Value: " comment 0"}, Value: nil, }, sops.TreeItem{ @@ -36,7 +36,7 @@ var BRANCHES = sops.TreeBranches{ Value: "value", }, sops.TreeItem{ - Key: sops.Comment{" ^ comment 1"}, + Key: sops.Comment{Value: " ^ comment 1"}, Value: nil, }, }, @@ -101,10 +101,10 @@ var COMMENT_6 = []byte(`a: var COMMENT_6_BRANCHES = sops.TreeBranches{ sops.TreeBranch{ sops.TreeItem{ - Key: "a", + Key: "a", Value: []interface{}{ "a", - sops.Comment{" I no longer get duplicated"}, + sops.Comment{Value: " I no longer get duplicated"}, sops.TreeBranch{}, }, }, @@ -124,10 +124,10 @@ e: var COMMENT_7_BRANCHES = sops.TreeBranches{ sops.TreeBranch{ sops.TreeItem{ - Key: "a", + Key: "a", Value: sops.TreeBranch{ sops.TreeItem{ - Key: "b", + Key: "b", Value: sops.TreeBranch{ sops.TreeItem{ Key: "c", @@ -136,13 +136,13 @@ var COMMENT_7_BRANCHES = sops.TreeBranches{ }, }, sops.TreeItem{ - Key: sops.Comment{" comment"}, + Key: sops.Comment{Value: " comment"}, Value: nil, }, }, }, sops.TreeItem{ - Key: "e", + Key: "e", Value: []interface{}{ "f", },