1
0
mirror of https://github.com/getsops/sops.git synced 2026-02-05 12:45:21 +01:00

Use log.Print instead of fmt.Print everywhere

This commit is contained in:
Adrian Utrilla
2017-08-29 11:08:55 -07:00
parent 609d541bae
commit 1b09444742
4 changed files with 18 additions and 16 deletions

View File

@@ -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, "")

View File

@@ -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
}

View File

@@ -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]

View File

@@ -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,
},