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:
1 parent
4e8e069c9c
commit
35d1df7388
72 files changed
+510
-475
No files matched your search
@@ -14,7 +14,7 @@ type LdapManagedGroupAttributes struct {
|
||||
GroupNames []string `json:"group_names,omitempty"`
|
||||
}
|
||||
|
||||
func AttributesMapToLdapManagedGroupAttributes(in map[string]interface{}) (*LdapManagedGroupAttributes, error) {
|
||||
func AttributesMapToLdapManagedGroupAttributes(in map[string]any) (*LdapManagedGroupAttributes, error) {
|
||||
if in == nil {
|
||||
return nil, fmt.Errorf("nil input map")
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ type ManagedGroupDeleteResult struct {
|
||||
}
|
||||
|
||||
// GetItem will always be nil for ManagedGroupDeleteResult
|
||||
func (n ManagedGroupDeleteResult) GetItem() interface{} {
|
||||
func (n ManagedGroupDeleteResult) GetItem() any {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ type OidcManagedGroupAttributes struct {
|
||||
Filter string `json:"filter,omitempty"`
|
||||
}
|
||||
|
||||
func AttributesMapToOidcManagedGroupAttributes(in map[string]interface{}) (*OidcManagedGroupAttributes, error) {
|
||||
func AttributesMapToOidcManagedGroupAttributes(in map[string]any) (*OidcManagedGroupAttributes, error) {
|
||||
if in == nil {
|
||||
return nil, fmt.Errorf("nil input map")
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,9 +118,9 @@ func WithOidcManagedGroupFilter(inFilter 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["filter"] = inFilter
|
||||
o.postMap["attributes"] = val
|
||||
}
|
||||
@@ -130,9 +130,9 @@ func WithLdapManagedGroupGroupNames(inGroupNames []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["group_names"] = inGroupNames
|
||||
o.postMap["attributes"] = val
|
||||
}
|
||||
@@ -142,9 +142,9 @@ func DefaultLdapManagedGroupGroupNames() 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["group_names"] = nil
|
||||
o.postMap["attributes"] = val
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user