Skip to content

Commit

Permalink
Improved support on versioned KV engines in kv.ReadSecret()
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanfrancoisgratton committed Aug 31, 2024
1 parent 4271b13 commit a32b0a9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion current_package_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.9
0.1.11
10 changes: 5 additions & 5 deletions kv/kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"strings"
)

// getEngineVersion determines the KV engine version for the given path
func (km *KVManager) getEngineVersion(path string) (int, *cerr.CustomError) {
// GetEngineVersion determines the KV engine version for the given path
func (km *KVManager) GetEngineVersion(path string) (int, *cerr.CustomError) {
mounts, err := km.client.Sys().ListMounts()
if err != nil {
return 0, &cerr.CustomError{Title: "Unable to list mounts", Message: err.Error()}
Expand All @@ -39,7 +39,7 @@ func (km *KVManager) getEngineVersion(path string) (int, *cerr.CustomError) {

// DeleteSecret deletes a secret from the KV engine at the given path
func (km *KVManager) DeleteSecret(path string) *cerr.CustomError {
version, ce := km.getEngineVersion(path)
version, ce := km.GetEngineVersion(path)
if ce != nil {
return ce
}
Expand All @@ -58,7 +58,7 @@ func (km *KVManager) DeleteSecret(path string) *cerr.CustomError {

// ListSecrets lists the secrets at the given path
func (km *KVManager) ListSecrets(path string) ([]string, *cerr.CustomError) {
version, ce := km.getEngineVersion(path)
version, ce := km.GetEngineVersion(path)
if ce != nil {
return nil, ce
}
Expand Down Expand Up @@ -91,7 +91,7 @@ func (km *KVManager) ListSecrets(path string) ([]string, *cerr.CustomError) {
}

func (km *KVManager) GetLatestVersion(path string) (int, *cerr.CustomError) {
engineVersion, err := km.getEngineVersion(path)
engineVersion, err := km.GetEngineVersion(path)
if err != nil {
return 0, err
}
Expand Down
6 changes: 3 additions & 3 deletions kv/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

// ReadSecret reads a secret from the KV engine at the given path
//func (km *KVManager) ReadSecret(path, field string) (interface{}, *cerr.CustomError) {
// engineVersion, err := km.getEngineVersion(path)
// engineVersion, err := km.GetEngineVersion(path)
// var nErr error
// if err != nil {
// return nil, err
Expand Down Expand Up @@ -43,11 +43,11 @@ import (
//}

func (km *KVManager) ReadSecret(path, field string, version int) (interface{}, *cerr.CustomError) {
var cErr *cerr.CustomError
//var cErr *cerr.CustomError
var secret *api.Secret
var err error

engineVersion, cErr := km.getEngineVersion(path)
engineVersion, cErr := km.GetEngineVersion(path)
if cErr != nil {
return nil, cErr
}
Expand Down
2 changes: 1 addition & 1 deletion kv/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import cerr "github.com/jeanfrancoisgratton/customError"
// WriteSecret writes a secret to the KV engine at the given path
func (km *KVManager) WriteSecret(path, field string, value interface{}) *cerr.CustomError {
var nErr error
engineVersion, err := km.getEngineVersion(path)
engineVersion, err := km.GetEngineVersion(path)
if err != nil {
return err
}
Expand Down

0 comments on commit a32b0a9

Please sign in to comment.