*: `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:
Hidde Beydals 2023-08-17 01:21:25 +02:00
Родитель 7e487fa0d2
Коммит 92aa55f06a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 979F380FC2341744
2 изменённых файлов: 12 добавлений и 5 удалений

Просмотреть файл

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

Просмотреть файл

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