1
0
mirror of https://github.com/getsops/sops.git synced 2026-02-05 12:45:21 +01:00
Files
AJ Bahnken 6910225545 Adds support for sops publish-ing to Vault (#494)
* Add vault/api to vendor/

* Adds support for sops publish-ing to Vault

* Adds support for publishing secrets (unencrypted) to Vault
* Adds a new EmitAsMap for TreeBanches
* Adds documentation about sops publish-ing to Vault
* Initial integration/functional test for publishing to vault
2019-07-16 14:33:59 -07:00

47 lines
1.1 KiB
Go

// Licensed under the MIT license, see LICENCE file for details.
package quicktest
import (
"fmt"
"strconv"
"strings"
"github.com/kr/pretty"
)
// Format formats the given value as a string. It is used to print values in
// test failures unless that's changed by calling C.SetFormat.
func Format(v interface{}) string {
switch v := v.(type) {
case error:
return formatErr(v)
case fmt.Stringer:
return "s" + quoteString(v.String())
case string:
return quoteString(v)
}
// The pretty.Sprint equivalent does not quote string values.
return fmt.Sprintf("%# v", pretty.Formatter(v))
}
func formatErr(err error) string {
s := fmt.Sprintf("%+v", err)
if s != err.Error() {
// The error has formatted itself with additional information.
// Leave that as is.
return s
}
return "e" + quoteString(s)
}
func quoteString(s string) string {
// TODO think more about what to do about multi-line strings.
if strings.Contains(s, `"`) && !strings.Contains(s, "\n") && strconv.CanBackquote(s) {
return "`" + s + "`"
}
return strconv.Quote(s)
}
type formatFunc func(interface{}) string