-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
1,053 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
--- | ||
# Copyright (c) 2023 Dell Inc., or its subsidiaries. All Rights Reserved. | ||
# | ||
# Licensed under the Mozilla Public License Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://mozilla.org/MPL/2.0/ | ||
# | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
title: "powerscale_user data source" | ||
linkTitle: "powerscale_user" | ||
page_title: "powerscale_user Data Source - terraform-provider-powerscale" | ||
subcategory: "" | ||
description: |- | ||
Data source for reading Users in PowerScale cluster. | ||
--- | ||
|
||
# powerscale_user (Data Source) | ||
|
||
Data source for reading Users in PowerScale cluster. | ||
|
||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Optional | ||
|
||
- `filter` (Block, Optional) (see [below for nested schema](#nestedblock--filter)) | ||
|
||
### Read-Only | ||
|
||
- `id` (String) Unique identifier of the user instance. | ||
- `users` (Attributes List) List of users. (see [below for nested schema](#nestedatt--users)) | ||
|
||
<a id="nestedblock--filter"></a> | ||
### Nested Schema for `filter` | ||
|
||
Optional: | ||
|
||
- `cached` (Boolean) If true, only return cached objects. | ||
- `domain` (String) Filter users by domain. | ||
- `member_of` (Boolean) Enumerate all users that a group is a member of. | ||
- `name_prefix` (String) Filter users by name prefix. | ||
- `names` (Attributes List) List of user identity. (see [below for nested schema](#nestedatt--filter--names)) | ||
- `provider` (String) Filter users by provider. | ||
- `resolve_names` (Boolean) Resolve names of personas. | ||
- `zone` (String) Filter users by zone. | ||
|
||
<a id="nestedatt--filter--names"></a> | ||
### Nested Schema for `filter.names` | ||
|
||
Optional: | ||
|
||
- `name` (String) Specifies a user name. | ||
- `uid` (Number) Specifies a numeric user identifier. | ||
|
||
|
||
|
||
<a id="nestedatt--users"></a> | ||
### Nested Schema for `users` | ||
|
||
Optional: | ||
|
||
- `dn` (String) Specifies a principal name for the user. | ||
- `dns_domain` (String) Specifies the DNS domain. | ||
- `domain` (String) Specifies the domain that the object is part of. | ||
- `email` (String) Specifies an email address. | ||
- `enabled` (Boolean) If true, the authenticated user is enabled. | ||
- `expired` (Boolean) If true, the authenticated user has expired. | ||
- `expiry` (Number) Specifies the Unix Epoch time at which the authenticated user will expire. | ||
- `gecos` (String) Specifies the GECOS value, which is usually the full name. | ||
- `generated_gid` (Boolean) If true, the GID was generated. | ||
- `generated_uid` (Boolean) If true, the UID was generated. | ||
- `generated_upn` (Boolean) If true, the UPN was generated. | ||
- `gid` (String) Specifies a group identifier. | ||
- `home_directory` (String) Specifies a home directory for the user. | ||
- `id` (String) Specifies the user ID. | ||
- `locked` (Boolean) If true, indicates that the account is locked. | ||
- `max_password_age` (Number) Specifies the maximum time in seconds allowed before the password expires. | ||
- `name` (String) Specifies a user name. | ||
- `password_expired` (Boolean) If true, the password has expired. | ||
- `password_expires` (Boolean) If true, the password is allowed to expire. | ||
- `password_expiry` (Number) Specifies the time in Unix Epoch seconds that the password will expire. | ||
- `password_last_set` (Number) Specifies the last time the password was set. | ||
- `primary_group_sid` (String) Specifies the persona of the primary group. | ||
- `prompt_password_change` (Boolean) If true, Prompts the user to change their password at the next login. | ||
- `provider` (String) Specifies the authentication provider that the object belongs to. | ||
- `sam_account_name` (String) Specifies a user name. | ||
- `shell` (String) Specifies a path to the shell for the user. | ||
- `sid` (String) Specifies a security identifier. | ||
- `type` (String) Specifies the object type. | ||
- `uid` (String) Specifies a user identifier. | ||
- `upn` (String) Specifies a principal name for the user. | ||
- `user_can_change_password` (Boolean) Specifies whether the password for the user can be changed. | ||
|
||
Read-Only: | ||
|
||
- `roles` (List of String) List of roles. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
Copyright (c) 2023 Dell Inc., or its subsidiaries. All Rights Reserved. | ||
Licensed under the Mozilla Public License Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://mozilla.org/MPL/2.0/ | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
data "powerscale_user" "test_user" { | ||
filter { | ||
names = [ | ||
# { | ||
# uid = 0 | ||
# }, | ||
# { | ||
# name = "admin" | ||
# }, | ||
{ | ||
name = "tfaccUserDatasource" | ||
uid = 10000 | ||
} | ||
] | ||
cached = false | ||
name_prefix = "tfacc" | ||
resolve_names = false | ||
member_of = false | ||
# domain = "testDomain" | ||
# zone = "testZone" | ||
# provider = "testProvider" | ||
} | ||
} | ||
|
||
output "powerscale_user_filter" { | ||
value = data.powerscale_user.test_user | ||
} | ||
|
||
data "powerscale_user" "test_all_user" { | ||
} | ||
|
||
output "powerscale_user_all" { | ||
value = data.powerscale_user.test_all_user | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
Copyright (c) 2023 Dell Inc., or its subsidiaries. All Rights Reserved. | ||
Licensed under the Mozilla Public License Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://mozilla.org/MPL/2.0/ | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
terraform { | ||
required_providers { | ||
powerscale = { | ||
source = "registry.terraform.io/dell/powerscale" | ||
} | ||
} | ||
} | ||
|
||
provider "powerscale" { | ||
username = var.username | ||
password = var.password | ||
endpoint = var.endpoint | ||
insecure = var.insecure | ||
group = var.group | ||
volume_path = var.volume_path | ||
volume_path_permissions = var.volume_path_permissions | ||
ignore_unresolvable_hosts = var.ignore_unresolvable_hosts | ||
auth_type = var.auth_type | ||
verbose_logging = var.verbose_logging | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
Copyright (c) 2023 Dell Inc., or its subsidiaries. All Rights Reserved. | ||
Licensed under the Mozilla Public License Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://mozilla.org/MPL/2.0/ | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package helper | ||
|
||
import ( | ||
powerscale "dell/powerscale-go-client" | ||
"terraform-provider-powerscale/powerscale/models" | ||
|
||
"github.com/hashicorp/terraform-plugin-framework/attr" | ||
"github.com/hashicorp/terraform-plugin-framework/types" | ||
) | ||
|
||
// UpdateUserDataSourceState updates datasource state. | ||
func UpdateUserDataSourceState(userState *models.UserDataSourceModel, userResponse []powerscale.V1MappingUsersLookupMappingItemUser, roles []powerscale.V1AuthRoleExtended) { | ||
for _, user := range userResponse { | ||
var model models.UserModel | ||
UpdateUserState(&model, user) | ||
|
||
var roleAttrs []attr.Value | ||
for _, r := range roles { | ||
for _, m := range r.Members { | ||
if *m.Id == *user.Uid.Id { | ||
roleAttrs = append(roleAttrs, types.StringValue(r.Name)) | ||
} | ||
} | ||
} | ||
model.Roles, _ = types.ListValue(types.StringType, roleAttrs) | ||
userState.Users = append(userState.Users, model) | ||
} | ||
} | ||
|
||
// UpdateUserState updates user state. | ||
func UpdateUserState(model *models.UserModel, user powerscale.V1MappingUsersLookupMappingItemUser) { | ||
|
||
model.Dn = types.StringValue(user.Dn) | ||
model.DNSDomain = types.StringValue(user.DnsDomain) | ||
model.Domain = types.StringValue(user.Domain) | ||
model.Email = types.StringValue(user.Email) | ||
model.Gecos = types.StringValue(user.Gecos) | ||
model.HomeDirectory = types.StringValue(user.HomeDirectory) | ||
model.ID = types.StringValue(user.Id) | ||
model.Name = types.StringValue(user.Name) | ||
model.Provider = types.StringValue(user.Provider) | ||
model.SamAccountName = types.StringValue(user.SamAccountName) | ||
model.Shell = types.StringValue(user.Shell) | ||
model.Type = types.StringValue(user.Type) | ||
model.Upn = types.StringValue(user.Upn) | ||
if user.Gid.Id != nil { | ||
model.GID = types.StringValue(*user.Gid.Id) | ||
} | ||
if user.PrimaryGroupSid.Id != nil { | ||
model.PrimaryGroupSID = types.StringValue(*user.PrimaryGroupSid.Id) | ||
} | ||
if user.Sid.Id != nil { | ||
model.SID = types.StringValue(*user.Sid.Id) | ||
} | ||
if user.Uid.Id != nil { | ||
model.UID = types.StringValue(*user.Uid.Id) | ||
} | ||
|
||
model.Enabled = types.BoolValue(user.Enabled) | ||
model.Expired = types.BoolValue(user.Expired) | ||
model.GeneratedGID = types.BoolValue(user.GeneratedGid) | ||
model.GeneratedUID = types.BoolValue(user.GeneratedUid) | ||
model.GeneratedUpn = types.BoolValue(user.GeneratedUpn) | ||
model.Locked = types.BoolValue(user.Locked) | ||
model.PasswordExpired = types.BoolValue(user.PasswordExpired) | ||
model.PasswordExpires = types.BoolValue(user.PasswordExpires) | ||
model.PromptPasswordChange = types.BoolValue(user.PromptPasswordChange) | ||
model.UserCanChangePassword = types.BoolValue(user.UserCanChangePassword) | ||
|
||
model.Expiry = types.Int64Value(int64(user.Expiry)) | ||
model.MaxPasswordAge = types.Int64Value(int64(user.MaxPasswordAge)) | ||
model.PasswordExpiry = types.Int64Value(int64(user.PasswordExpiry)) | ||
model.PasswordLastSet = types.Int64Value(int64(user.PasswordLastSet)) | ||
} |
Oops, something went wrong.