Skip to content
This repository was archived by the owner on Mar 15, 2024. It is now read-only.

Commit a26f358

Browse files
author
Michael Weber
committed
renamed roles parameter allowed_node_types to allowed_server_roles
To conform with the returned responses from the `search/distributed/peers`.
1 parent 22f6aa8 commit a26f358

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

path_creds_create.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,15 @@ func findNode(nodeFQDN string, hosts []splunk.ServerInfoEntry, roleConfig *roleC
129129
// check if node_fqdn is in either of HostFQDN or Host. User might not always the FQDN on the cli input
130130
if host.Content.HostFQDN == nodeFQDN || host.Content.Host == nodeFQDN {
131131
// Return true if the requested node type is allowed
132-
if strutil.StrListContains(roleConfig.AllowedNodeTypes, "*") {
132+
if strutil.StrListContains(roleConfig.AllowedServerRoles, "*") {
133133
return true, nil
134134
}
135135
for _, role := range host.Content.Roles {
136-
if strutil.StrListContainsGlob(roleConfig.AllowedNodeTypes, role) {
136+
if strutil.StrListContainsGlob(roleConfig.AllowedServerRoles, role) {
137137
return true, nil
138138
}
139139
}
140-
return false, fmt.Errorf("host %q does not have an allowed node type", nodeFQDN)
140+
return false, fmt.Errorf("host %q does not have any of the allowed server roles: %q", nodeFQDN, roleConfig.AllowedServerRoles)
141141
}
142142
}
143143
return false, fmt.Errorf("host %q not found", nodeFQDN)

path_roles.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func (b *backend) pathRoles() *framework.Path {
3535
Type: framework.TypeCommaStringSlice,
3636
Description: "Comma-separated string or list of Splunk roles.",
3737
},
38-
"allowed_node_types": &framework.FieldSchema{
38+
"allowed_server_roles": &framework.FieldSchema{
3939
Type: framework.TypeCommaStringSlice,
4040
Description: trimIndent(`
4141
Comma-separated string or array of node type (glob) patterns that are allowed
@@ -122,8 +122,8 @@ func (b *backend) rolesWriteHandler(ctx context.Context, req *logical.Request, d
122122
if maxTTLRaw, ok := getValue(data, req.Operation, "max_ttl"); ok {
123123
role.MaxTTL = time.Duration(maxTTLRaw.(int)) * time.Second
124124
}
125-
if allowed_node_types, ok := getValue(data, req.Operation, "allowed_node_types"); ok {
126-
role.AllowedNodeTypes = allowed_node_types.([]string)
125+
if allowedServerRoles, ok := getValue(data, req.Operation, "allowed_server_roles"); ok {
126+
role.AllowedServerRoles = allowedServerRoles.([]string)
127127
}
128128
role.PasswordSpec = DefaultPasswordSpec() // XXX make configurable
129129

role.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import (
1111
)
1212

1313
type roleConfig struct {
14-
Connection string `json:"connection" structs:"connection"`
15-
DefaultTTL time.Duration `json:"default_ttl" structs:"default_ttl"`
16-
MaxTTL time.Duration `json:"max_ttl" structs:"max_ttl"`
17-
AllowedNodeTypes []string `json:"allowed_node_types" structs:"allowed_node_types"`
18-
PasswordSpec *PasswordSpec `json:"password_spec" structs:"password_spec"`
14+
Connection string `json:"connection" structs:"connection"`
15+
DefaultTTL time.Duration `json:"default_ttl" structs:"default_ttl"`
16+
MaxTTL time.Duration `json:"max_ttl" structs:"max_ttl"`
17+
AllowedServerRoles []string `json:"allowed_server_roles" structs:"allowed_server_roles"`
18+
PasswordSpec *PasswordSpec `json:"password_spec" structs:"password_spec"`
1919

2020
// Splunk user attributes
2121
Roles []string `json:"roles" structs:"roles"`

0 commit comments

Comments
 (0)