@@ -134,7 +134,6 @@ func (v *Vault) Curl(method string, path string, body []byte) (*http.Response, e
134134// If there is nothing at that path, a nil *Secret will be returned, with no
135135// error.
136136func (v * Vault ) Read (path string ) (secret * Secret , err error ) {
137- path = Canonicalize (path )
138137 path , key , version := ParsePath (path )
139138
140139 secret = NewSecret ()
@@ -190,11 +189,15 @@ func (v *Vault) List(path string) (paths []string, err error) {
190189
191190// Write takes a Secret and writes it to the Vault at the specified path.
192191func (v * Vault ) Write (path string , s * Secret ) error {
193- path = Canonicalize (path )
194- if strings . Contains ( path , ":" ) {
192+ path , key , version := ParsePath (path )
193+ if key != "" {
195194 return fmt .Errorf ("cannot write to paths in /path:key notation" )
196195 }
197196
197+ if version != 0 {
198+ return fmt .Errorf ("cannot write to paths in /path^version notation" )
199+ }
200+
198201 if s .Empty () {
199202 return v .deleteIfPresent (path , DeleteOpts {})
200203 }
@@ -207,7 +210,7 @@ func (v *Vault) Write(path string, s *Secret) error {
207210 return err
208211}
209212
210- //errIfFolder returns an error with your provided message if the given path is a folder.
213+ // errIfFolder returns an error with your provided message if the given path is a folder.
211214// Can also throw an error if contacting the backend failed, in which case that error
212215// is returned.
213216func (v * Vault ) errIfFolder (path , message string , args ... interface {}) error {
@@ -316,8 +319,8 @@ func (v *Vault) verifySecretExists(path string) error {
316319 return err
317320}
318321
319- //DeleteTree recursively deletes the leaf nodes beneath the given root until
320- //the root has no children, and then deletes that.
322+ // DeleteTree recursively deletes the leaf nodes beneath the given root until
323+ // the root has no children, and then deletes that.
321324func (v * Vault ) DeleteTree (root string , opts DeleteOpts ) error {
322325 root = Canonicalize (root )
323326
@@ -486,13 +489,13 @@ func (v *Vault) deleteSpecificKey(path string) error {
486489 return v .Write (secretPath , secret )
487490}
488491
489- //DeleteVersions marks the given versions of the given secret as deleted for
492+ // DeleteVersions marks the given versions of the given secret as deleted for
490493// a v2 backend or actually deletes it for a v1 backend.
491494func (v * Vault ) DeleteVersions (path string , versions []uint ) error {
492495 return v .client .Delete (path , & vaultkv.KVDeleteOpts {Versions : versions , V1Destroy : true })
493496}
494497
495- //DestroyVersions irrevocably destroys the given versions of the given secret
498+ // DestroyVersions irrevocably destroys the given versions of the given secret
496499func (v * Vault ) DestroyVersions (path string , versions []uint ) error {
497500 return v .client .Destroy (path , versions )
498501}
@@ -530,7 +533,7 @@ func (v *Vault) Undelete(path string) error {
530533 return v .Client ().Undelete (secret , []uint {uint (version )})
531534}
532535
533- //deleteIfPresent first checks to see if there is a Secret at the given path,
536+ // deleteIfPresent first checks to see if there is a Secret at the given path,
534537// and if so, it deletes it. Otherwise, no error is thrown
535538func (v * Vault ) deleteIfPresent (path string , opts DeleteOpts ) error {
536539 secretpath , _ , _ := ParsePath (path )
@@ -699,7 +702,7 @@ func (v *Vault) Copy(oldpath, newpath string, opts MoveCopyOpts) error {
699702 return nil
700703}
701704
702- //MoveCopyTree will recursively copy all nodes from the root to the new location.
705+ // MoveCopyTree will recursively copy all nodes from the root to the new location.
703706// This function will get confused about 'secret:key' syntax, so don't let those
704707// get routed here - they don't make sense for a recursion anyway.
705708func (v * Vault ) MoveCopyTree (oldRoot , newRoot string , f func (string , string , MoveCopyOpts ) error , opts MoveCopyOpts ) error {
0 commit comments