Skip to content

Commit 9985d15

Browse files
committed
Remove old (de-)serialization.
Signed-off-by: Felix Fontein <felix@fontein.de>
1 parent 2157bda commit 9985d15

1 file changed

Lines changed: 53 additions & 62 deletions

File tree

stores/stores.go

Lines changed: 53 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -30,97 +30,88 @@ const (
3030
SopsMetadataKey = "sops"
3131
)
3232

33-
// SopsFile is a struct used by the stores as a helper to unmarshal the SOPS metadata
34-
type SopsFile struct {
35-
// Metadata is a pointer so we can easily tell when the field is not present
36-
// in the SOPS file by checking for nil. This way we can show the user a
37-
// helpful error message indicating that the metadata wasn't found, instead
38-
// of showing a cryptic parsing error
39-
Metadata *Metadata `yaml:"sops" json:"sops" ini:"sops" mapstructure:"sops,deep"`
40-
}
41-
4233
// Metadata is stored in SOPS encrypted files, and it contains the information necessary to decrypt the file.
4334
// This struct is just used for serialization, and SOPS uses another struct internally, sops.Metadata. It exists
4435
// in order to allow the binary format to stay backwards compatible over time, but at the same time allow the internal
4536
// representation SOPS uses to change over time.
4637
type Metadata struct {
47-
ShamirThreshold int `yaml:"shamir_threshold,omitempty" json:"shamir_threshold,omitempty" mapstructure:"shamir_threshold,omitempty"`
48-
KeyGroups []keygroup `yaml:"key_groups,omitempty" json:"key_groups,omitempty" mapstructure:"key_groups,omitempty,deep"`
49-
KMSKeys []kmskey `yaml:"kms,omitempty" json:"kms,omitempty" mapstructure:"kms,omitempty,deep"`
50-
GCPKMSKeys []gcpkmskey `yaml:"gcp_kms,omitempty" json:"gcp_kms,omitempty" mapstructure:"gcp_kms,omitempty,deep"`
51-
HCKmsKeys []hckmskey `yaml:"hckms,omitempty" json:"hckms,omitempty" mapstructure:"hckms,omitempty,deep"`
52-
AzureKeyVaultKeys []azkvkey `yaml:"azure_kv,omitempty" json:"azure_kv,omitempty" mapstructure:"azure_kv,omitempty,deep"`
53-
VaultKeys []vaultkey `yaml:"hc_vault,omitempty" json:"hc_vault,omitempty" mapstructure:"hc_vault,omitempty,deep"`
54-
AgeKeys []agekey `yaml:"age,omitempty" json:"age,omitempty" mapstructure:"age,omitempty,deep"`
55-
LastModified string `yaml:"lastmodified" json:"lastmodified" mapstructure:"lastmodified"`
56-
MessageAuthenticationCode string `yaml:"mac" json:"mac" mapstructure:"mac"`
57-
PGPKeys []pgpkey `yaml:"pgp,omitempty" json:"pgp,omitempty" mapstructure:"pgp,omitempty,deep"`
58-
UnencryptedSuffix string `yaml:"unencrypted_suffix,omitempty" json:"unencrypted_suffix,omitempty" mapstructure:"unencrypted_suffix,omitempty"`
59-
EncryptedSuffix string `yaml:"encrypted_suffix,omitempty" json:"encrypted_suffix,omitempty" mapstructure:"encrypted_suffix,omitempty"`
60-
UnencryptedRegex string `yaml:"unencrypted_regex,omitempty" json:"unencrypted_regex,omitempty" mapstructure:"unencrypted_regex,omitempty"`
61-
EncryptedRegex string `yaml:"encrypted_regex,omitempty" json:"encrypted_regex,omitempty" mapstructure:"encrypted_regex,omitempty"`
62-
UnencryptedCommentRegex string `yaml:"unencrypted_comment_regex,omitempty" json:"unencrypted_comment_regex,omitempty" mapstructure:"unencrypted_comment_regex,omitempty"`
63-
EncryptedCommentRegex string `yaml:"encrypted_comment_regex,omitempty" json:"encrypted_comment_regex,omitempty" mapstructure:"encrypted_comment_regex,omitempty"`
64-
MACOnlyEncrypted bool `yaml:"mac_only_encrypted,omitempty" json:"mac_only_encrypted,omitempty" mapstructure:"mac_only_encrypted,omitempty"`
65-
Version string `yaml:"version" json:"version" mapstructure:"version"`
38+
ShamirThreshold int `mapstructure:"shamir_threshold,omitempty"`
39+
KeyGroups []keygroup `mapstructure:"key_groups,omitempty,deep"`
40+
KMSKeys []kmskey `mapstructure:"kms,omitempty,deep"`
41+
GCPKMSKeys []gcpkmskey `mapstructure:"gcp_kms,omitempty,deep"`
42+
HCKmsKeys []hckmskey `mapstructure:"hckms,omitempty,deep"`
43+
AzureKeyVaultKeys []azkvkey `mapstructure:"azure_kv,omitempty,deep"`
44+
VaultKeys []vaultkey `mapstructure:"hc_vault,omitempty,deep"`
45+
AgeKeys []agekey `mapstructure:"age,omitempty,deep"`
46+
LastModified string `mapstructure:"lastmodified"`
47+
MessageAuthenticationCode string `mapstructure:"mac"`
48+
PGPKeys []pgpkey `mapstructure:"pgp,omitempty,deep"`
49+
UnencryptedSuffix string `mapstructure:"unencrypted_suffix,omitempty"`
50+
EncryptedSuffix string `mapstructure:"encrypted_suffix,omitempty"`
51+
UnencryptedRegex string `mapstructure:"unencrypted_regex,omitempty"`
52+
EncryptedRegex string `mapstructure:"encrypted_regex,omitempty"`
53+
UnencryptedCommentRegex string `mapstructure:"unencrypted_comment_regex,omitempty"`
54+
EncryptedCommentRegex string `mapstructure:"encrypted_comment_regex,omitempty"`
55+
MACOnlyEncrypted bool `mapstructure:"mac_only_encrypted,omitempty"`
56+
Version string `mapstructure:"version"`
6657
}
6758

6859
type keygroup struct {
69-
PGPKeys []pgpkey `yaml:"pgp,omitempty" json:"pgp,omitempty" mapstructure:"pgp,omitempty,deep"`
70-
KMSKeys []kmskey `yaml:"kms,omitempty" json:"kms,omitempty" mapstructure:"kms,omitempty,deep"`
71-
GCPKMSKeys []gcpkmskey `yaml:"gcp_kms,omitempty" json:"gcp_kms,omitempty" mapstructure:"gcp_kms,omitempty,deep"`
72-
HCKmsKeys []hckmskey `yaml:"hckms,omitempty" json:"hckms,omitempty" mapstructure:"hckms,omitempty,deep"`
73-
AzureKeyVaultKeys []azkvkey `yaml:"azure_kv,omitempty" json:"azure_kv,omitempty" mapstructure:"azure_kv,omitempty,deep"`
74-
VaultKeys []vaultkey `yaml:"hc_vault" json:"hc_vault" mapstructure:"hc_vault,deep"`
75-
AgeKeys []agekey `yaml:"age" json:"age" mapstructure:"age,deep"`
60+
PGPKeys []pgpkey `mapstructure:"pgp,omitempty,deep"`
61+
KMSKeys []kmskey `mapstructure:"kms,omitempty,deep"`
62+
GCPKMSKeys []gcpkmskey `mapstructure:"gcp_kms,omitempty,deep"`
63+
HCKmsKeys []hckmskey `mapstructure:"hckms,omitempty,deep"`
64+
AzureKeyVaultKeys []azkvkey `mapstructure:"azure_kv,omitempty,deep"`
65+
VaultKeys []vaultkey `mapstructure:"hc_vault,deep"`
66+
AgeKeys []agekey `mapstructure:"age,deep"`
7667
}
7768

7869
type pgpkey struct {
79-
CreatedAt string `yaml:"created_at" json:"created_at" mapstructure:"created_at"`
80-
EncryptedDataKey string `yaml:"enc" json:"enc" mapstructure:"enc"`
81-
Fingerprint string `yaml:"fp" json:"fp" mapstructure:"fp"`
70+
CreatedAt string `mapstructure:"created_at"`
71+
EncryptedDataKey string `mapstructure:"enc"`
72+
Fingerprint string `mapstructure:"fp"`
8273
}
8374

8475
type kmskey struct {
85-
Arn string `yaml:"arn" json:"arn" mapstructure:"arn"`
86-
Role string `yaml:"role,omitempty" json:"role,omitempty" mapstructure:"role,omitempty"`
87-
Context map[string]*string `yaml:"context,omitempty" json:"context,omitempty" mapstructure:"context,omitempty"`
88-
CreatedAt string `yaml:"created_at" json:"created_at" mapstructure:"created_at"`
89-
EncryptedDataKey string `yaml:"enc" json:"enc" mapstructure:"enc"`
90-
AwsProfile string `yaml:"aws_profile" json:"aws_profile" mapstructure:"aws_profile"`
76+
Arn string `mapstructure:"arn"`
77+
Role string `mapstructure:"role,omitempty"`
78+
Context map[string]*string `mapstructure:"context,omitempty"`
79+
CreatedAt string `mapstructure:"created_at"`
80+
EncryptedDataKey string `mapstructure:"enc"`
81+
AwsProfile string `mapstructure:"aws_profile"`
9182
}
9283

9384
type gcpkmskey struct {
94-
ResourceID string `yaml:"resource_id" json:"resource_id" mapstructure:"resource_id"`
95-
CreatedAt string `yaml:"created_at" json:"created_at" mapstructure:"created_at"`
96-
EncryptedDataKey string `yaml:"enc" json:"enc" mapstructure:"enc"`
85+
ResourceID string `mapstructure:"resource_id"`
86+
CreatedAt string `mapstructure:"created_at"`
87+
EncryptedDataKey string `mapstructure:"enc"`
9788
}
9889

9990
type vaultkey struct {
100-
VaultAddress string `yaml:"vault_address" json:"vault_address" mapstructure:"vault_address"`
101-
EnginePath string `yaml:"engine_path" json:"engine_path" mapstructure:"engine_path"`
102-
KeyName string `yaml:"key_name" json:"key_name" mapstructure:"key_name"`
103-
CreatedAt string `yaml:"created_at" json:"created_at" mapstructure:"created_at"`
104-
EncryptedDataKey string `yaml:"enc" json:"enc" mapstructure:"enc"`
91+
VaultAddress string `mapstructure:"vault_address"`
92+
EnginePath string `mapstructure:"engine_path"`
93+
KeyName string `mapstructure:"key_name"`
94+
CreatedAt string `mapstructure:"created_at"`
95+
EncryptedDataKey string `mapstructure:"enc"`
10596
}
10697

10798
type azkvkey struct {
108-
VaultURL string `yaml:"vault_url" json:"vault_url" mapstructure:"vault_url"`
109-
Name string `yaml:"name" json:"name" mapstructure:"name"`
110-
Version string `yaml:"version" json:"version" mapstructure:"version"`
111-
CreatedAt string `yaml:"created_at" json:"created_at" mapstructure:"created_at"`
112-
EncryptedDataKey string `yaml:"enc" json:"enc" mapstructure:"enc"`
99+
VaultURL string `mapstructure:"vault_url"`
100+
Name string `mapstructure:"name"`
101+
Version string `mapstructure:"version"`
102+
CreatedAt string `mapstructure:"created_at"`
103+
EncryptedDataKey string `mapstructure:"enc"`
113104
}
114105

115106
type agekey struct {
116-
Recipient string `yaml:"recipient" json:"recipient" mapstructure:"recipient"`
117-
EncryptedDataKey string `yaml:"enc" json:"enc" mapstructure:"enc"`
107+
Recipient string `mapstructure:"recipient"`
108+
EncryptedDataKey string `mapstructure:"enc"`
118109
}
119110

120111
type hckmskey struct {
121-
KeyID string `yaml:"key_id" json:"key_id" mapstructure:"key_id"`
122-
CreatedAt string `yaml:"created_at" json:"created_at" mapstructure:"created_at"`
123-
EncryptedDataKey string `yaml:"enc" json:"enc" mapstructure:"enc"`
112+
KeyID string `mapstructure:"key_id"`
113+
CreatedAt string `mapstructure:"created_at"`
114+
EncryptedDataKey string `mapstructure:"enc"`
124115
}
125116

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

0 commit comments

Comments
 (0)