Skip to content

Commit 7bc3b77

Browse files
add toml store
1 parent 6130ffe commit 7bc3b77

File tree

5 files changed

+555
-46
lines changed

5 files changed

+555
-46
lines changed

go.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ require (
3434
github.com/opencontainers/image-spec v1.0.1 // indirect
3535
github.com/opencontainers/runc v0.1.1 // indirect
3636
github.com/ory/dockertest v3.3.4+incompatible
37+
github.com/pelletier/go-toml v1.8.2-0.20210203134853-b4f0a950bf95
3738
github.com/pkg/errors v0.9.1
3839
github.com/sirupsen/logrus v1.4.2
3940
github.com/smartystreets/goconvey v0.0.0-20190710185942-9d28bd7c0945 // indirect
@@ -48,6 +49,10 @@ require (
4849
google.golang.org/protobuf v1.25.0
4950
gopkg.in/ini.v1 v1.44.0
5051
gopkg.in/urfave/cli.v1 v1.20.0
52+
<<<<<<< HEAD
5153
gopkg.in/yaml.v3 v3.0.0-20210107172259-749611fa9fcc
5254
gotest.tools v2.2.0+incompatible // indirect
55+
=======
56+
gotest.tools v2.2.0+incompatible
57+
>>>>>>> cc2ee88b7 (add toml store)
5358
)

go.sum

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,12 @@ github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJ
217217
github.com/ory/dockertest v3.3.4+incompatible h1:VrpM6Gqg7CrPm3bL4Wm1skO+zFWLbh7/Xb5kGEbJRh8=
218218
github.com/ory/dockertest v3.3.4+incompatible/go.mod h1:1vX4m9wsvi00u5bseYwXaSnhNrne+V0E6LAcBILJdPs=
219219
github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
220+
github.com/pelletier/go-toml v1.8.1 h1:1Nf83orprkJyknT6h7zbuEGUEjcyVlCxSUGTENmNCRM=
221+
github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc=
222+
github.com/pelletier/go-toml v1.8.2-0.20210129133109-c9a09d8695a8 h1:W2oirYjelH+CnTvFIwDQU+oxSNrrUt7/w7CRQ8yZokA=
223+
github.com/pelletier/go-toml v1.8.2-0.20210129133109-c9a09d8695a8/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc=
224+
github.com/pelletier/go-toml v1.8.2-0.20210203134853-b4f0a950bf95 h1:MAWl0xCdavY7sCLWqBORpL8ppvxvue1/ffgghMMVe5E=
225+
github.com/pelletier/go-toml v1.8.2-0.20210203134853-b4f0a950bf95/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc=
220226
github.com/pierrec/lz4 v2.0.5+incompatible h1:2xWsjqPFWcplujydGg4WmhC/6fZqK42wMM8aXeqhl0I=
221227
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
222228
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=

stores/stores.go

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -29,80 +29,80 @@ type SopsFile struct {
2929
// in the SOPS file by checking for nil. This way we can show the user a
3030
// helpful error message indicating that the metadata wasn't found, instead
3131
// of showing a cryptic parsing error
32-
Metadata *Metadata `yaml:"sops" json:"sops" ini:"sops"`
32+
Metadata *Metadata `toml:"sops" yaml:"sops" json:"sops" ini:"sops"`
3333
}
3434

3535
// Metadata is stored in SOPS encrypted files, and it contains the information necessary to decrypt the file.
3636
// This struct is just used for serialization, and SOPS uses another struct internally, sops.Metadata. It exists
3737
// in order to allow the binary format to stay backwards compatible over time, but at the same time allow the internal
3838
// representation SOPS uses to change over time.
3939
type Metadata struct {
40-
ShamirThreshold int `yaml:"shamir_threshold,omitempty" json:"shamir_threshold,omitempty"`
41-
KeyGroups []keygroup `yaml:"key_groups,omitempty" json:"key_groups,omitempty"`
42-
KMSKeys []kmskey `yaml:"kms" json:"kms"`
43-
GCPKMSKeys []gcpkmskey `yaml:"gcp_kms" json:"gcp_kms"`
44-
AzureKeyVaultKeys []azkvkey `yaml:"azure_kv" json:"azure_kv"`
45-
VaultKeys []vaultkey `yaml:"hc_vault" json:"hc_vault"`
46-
AgeKeys []agekey `yaml:"age" json:"age"`
47-
LastModified string `yaml:"lastmodified" json:"lastmodified"`
48-
MessageAuthenticationCode string `yaml:"mac" json:"mac"`
49-
PGPKeys []pgpkey `yaml:"pgp" json:"pgp"`
50-
UnencryptedSuffix string `yaml:"unencrypted_suffix,omitempty" json:"unencrypted_suffix,omitempty"`
51-
EncryptedSuffix string `yaml:"encrypted_suffix,omitempty" json:"encrypted_suffix,omitempty"`
52-
UnencryptedRegex string `yaml:"unencrypted_regex,omitempty" json:"unencrypted_regex,omitempty"`
53-
EncryptedRegex string `yaml:"encrypted_regex,omitempty" json:"encrypted_regex,omitempty"`
54-
Version string `yaml:"version" json:"version"`
40+
ShamirThreshold int `toml:"shamir_threshold,omitempty" yaml:"shamir_threshold,omitempty" json:"shamir_threshold,omitempty"`
41+
KeyGroups []keygroup `toml:"key_groups,omitempty" yaml:"key_groups,omitempty" json:"key_groups,omitempty"`
42+
KMSKeys []kmskey `toml:"kms" yaml:"kms" json:"kms"`
43+
GCPKMSKeys []gcpkmskey `toml:"gcp_kms" yaml:"gcp_kms" json:"gcp_kms"`
44+
AzureKeyVaultKeys []azkvkey `toml:"azure_kv" yaml:"azure_kv" json:"azure_kv"`
45+
VaultKeys []vaultkey `toml:"hc_vault" yaml:"hc_vault" json:"hc_vault"`
46+
AgeKeys []agekey `toml:"age" yaml:"age" json:"age"`
47+
LastModified string `toml:"lastmodified" yaml:"lastmodified" json:"lastmodified"`
48+
MessageAuthenticationCode string `toml:"mac" yaml:"mac" json:"mac"`
49+
PGPKeys []pgpkey `toml:"pgp" yaml:"pgp" json:"pgp"`
50+
UnencryptedSuffix string `toml:"unencrypted_suffix,omitempty" yaml:"unencrypted_suffix,omitempty" json:"unencrypted_suffix,omitempty"`
51+
EncryptedSuffix string `toml:"encrypted_suffix,omitempty" yaml:"encrypted_suffix,omitempty" json:"encrypted_suffix,omitempty"`
52+
UnencryptedRegex string `toml:"unencrypted_regex,omitempty" yaml:"unencrypted_regex,omitempty" json:"unencrypted_regex,omitempty"`
53+
EncryptedRegex string `toml:"encrypted_regex,omitempty" yaml:"encrypted_regex,omitempty" json:"encrypted_regex,omitempty"`
54+
Version string `toml:"version" yaml:"version" json:"version"`
5555
}
5656

5757
type keygroup struct {
58-
PGPKeys []pgpkey `yaml:"pgp,omitempty" json:"pgp,omitempty"`
59-
KMSKeys []kmskey `yaml:"kms,omitempty" json:"kms,omitempty"`
60-
GCPKMSKeys []gcpkmskey `yaml:"gcp_kms,omitempty" json:"gcp_kms,omitempty"`
61-
AzureKeyVaultKeys []azkvkey `yaml:"azure_kv,omitempty" json:"azure_kv,omitempty"`
62-
VaultKeys []vaultkey `yaml:"hc_vault" json:"hc_vault"`
63-
AgeKeys []agekey `yaml:"age" json:"age"`
58+
PGPKeys []pgpkey `toml:"pgp,omitempty" yaml:"pgp,omitempty" json:"pgp,omitempty"`
59+
KMSKeys []kmskey `toml:"kms,omitempty" yaml:"kms,omitempty" json:"kms,omitempty"`
60+
GCPKMSKeys []gcpkmskey `toml:"gcp_kms,omitempty" yaml:"gcp_kms,omitempty" json:"gcp_kms,omitempty"`
61+
AzureKeyVaultKeys []azkvkey `toml:"azure_kv,omitempty" yaml:"azure_kv,omitempty" json:"azure_kv,omitempty"`
62+
VaultKeys []vaultkey `toml:"hc_vault" yaml:"hc_vault" json:"hc_vault"`
63+
AgeKeys []agekey `toml:"age" yaml:"age" json:"age"`
6464
}
6565

6666
type pgpkey struct {
67-
CreatedAt string `yaml:"created_at" json:"created_at"`
68-
EncryptedDataKey string `yaml:"enc" json:"enc"`
69-
Fingerprint string `yaml:"fp" json:"fp"`
67+
CreatedAt string `toml:"created_at" yaml:"created_at" json:"created_at"`
68+
EncryptedDataKey string `toml:"enc" yaml:"enc" json:"enc"`
69+
Fingerprint string `toml:"fp" yaml:"fp" json:"fp"`
7070
}
7171

7272
type kmskey struct {
73-
Arn string `yaml:"arn" json:"arn"`
74-
Role string `yaml:"role,omitempty" json:"role,omitempty"`
75-
Context map[string]*string `yaml:"context,omitempty" json:"context,omitempty"`
76-
CreatedAt string `yaml:"created_at" json:"created_at"`
77-
EncryptedDataKey string `yaml:"enc" json:"enc"`
78-
AwsProfile string `yaml:"aws_profile" json:"aws_profile"`
73+
Arn string `toml:"arn" yaml:"arn" json:"arn"`
74+
Role string `toml:"role,omitempty" yaml:"role,omitempty" json:"role,omitempty"`
75+
Context map[string]*string `toml:"context,omitempty" yaml:"context,omitempty" json:"context,omitempty"`
76+
CreatedAt string `toml:"created_at" yaml:"created_at" json:"created_at"`
77+
EncryptedDataKey string `toml:"enc" yaml:"enc" json:"enc"`
78+
AwsProfile string `toml:"aws_profile" yaml:"aws_profile" json:"aws_profile"`
7979
}
8080

8181
type gcpkmskey struct {
82-
ResourceID string `yaml:"resource_id" json:"resource_id"`
83-
CreatedAt string `yaml:"created_at" json:"created_at"`
84-
EncryptedDataKey string `yaml:"enc" json:"enc"`
82+
ResourceID string `toml:"resource_id" yaml:"resource_id" json:"resource_id"`
83+
CreatedAt string `toml:"created_at" yaml:"created_at" json:"created_at"`
84+
EncryptedDataKey string `toml:"enc" yaml:"enc" json:"enc"`
8585
}
8686

8787
type vaultkey struct {
88-
VaultAddress string `yaml:"vault_address" json:"vault_address"`
89-
EnginePath string `yaml:"engine_path" json:"engine_path"`
90-
KeyName string `yaml:"key_name" json:"key_name"`
91-
CreatedAt string `yaml:"created_at" json:"created_at"`
92-
EncryptedDataKey string `yaml:"enc" json:"enc"`
88+
VaultAddress string `toml:"vault_address" yaml:"vault_address" json:"vault_address"`
89+
EnginePath string `toml:"engine_path" yaml:"engine_path" json:"engine_path"`
90+
KeyName string `toml:"key_name" yaml:"key_name" json:"key_name"`
91+
CreatedAt string `toml:"created_at" yaml:"created_at" json:"created_at"`
92+
EncryptedDataKey string `toml:"enc" yaml:"enc" json:"enc"`
9393
}
9494

9595
type azkvkey struct {
96-
VaultURL string `yaml:"vault_url" json:"vault_url"`
97-
Name string `yaml:"name" json:"name"`
98-
Version string `yaml:"version" json:"version"`
99-
CreatedAt string `yaml:"created_at" json:"created_at"`
100-
EncryptedDataKey string `yaml:"enc" json:"enc"`
96+
VaultURL string `toml:"vault_url" yaml:"vault_url" json:"vault_url"`
97+
Name string `toml:"name" yaml:"name" json:"name"`
98+
Version string `toml:"version" yaml:"version" json:"version"`
99+
CreatedAt string `toml:"created_at" yaml:"created_at" json:"created_at"`
100+
EncryptedDataKey string `toml:"enc" yaml:"enc" json:"enc"`
101101
}
102102

103103
type agekey struct {
104-
Recipient string `yaml:"recipient" json:"recipient"`
105-
EncryptedDataKey string `yaml:"enc" json:"enc"`
104+
Recipient string `toml:"recipient" yaml:"recipient" json:"recipient"`
105+
EncryptedDataKey string `toml:"enc" yaml:"enc" json:"enc"`
106106
}
107107

108108
// MetadataFromInternal converts an internal SOPS metadata representation to a representation appropriate for storage

0 commit comments

Comments
 (0)