diff --git a/internal/cmd/kvm/crtentry.go b/internal/cmd/kvm/crtentry.go index e6b974d3e..189d1a8c7 100644 --- a/internal/cmd/kvm/crtentry.go +++ b/internal/cmd/kvm/crtentry.go @@ -40,6 +40,7 @@ var CreateEntryCmd = &cobra.Command{ }, RunE: func(cmd *cobra.Command, args []string) (err error) { cmd.SilenceUsage = true + value = getKVMString(value) _, err = kvm.CreateEntry(proxyName, mapName, keyName, []byte(value)) return }, diff --git a/internal/cmd/kvm/entries.go b/internal/cmd/kvm/entries.go index acb9e9291..5bd4595bc 100644 --- a/internal/cmd/kvm/entries.go +++ b/internal/cmd/kvm/entries.go @@ -15,6 +15,9 @@ package kvm import ( + "fmt" + "strconv" + "github.com/spf13/cobra" ) @@ -36,3 +39,16 @@ func init() { EntryCmd.AddCommand(ImpEntryCmd) EntryCmd.AddCommand(UpdateEntryCmd) } + +func getKVMString(value string) string { + var err error + // convert any boolean, float or integer to string + if _, err = strconv.ParseBool(value); err == nil { + value = fmt.Sprintf("\"%s\"", value) + } else if _, err = strconv.ParseInt(value, 10, 0); err == nil { + value = fmt.Sprintf("\"%s\"", value) + } else if _, err = strconv.ParseFloat(value, 0); err == nil { + value = fmt.Sprintf("\"%s\"", value) + } + return value +} diff --git a/internal/cmd/kvm/updentry.go b/internal/cmd/kvm/updentry.go index ea338f0e0..a32a5dd0d 100644 --- a/internal/cmd/kvm/updentry.go +++ b/internal/cmd/kvm/updentry.go @@ -40,6 +40,7 @@ var UpdateEntryCmd = &cobra.Command{ }, RunE: func(cmd *cobra.Command, args []string) (err error) { cmd.SilenceUsage = true + value = getKVMString(value) _, err = kvm.UpdateEntry(proxyName, mapName, keyName, []byte(value)) return },