mirror of
https://github.com/getsops/sops.git
synced 2026-02-05 03:45:44 +01:00
Run 'gofmt -w' on all .go files.
Signed-off-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
@@ -462,7 +462,7 @@ func main() {
|
||||
Name: "filestatus",
|
||||
Usage: "check the status of the file, returning encryption status",
|
||||
ArgsUsage: `file`,
|
||||
Flags: []cli.Flag{
|
||||
Flags: []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "input-type",
|
||||
Usage: "currently ini, json, yaml, dotenv and binary are supported. If not set, sops will use the file's extension to determine the type",
|
||||
@@ -1718,8 +1718,8 @@ func main() {
|
||||
Usage: "set the encrypted comment suffix. When specified, only keys that have comment matching the regex will be encrypted.",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "config",
|
||||
Usage: "path to sops' config file. If set, sops will not search for the config file recursively.",
|
||||
Name: "config",
|
||||
Usage: "path to sops' config file. If set, sops will not search for the config file recursively.",
|
||||
EnvVar: "SOPS_CONFIG",
|
||||
},
|
||||
cli.StringFlag{
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package exec
|
||||
|
||||
@@ -537,29 +537,29 @@ func TestLoadConfigFileWithMerge(t *testing.T) {
|
||||
"hc_vault: https://foo.vault:8200/v1/foo/keys/foo-key",
|
||||
}, ids(conf.KeyGroups[0]))
|
||||
assert.Equal(t, []string{
|
||||
"pgp: foo", // key01
|
||||
"kms: foo||foo", //key02
|
||||
"pgp: foo", // key01
|
||||
"kms: foo||foo", //key02
|
||||
"kms: foo+123|baz:bam|bar", //key03
|
||||
"gcp_kms: foo", //key04
|
||||
"gcp_kms: foo", //key04
|
||||
"azure_kv: https://foo.vault.azure.net/keys/foo-key/fooversion", //key05
|
||||
"hc_vault: https://bar.vault:8200/v1/bar/keys/bar-key", //key06
|
||||
"pgp: bar", //key07
|
||||
"hc_vault: https://bar.vault:8200/v1/bar/keys/bar-key", //key06
|
||||
"pgp: bar", //key07
|
||||
"kms: bar||bar", //key08
|
||||
"gcp_kms: bar", //key09
|
||||
"gcp_kms: baz", //key10
|
||||
"gcp_kms: bar", //key09
|
||||
"gcp_kms: baz", //key10
|
||||
"azure_kv: https://bar.vault.azure.net/keys/bar-key/barversion", //key11
|
||||
"hc_vault: https://baz.vault:8200/v1/baz/keys/baz-key", //key12
|
||||
"pgp: baz", //key13
|
||||
"hc_vault: https://baz.vault:8200/v1/baz/keys/baz-key", //key12
|
||||
"pgp: baz", //key13
|
||||
"kms: baz||baz", //key14
|
||||
"hc_vault: https://foo.vault:8200/v1/foo/keys/foo-key", //key15
|
||||
"pgp: qux", //key16
|
||||
"kms: qux||qux", //key17
|
||||
"kms: baz||bar", //key18
|
||||
"kms: baz+123", //key19
|
||||
"gcp_kms: qux", //key20
|
||||
"pgp: qux", //key16
|
||||
"kms: qux||qux", //key17
|
||||
"kms: baz||bar", //key18
|
||||
"kms: baz+123", //key19
|
||||
"gcp_kms: qux", //key20
|
||||
"gcp_kms: fnord", //key21
|
||||
"azure_kv: https://baz.vault.azure.net/keys/baz-key/bazversion", //key22
|
||||
"hc_vault: https://qux.vault:8200/v1/qux/keys/qux-key", //key23
|
||||
"hc_vault: https://qux.vault:8200/v1/qux/keys/qux-key", //key23
|
||||
"kms: fnord||fnord", //key24
|
||||
"hc_vault: https://fnord.vault:8200/v1/fnord/keys/fnord-key", //key25
|
||||
}, ids(conf.KeyGroups[1]))
|
||||
|
||||
@@ -4,9 +4,9 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/getsops/sops/v3/logging"
|
||||
"github.com/google/go-cmp/cmp"
|
||||
vault "github.com/hashicorp/vault/api"
|
||||
"github.com/getsops/sops/v3/logging"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
@@ -123,17 +123,17 @@ func inverse(a uint8) uint8 {
|
||||
// (See also https://github.com/openbao/openbao/commit/a209a052024b70bc563d9674cde21a20b5106570)
|
||||
|
||||
// In the comments, we use ^ to denote raising to the power:
|
||||
b := mult(a, a) // b is now a^2
|
||||
c := mult(a, b) // c is now a^3
|
||||
b = mult(c, c) // b is now a^6
|
||||
b = mult(b, b) // b is now a^12
|
||||
c = mult(b, c) // c is now a^15
|
||||
b = mult(b, b) // b is now a^24
|
||||
b = mult(b, b) // b is now a^48
|
||||
b = mult(b, c) // b is now a^63
|
||||
b = mult(b, b) // b is now a^126
|
||||
b = mult(a, b) // b is now a^127
|
||||
return mult(b, b) // result is a^254
|
||||
b := mult(a, a) // b is now a^2
|
||||
c := mult(a, b) // c is now a^3
|
||||
b = mult(c, c) // b is now a^6
|
||||
b = mult(b, b) // b is now a^12
|
||||
c = mult(b, c) // c is now a^15
|
||||
b = mult(b, b) // b is now a^24
|
||||
b = mult(b, b) // b is now a^48
|
||||
b = mult(b, c) // b is now a^63
|
||||
b = mult(b, b) // b is now a^126
|
||||
b = mult(a, b) // b is now a^127
|
||||
return mult(b, b) // result is a^254
|
||||
}
|
||||
|
||||
// mult multiplies two numbers in GF(2^8)
|
||||
|
||||
66
sops_test.go
66
sops_test.go
@@ -919,7 +919,7 @@ func TestTruncateTreeNotArray(t *testing.T) {
|
||||
func TestTruncateTreeArrayOutOfBounds(t *testing.T) {
|
||||
tree := TreeBranch{
|
||||
TreeItem{
|
||||
Key: "foo",
|
||||
Key: "foo",
|
||||
Value: []interface{}{
|
||||
"one",
|
||||
"two",
|
||||
@@ -1198,11 +1198,11 @@ func TestSetArrayNonLeaf(t *testing.T) {
|
||||
func TestUnsetKeyRootLeaf(t *testing.T) {
|
||||
branch := TreeBranch{
|
||||
TreeItem{
|
||||
Key: "foo",
|
||||
Key: "foo",
|
||||
Value: "foo",
|
||||
},
|
||||
TreeItem{
|
||||
Key: "foofoo",
|
||||
Key: "foofoo",
|
||||
Value: "foofoo",
|
||||
},
|
||||
}
|
||||
@@ -1210,7 +1210,7 @@ func TestUnsetKeyRootLeaf(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, TreeBranch{
|
||||
TreeItem{
|
||||
Key: "foo",
|
||||
Key: "foo",
|
||||
Value: "foo",
|
||||
},
|
||||
}, unset)
|
||||
@@ -1222,11 +1222,11 @@ func TestUnsetKeyBranchLeaf(t *testing.T) {
|
||||
Key: "foo",
|
||||
Value: TreeBranch{
|
||||
TreeItem{
|
||||
Key: "bar",
|
||||
Key: "bar",
|
||||
Value: "bar",
|
||||
},
|
||||
TreeItem{
|
||||
Key: "barbar",
|
||||
Key: "barbar",
|
||||
Value: "barbar",
|
||||
},
|
||||
},
|
||||
@@ -1239,7 +1239,7 @@ func TestUnsetKeyBranchLeaf(t *testing.T) {
|
||||
Key: "foo",
|
||||
Value: TreeBranch{
|
||||
TreeItem{
|
||||
Key: "bar",
|
||||
Key: "bar",
|
||||
Value: "bar",
|
||||
},
|
||||
},
|
||||
@@ -1250,14 +1250,14 @@ func TestUnsetKeyBranchLeaf(t *testing.T) {
|
||||
func TestUnsetKeyBranch(t *testing.T) {
|
||||
branch := TreeBranch{
|
||||
TreeItem{
|
||||
Key: "foo",
|
||||
Key: "foo",
|
||||
Value: "foo",
|
||||
},
|
||||
TreeItem{
|
||||
Key: "foofoo",
|
||||
Value: TreeBranch{
|
||||
TreeItem{
|
||||
Key: "bar",
|
||||
Key: "bar",
|
||||
Value: "bar",
|
||||
},
|
||||
},
|
||||
@@ -1267,7 +1267,7 @@ func TestUnsetKeyBranch(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, TreeBranch{
|
||||
TreeItem{
|
||||
Key: "foo",
|
||||
Key: "foo",
|
||||
Value: "foo",
|
||||
},
|
||||
}, unset)
|
||||
@@ -1276,14 +1276,13 @@ func TestUnsetKeyBranch(t *testing.T) {
|
||||
func TestUnsetKeyRootLastLeaf(t *testing.T) {
|
||||
branch := TreeBranch{
|
||||
TreeItem{
|
||||
Key: "foo",
|
||||
Key: "foo",
|
||||
Value: "foo",
|
||||
},
|
||||
}
|
||||
unset, err := branch.Unset([]interface{}{"foo"})
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, TreeBranch{
|
||||
}, unset)
|
||||
assert.Equal(t, TreeBranch{}, unset)
|
||||
}
|
||||
|
||||
func TestUnsetKeyBranchLastLeaf(t *testing.T) {
|
||||
@@ -1292,7 +1291,7 @@ func TestUnsetKeyBranchLastLeaf(t *testing.T) {
|
||||
Key: "foo",
|
||||
Value: TreeBranch{
|
||||
TreeItem{
|
||||
Key: "bar",
|
||||
Key: "bar",
|
||||
Value: "bar",
|
||||
},
|
||||
},
|
||||
@@ -1302,9 +1301,8 @@ func TestUnsetKeyBranchLastLeaf(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, TreeBranch{
|
||||
TreeItem{
|
||||
Key: "foo",
|
||||
Value: TreeBranch{
|
||||
},
|
||||
Key: "foo",
|
||||
Value: TreeBranch{},
|
||||
},
|
||||
}, unset)
|
||||
}
|
||||
@@ -1319,7 +1317,7 @@ func TestUnsetKeyArray(t *testing.T) {
|
||||
Value: []interface{}{
|
||||
TreeBranch{
|
||||
TreeItem{
|
||||
Key: "baz",
|
||||
Key: "baz",
|
||||
Value: "baz",
|
||||
},
|
||||
},
|
||||
@@ -1332,9 +1330,8 @@ func TestUnsetKeyArray(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, TreeBranch{
|
||||
TreeItem{
|
||||
Key: "foo",
|
||||
Value: TreeBranch{
|
||||
},
|
||||
Key: "foo",
|
||||
Value: TreeBranch{},
|
||||
},
|
||||
}, unset)
|
||||
}
|
||||
@@ -1346,13 +1343,13 @@ func TestUnsetArrayItem(t *testing.T) {
|
||||
Value: []interface{}{
|
||||
TreeBranch{
|
||||
TreeItem{
|
||||
Key: "bar",
|
||||
Key: "bar",
|
||||
Value: "bar",
|
||||
},
|
||||
},
|
||||
TreeBranch{
|
||||
TreeItem{
|
||||
Key: "barbar",
|
||||
Key: "barbar",
|
||||
Value: "barbar",
|
||||
},
|
||||
},
|
||||
@@ -1367,7 +1364,7 @@ func TestUnsetArrayItem(t *testing.T) {
|
||||
Value: []interface{}{
|
||||
TreeBranch{
|
||||
TreeItem{
|
||||
Key: "bar",
|
||||
Key: "bar",
|
||||
Value: "bar",
|
||||
},
|
||||
},
|
||||
@@ -1383,11 +1380,11 @@ func TestUnsetKeyInArrayItem(t *testing.T) {
|
||||
Value: []interface{}{
|
||||
TreeBranch{
|
||||
TreeItem{
|
||||
Key: "bar",
|
||||
Key: "bar",
|
||||
Value: "bar",
|
||||
},
|
||||
TreeItem{
|
||||
Key: "barbar",
|
||||
Key: "barbar",
|
||||
Value: "barbar",
|
||||
},
|
||||
},
|
||||
@@ -1402,7 +1399,7 @@ func TestUnsetKeyInArrayItem(t *testing.T) {
|
||||
Value: []interface{}{
|
||||
TreeBranch{
|
||||
TreeItem{
|
||||
Key: "bar",
|
||||
Key: "bar",
|
||||
Value: "bar",
|
||||
},
|
||||
},
|
||||
@@ -1418,7 +1415,7 @@ func TestUnsetArrayLastItem(t *testing.T) {
|
||||
Value: []interface{}{
|
||||
TreeBranch{
|
||||
TreeItem{
|
||||
Key: "bar",
|
||||
Key: "bar",
|
||||
Value: "bar",
|
||||
},
|
||||
},
|
||||
@@ -1429,9 +1426,8 @@ func TestUnsetArrayLastItem(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, TreeBranch{
|
||||
TreeItem{
|
||||
Key: "foo",
|
||||
Value: []interface{}{
|
||||
},
|
||||
Key: "foo",
|
||||
Value: []interface{}{},
|
||||
},
|
||||
}, unset)
|
||||
}
|
||||
@@ -1442,7 +1438,7 @@ func TestUnsetKeyNotFound(t *testing.T) {
|
||||
Key: "foo",
|
||||
Value: TreeBranch{
|
||||
TreeItem{
|
||||
Key: "bar",
|
||||
Key: "bar",
|
||||
Value: "bar",
|
||||
},
|
||||
},
|
||||
@@ -1461,7 +1457,7 @@ func TestUnsetKeyInArrayNotFound(t *testing.T) {
|
||||
Value: []interface{}{
|
||||
TreeBranch{
|
||||
TreeItem{
|
||||
Key: "bar",
|
||||
Key: "bar",
|
||||
Value: "bar",
|
||||
},
|
||||
},
|
||||
@@ -1480,7 +1476,7 @@ func TestUnsetArrayItemOutOfBounds(t *testing.T) {
|
||||
Value: []interface{}{
|
||||
TreeBranch{
|
||||
TreeItem{
|
||||
Key: "bar",
|
||||
Key: "bar",
|
||||
Value: "bar",
|
||||
},
|
||||
},
|
||||
@@ -1495,7 +1491,7 @@ func TestUnsetArrayItemOutOfBounds(t *testing.T) {
|
||||
func TestUnsetKeyNotABranch(t *testing.T) {
|
||||
branch := TreeBranch{
|
||||
TreeItem{
|
||||
Key: "foo",
|
||||
Key: "foo",
|
||||
Value: 99,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -245,16 +245,16 @@ func DecodeNonStrings(m map[string]interface{}) error {
|
||||
}
|
||||
if v, ok := m["shamir_threshold"]; ok {
|
||||
switch val := v.(type) {
|
||||
case string:
|
||||
vInt, err := strconv.Atoi(val)
|
||||
if err != nil {
|
||||
return fmt.Errorf("shamir_threshold is not an integer: %s", err.Error())
|
||||
}
|
||||
m["shamir_threshold"] = vInt
|
||||
case int:
|
||||
m["shamir_threshold"] = val
|
||||
default:
|
||||
return fmt.Errorf("shamir_threshold is neither a string nor an integer, but %T", val)
|
||||
case string:
|
||||
vInt, err := strconv.Atoi(val)
|
||||
if err != nil {
|
||||
return fmt.Errorf("shamir_threshold is not an integer: %s", err.Error())
|
||||
}
|
||||
m["shamir_threshold"] = vInt
|
||||
case int:
|
||||
m["shamir_threshold"] = val
|
||||
default:
|
||||
return fmt.Errorf("shamir_threshold is neither a string nor an integer, but %T", val)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user