From 1b0944474208076ff2e3e6dce5ef0666328b0ed9 Mon Sep 17 00:00:00 2001 From: Adrian Utrilla Date: Tue, 29 Aug 2017 11:08:55 -0700 Subject: [PATCH] Use log.Print instead of fmt.Print everywhere --- aes/decryptor_test.go | 10 +++++----- cmd/sops/edit.go | 7 ++++--- kms/keysource.go | 8 ++++---- kms/keysource_test.go | 9 +++++---- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/aes/decryptor_test.go b/aes/decryptor_test.go index bf1f4b26a..4e1b24445 100644 --- a/aes/decryptor_test.go +++ b/aes/decryptor_test.go @@ -2,7 +2,7 @@ package aes import ( "crypto/rand" - "fmt" + "log" "strings" "testing" "testing/quick" @@ -35,7 +35,7 @@ func TestRoundtripString(t *testing.T) { rand.Read(key) s, err := Cipher{}.Encrypt(x, key, aad, nil) if err != nil { - fmt.Println(err) + log.Println(err) return false } d, _, err := Cipher{}.Decrypt(s, key, aad) @@ -54,7 +54,7 @@ func TestRoundtripFloat(t *testing.T) { f := func(x float64) bool { s, err := Cipher{}.Encrypt(x, key, "", nil) if err != nil { - fmt.Println(err) + log.Println(err) return false } d, _, err := Cipher{}.Decrypt(s, key, "") @@ -73,7 +73,7 @@ func TestRoundtripInt(t *testing.T) { f := func(x int) bool { s, err := Cipher{}.Encrypt(x, key, "", nil) if err != nil { - fmt.Println(err) + log.Println(err) return false } d, _, err := Cipher{}.Decrypt(s, key, "") @@ -92,7 +92,7 @@ func TestRoundtripBool(t *testing.T) { f := func(x bool) bool { s, err := Cipher{}.Encrypt(x, key, "", nil) if err != nil { - fmt.Println(err) + log.Println(err) return false } d, _, err := Cipher{}.Decrypt(s, key, "") diff --git a/cmd/sops/edit.go b/cmd/sops/edit.go index b1c43c105..289c043a4 100644 --- a/cmd/sops/edit.go +++ b/cmd/sops/edit.go @@ -3,6 +3,7 @@ package main import ( "fmt" "io/ioutil" + "log" "os" "crypto/md5" @@ -202,14 +203,14 @@ func runEditorUntilOk(opts runEditorUntilOkOpts) error { } newBranch, err := opts.InputStore.Unmarshal(edited) if err != nil { - fmt.Printf("Could not load tree: %s\nProbably invalid syntax. Press a key to return to the editor, or Ctrl+C to exit.", err) + log.Printf("Could not load tree: %s\nProbably invalid syntax. Press a key to return to the editor, or Ctrl+C to exit.", err) bufio.NewReader(os.Stdin).ReadByte() continue } if opts.ShowMasterKeys { metadata, err := opts.InputStore.UnmarshalMetadata(edited) if err != nil { - fmt.Printf("sops branch is invalid: %s.\nPress a key to return to the editor, or Ctrl+C to exit.", err) + log.Printf("sops branch is invalid: %s.\nPress a key to return to the editor, or Ctrl+C to exit.", err) bufio.NewReader(os.Stdin).ReadByte() continue } @@ -224,7 +225,7 @@ func runEditorUntilOk(opts runEditorUntilOkOpts) error { opts.Tree.Metadata.Version = version } if opts.Tree.Metadata.MasterKeyCount() == 0 { - fmt.Println("No master keys were provided, so sops can't encrypt the file.\nPress a key to return to the editor, or Ctrl+C to exit.") + log.Println("No master keys were provided, so sops can't encrypt the file.\nPress a key to return to the editor, or Ctrl+C to exit.") bufio.NewReader(os.Stdin).ReadByte() continue } diff --git a/kms/keysource.go b/kms/keysource.go index a89db17bd..243dd3b7a 100644 --- a/kms/keysource.go +++ b/kms/keysource.go @@ -210,7 +210,7 @@ func ParseKMSContext(in interface{}) map[string]*string { for k, v := range in { value, ok := v.(string) if !ok { - fmt.Println("[WARNING]: KMS Encryption Context contains a non-string value, context will not be used") + log.Println("[WARNING]: KMS Encryption Context contains a non-string value, context will not be used") return nil } out[k] = &value @@ -222,12 +222,12 @@ func ParseKMSContext(in interface{}) map[string]*string { for k, v := range in { key, ok := k.(string) if !ok { - fmt.Println("[WARNING]: KMS Encryption Context contains a non-string key, context will not be used") + log.Println("[WARNING]: KMS Encryption Context contains a non-string key, context will not be used") return nil } value, ok := v.(string) if !ok { - fmt.Println("[WARNING]: KMS Encryption Context contains a non-string value, context will not be used") + log.Println("[WARNING]: KMS Encryption Context contains a non-string value, context will not be used") return nil } out[key] = &value @@ -239,7 +239,7 @@ func ParseKMSContext(in interface{}) map[string]*string { for _, kv := range strings.Split(in, ",") { kv := strings.Split(kv, ":") if len(kv) != 2 { - fmt.Printf("[WARNING]: KMS Encryption Context could not be parsed, context will not be used") + log.Printf("[WARNING]: KMS Encryption Context could not be parsed, context will not be used") return nil } out[kv[0]] = &kv[1] diff --git a/kms/keysource_test.go b/kms/keysource_test.go index 1dbb7a760..3c1a8dd0b 100644 --- a/kms/keysource_test.go +++ b/kms/keysource_test.go @@ -2,11 +2,12 @@ package kms import ( "bytes" - "fmt" "testing" "testing/quick" "time" + "log" + "github.com/aws/aws-sdk-go/service/kms" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -30,11 +31,11 @@ func TestKMS(t *testing.T) { f := func(x []byte) bool { err := k.Encrypt(x) if err != nil { - fmt.Println(err) + log.Println(err) } v, err := k.Decrypt() if err != nil { - fmt.Println(err) + log.Println(err) } return bytes.Equal(v, x) } @@ -132,7 +133,7 @@ func TestKeyToMap(t *testing.T) { "role": "bar", "enc": "this is encrypted", "created_at": "2016-10-31T10:00:00Z", - "context": map[string]string{ + "context": map[string]string{ "key1": value1, "key2": value2, },