Two fixes in our Go API code: (#5066)

* Replace `interface{}` with `any`
* For options that are bools, don't always set true; set to the actual
  value passed in (some options already behaved this way, but they all
  should)
This commit is contained in:
Jeff Mitchell authored and GitHub committed 2024-09-04 11:40:43 -04:00
1 parent 4e8e069c9c
commit 35d1df7388
72 files changed
+510 -475

No files matched your search

+1 -1
View File
@@ -52,7 +52,7 @@ type CredentialDeleteResult struct {
}
// GetItem will always be nil for CredentialDeleteResult
func (n CredentialDeleteResult) GetItem() interface{} {
func (n CredentialDeleteResult) GetItem() any {
return nil
}
+1 -1
View File
@@ -15,7 +15,7 @@ type JsonAttributes struct {
ObjectHmac string `json:"object_hmac,omitempty"`
}
func AttributesMapToJsonAttributes(in map[string]interface{}) (*JsonAttributes, error) {
func AttributesMapToJsonAttributes(in map[string]any) (*JsonAttributes, error) {
if in == nil {
return nil, fmt.Errorf("nil input map")
}
+17 -17
View File
@@ -20,7 +20,7 @@ import (
type Option func(*options)
type options struct {
postMap map[string]interface{}
postMap map[string]any
queryMap map[string]string
withAutomaticVersioning bool
withSkipCurlOutput bool
@@ -30,7 +30,7 @@ type options struct {
func getDefaultOptions() options {
return options{
postMap: make(map[string]interface{}),
postMap: make(map[string]any),
queryMap: make(map[string]string),
}
}
@@ -69,7 +69,7 @@ func WithAutomaticVersioning(enable bool) Option {
// Useful for when we need to look up versions.
func WithSkipCurlOutput(skip bool) Option {
return func(o *options) {
o.withSkipCurlOutput = true
o.withSkipCurlOutput = skip
}
}
@@ -130,9 +130,9 @@ func WithJsonCredentialObject(inObject map[string]interface{}) Option {
return func(o *options) {
raw, ok := o.postMap["attributes"]
if !ok {
raw = interface{}(map[string]interface{}{})
raw = any(map[string]any{})
}
val := raw.(map[string]interface{})
val := raw.(map[string]any)
val["object"] = inObject
o.postMap["attributes"] = val
}
@@ -142,9 +142,9 @@ func WithUsernamePasswordCredentialPassword(inPassword string) Option {
return func(o *options) {
raw, ok := o.postMap["attributes"]
if !ok {
raw = interface{}(map[string]interface{}{})
raw = any(map[string]any{})
}
val := raw.(map[string]interface{})
val := raw.(map[string]any)
val["password"] = inPassword
o.postMap["attributes"] = val
}
@@ -154,9 +154,9 @@ func WithSshPrivateKeyCredentialPrivateKey(inPrivateKey string) Option {
return func(o *options) {
raw, ok := o.postMap["attributes"]
if !ok {
raw = interface{}(map[string]interface{}{})
raw = any(map[string]any{})
}
val := raw.(map[string]interface{})
val := raw.(map[string]any)
val["private_key"] = inPrivateKey
o.postMap["attributes"] = val
}
@@ -166,9 +166,9 @@ func WithSshPrivateKeyCredentialPrivateKeyPassphrase(inPrivateKeyPassphrase stri
return func(o *options) {
raw, ok := o.postMap["attributes"]
if !ok {
raw = interface{}(map[string]interface{}{})
raw = any(map[string]any{})
}
val := raw.(map[string]interface{})
val := raw.(map[string]any)
val["private_key_passphrase"] = inPrivateKeyPassphrase
o.postMap["attributes"] = val
}
@@ -178,9 +178,9 @@ func DefaultSshPrivateKeyCredentialPrivateKeyPassphrase() Option {
return func(o *options) {
raw, ok := o.postMap["attributes"]
if !ok {
raw = interface{}(map[string]interface{}{})
raw = any(map[string]any{})
}
val := raw.(map[string]interface{})
val := raw.(map[string]any)
val["private_key_passphrase"] = nil
o.postMap["attributes"] = val
}
@@ -190,9 +190,9 @@ func WithSshPrivateKeyCredentialUsername(inUsername string) Option {
return func(o *options) {
raw, ok := o.postMap["attributes"]
if !ok {
raw = interface{}(map[string]interface{}{})
raw = any(map[string]any{})
}
val := raw.(map[string]interface{})
val := raw.(map[string]any)
val["username"] = inUsername
o.postMap["attributes"] = val
}
@@ -202,9 +202,9 @@ func WithUsernamePasswordCredentialUsername(inUsername string) Option {
return func(o *options) {
raw, ok := o.postMap["attributes"]
if !ok {
raw = interface{}(map[string]interface{}{})
raw = any(map[string]any{})
}
val := raw.(map[string]interface{})
val := raw.(map[string]any)
val["username"] = inUsername
o.postMap["attributes"] = val
}
@@ -18,7 +18,7 @@ type SshPrivateKeyAttributes struct {
PrivateKeyPassphraseHmac string `json:"private_key_passphrase_hmac,omitempty"`
}
func AttributesMapToSshPrivateKeyAttributes(in map[string]interface{}) (*SshPrivateKeyAttributes, error) {
func AttributesMapToSshPrivateKeyAttributes(in map[string]any) (*SshPrivateKeyAttributes, error) {
if in == nil {
return nil, fmt.Errorf("nil input map")
}
@@ -16,7 +16,7 @@ type UsernamePasswordAttributes struct {
PasswordHmac string `json:"password_hmac,omitempty"`
}
func AttributesMapToUsernamePasswordAttributes(in map[string]interface{}) (*UsernamePasswordAttributes, error) {
func AttributesMapToUsernamePasswordAttributes(in map[string]any) (*UsernamePasswordAttributes, error) {
if in == nil {
return nil, fmt.Errorf("nil input map")
}