diff --git a/cmd/sops/edit.go b/cmd/sops/edit.go index d67c1054e..7a2255b2e 100644 --- a/cmd/sops/edit.go +++ b/cmd/sops/edit.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "go.mozilla.org/sops/stores/ini" "io/ioutil" "os" @@ -87,6 +88,12 @@ func editExample(opts editExampleOpts) ([]byte, error) { if _, ok := opts.InputStore.(*json.BinaryStore); ok { // Get the value under the first key of the first (possibly only) doc fileBytes = []byte(exampleTree.Branches[0][0].Value.(string)) + } else if _, ok := opts.InputStore.(*ini.Store); ok { + var err error + fileBytes, err = opts.InputStore.EmitPlainFile(ini.ExampleTree.Branches) + if err != nil { + return nil, err + } } else { var err error fileBytes, err = opts.InputStore.EmitPlainFile(exampleTree.Branches) diff --git a/example.ini b/example.ini new file mode 100644 index 000000000..e54a166e3 --- /dev/null +++ b/example.ini @@ -0,0 +1,28 @@ +; ENC[AES256_GCM,data:40al3asZ8L1+ajzMBp/0sHai9UNP3IoqkLIPNhuuMxs8Cg==,iv:2lqF+4RJTS9wSgjadUEYOyMVbe6eIOOFNIb0jgjdmK8=,tag:PkrPbykEN0ngUhP+ajfLKg==,type:comment] +[name] +firstName = ENC[AES256_GCM,data:30Q/XQ==,iv:nxqUz6dmPjVdXoRrtw/CGOH1HqFYyLmocbfikqzwf9o=,tag:3sIh386PIoTJ3XBu8T2Pww==,type:str] +lastName = ENC[AES256_GCM,data:W1hTh14=,iv:5M3RqShfVjkOatrGj4Z+e6BtOfQK6hZxWdm6IfkwzcY=,tag:zJBc/5O+rELdKu7Ja0IHuQ==,type:str] +age = ENC[AES256_GCM,data:ulhPjA==,iv:0ylri5mup2gAfT3LEyMdoi2orn/hfTvFs0KOzKwN8Ds=,tag:UVuBXcN1vfwbWH9md0K32A==,type:str] + +[address] +city = ENC[AES256_GCM,data:0+RVjaLGpys=,iv:7XomjWqHdmEbUQ4H9RG0L4kpmjnL0ROEP/bj0u9t0io=,tag:Z57atgaPDw1S51H6JfvcGA==,type:str] +postalCode = ENC[AES256_GCM,data:aPMpTW00LR63Zw==,iv:RiTxsg7vYIlaN41O3ESL/IKLwPi5VtsrepN0RdJrRmQ=,tag:gF4W5LmZ9gsrcBXxwrTPrA==,type:str] +state = ENC[AES256_GCM,data:xg8=,iv:6nvhxItys13r39+ktd5wd53T6UmgojeuqRorrM8bPHg=,tag:Osc5sC4LsesS1wZwAUt5tw==,type:str] +streetAddress = ENC[AES256_GCM,data:DXQclrCghMapHiqkow==,iv:aqc0JH4vadJWp9xwF2kch7xYuZ5bYA8yR9L7An6x2q4=,tag:XFj1rCYSSnwZXCh5An0TAA==,type:str] + +[phoneNumbers] +home = ENC[AES256_GCM,data:uD2247keEsbFI0ub,iv:yVWbL4wF6h3FXWMToZJoKy4Unx/Mp7dDbrT8zxJnZtE=,tag:6zR/ufgemmNx5/ySNnD/Aw==,type:str] +office = ENC[AES256_GCM,data:knmFCdTtHhE0pt5q,iv:dYMzj5TX0G3g0ZpGkB+CvR2XEoPDAwu1SSaY1R/sCYM=,tag:52+8cwq7s4Jloit/lYorOA==,type:str] + +[not private] +notsecret_unencrypted = hi there! + +[sops] +lastmodified = 2019-01-11T05:24:42Z +pgp__list_0__map_created_at = 2019-01-11T05:24:42Z +pgp__list_0__map_enc = -----BEGIN PGP MESSAGE-----\n\nwYwDEEVDpnzXnMABBACb46+yRjeFaLKegY3FGypZyE2XXiVUTEEL3iOu/gjN5TOT\n+EzgNKCxT0B+4mhG6/BSkxN6D3iU9D7ABeC2a1OO2I177dH5Mu9vG0RhPmxFQoYC\nyvqW8HnYqy0SnX/BaLrUlAOutFCpnNcwCHrqjX5u2w2f/nq47ZODGp3QbHEDxdLg\nAeT+v1BMYMoCuq5GD5bBeAv04WVv4JjgweEQFuAq4tkaBRDg9eXCIZxGmpuMkYHC\nsPEuuGLX22TrU3Nhq23xMiyTamf0qOCh5FDCZ5M2BMBTtwVneMq0TO/idTFumeFk\nXwA=\n=Lrn7\n-----END PGP MESSAGE----- +unencrypted_suffix = _unencrypted +version = 3.2.0 +pgp__list_0__map_fp = 1022470DE3F0BC54BC6AB62DE05550BC07FB1A0A +mac = ENC[AES256_GCM,data:P0QMbP0PD9zTGUbGw4gdyIXP5/RGOnWqplcXTvJyIYDlZLENNGJTSqb02OpZJ7iCCHi/LfzX0dQ0uacCHVbrgh1uWwgaPlvplJ++WVEpF7CHFplCPj4gvcKk2Jh/tNmQLov1VrfbzdfZf/epkiL1ie15+mG4gYiJEkH6zR24t7k=,iv:YLZu6BIN/8LaYR84m3dNJwMFnmyaZptOhYCH0Hwckrk=,tag:ayAkLDan52fEbliNFbhUGw==,type:str] + diff --git a/stores/ini/store.go b/stores/ini/store.go index 83e0664cb..1407e87f5 100644 --- a/stores/ini/store.go +++ b/stores/ini/store.go @@ -14,6 +14,30 @@ import ( "gopkg.in/ini.v1" ) +var ExampleTree = sops.Tree{ + Branches: sops.TreeBranches{ + sops.TreeBranch{ + sops.TreeItem{ + Key: "Welcome!", + Value: sops.TreeBranch{ + sops.TreeItem{ + Key: sops.Comment{Value: "This is an example ini file."}, + Value: nil, + }, + sops.TreeItem{ + Key: "hello", + Value: "Welcome to SOPS! Edit this file as you please!", + }, + sops.TreeItem{ + Key: "example_key", + Value: "example_value", + }, + }, + }, + }, + }, +} + // Store handles storage of ini data. type Store struct { }