зеркало из https://github.com/getsops/sops.git
*: `strings.Title` deprecation
Replace with simple manual construction of upper boolean representation, as the (construction of the) `golang.org/x/text/cases` replacement is way too complex for this use case. Signed-off-by: Hidde Beydals <hidde@hhh.computer>
This commit is contained in:
Родитель
7e487fa0d2
Коммит
92aa55f06a
|
@ -11,11 +11,10 @@ import (
|
|||
"fmt"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/getsops/sops/v3"
|
||||
"github.com/getsops/sops/v3/logging"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
var log *logrus.Logger
|
||||
|
@ -172,7 +171,11 @@ func (c Cipher) Encrypt(plaintext interface{}, key []byte, additionalData string
|
|||
case bool:
|
||||
encryptedType = "bool"
|
||||
// The Python version encodes booleans with Titlecase
|
||||
plainBytes = []byte(strings.Title(strconv.FormatBool(value)))
|
||||
if value {
|
||||
plainBytes = []byte("True")
|
||||
} else {
|
||||
plainBytes = []byte("False")
|
||||
}
|
||||
case sops.Comment:
|
||||
encryptedType = "comment"
|
||||
plainBytes = []byte(value.Value)
|
||||
|
|
8
sops.go
8
sops.go
|
@ -46,12 +46,12 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/getsops/sops/v3/audit"
|
||||
"github.com/getsops/sops/v3/keys"
|
||||
"github.com/getsops/sops/v3/keyservice"
|
||||
"github.com/getsops/sops/v3/logging"
|
||||
"github.com/getsops/sops/v3/shamir"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
|
@ -727,7 +727,11 @@ func ToBytes(in interface{}) ([]byte, error) {
|
|||
case float64:
|
||||
return []byte(strconv.FormatFloat(in, 'f', -1, 64)), nil
|
||||
case bool:
|
||||
return []byte(strings.Title(strconv.FormatBool(in))), nil
|
||||
boolB := []byte("True")
|
||||
if !in {
|
||||
boolB = []byte("False")
|
||||
}
|
||||
return boolB, nil
|
||||
case []byte:
|
||||
return in, nil
|
||||
case Comment:
|
||||
|
|
Загрузка…
Ссылка в новой задаче