-
Notifications
You must be signed in to change notification settings - Fork 130
feat(iam): creation of user as Member #3029
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Hello @giacomosirri and thank you for this PR. The guest type will disappear in the next months, and the fields you mentioned that cannot be updated will be updatable in very soon too. However, I would like to thank you for your contribution. Can you give me your Organization-id (here or on Slack Scaleway community - Cyril Scw) so that I can put a voucher on your Organization? Thanks again |
Hello @crlptl, Anyway, the organization id is: daf36079-e52c-416c-9535-d06742e48acc. Btw, I also tried to access the slack community from the link in the footer of the website, but it appears to be broken: Thank you again. |
Hello @giacomosirri, after careful consideration it happens that your approach fits well the current API state and is future proof. |
cbafdfd
to
9fcac44
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution, I made a few suggestion, feel free to tell me if you don't have time to work on this I would then make the changes myself
internal/services/iam/user.go
Outdated
@@ -140,6 +236,18 @@ func resourceIamUserUpdate(ctx context.Context, d *schema.ResourceData, m interf | |||
return diag.FromErr(err) | |||
} | |||
|
|||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this comment it should be now supported
resource.TestCheckResourceAttr("scaleway_iam_user.guest_user", "tags.#", "2"), | ||
resource.TestCheckResourceAttr("scaleway_iam_user.guest_user", "tags.0", "tf_tests"), | ||
resource.TestCheckResourceAttr("scaleway_iam_user.guest_user", "tags.1", "tests"), | ||
// The username is the same as the email for Guest users. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove comment
Hello @Gnoale, thank you for the update, that's good to hear! |
9fcac44
to
ab57ce0
Compare
3282040
to
344f1e8
Compare
@Gnoale @remyleone hello, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @giacomosirri thanks for you work, I made another review pass, it is almost good I think
I suggest we remove the ForceNew flag from the "email" field and return an error in case of a guest email update attempt.
Since guest will be deprecated
We could add a hint about this behavior in the documentation too
What do you think @remyleone @crlptl
@@ -23,20 +23,63 @@ func ResourceUser() *schema.Resource { | |||
}, | |||
SchemaVersion: 0, | |||
Schema: map[string]*schema.Schema{ | |||
"organization_id": account.OrganizationIDOptionalSchema(), | |||
// User input data | |||
"email": { | |||
Type: schema.TypeString, | |||
Required: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove ForceNew
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description: "The email of the iam user, in case of a member, this field is not editable",
}, scw.WithContext(ctx)) | ||
if err != nil { | ||
return diag.FromErr(err) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | |
} | |
if d.HasChange("email") { | |
return diag.FromErr(fmt.Errorf("The email of a guest user cannot be updated, you need to create a new user")) | |
} |
} | ||
} | ||
} else { | ||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rm comment
* For this reason, even though the IAM API supports it, the email is not considered | ||
* an updatable field here. | ||
*/ | ||
if d.HasChanges("tags", "first_name", "last_name", "phone_number", "locale") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if d.HasChanges("tags", "first_name", "last_name", "phone_number", "locale") { | |
if d.HasChanges("tags", "first_name", "last_name", "phone_number", "locale", "email") { |
FirstName: scw.StringPtr(d.Get("first_name").(string)), | ||
LastName: scw.StringPtr(d.Get("last_name").(string)), | ||
PhoneNumber: scw.StringPtr(d.Get("phone_number").(string)), | ||
Locale: scw.StringPtr(d.Get("locale").(string)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Locale: scw.StringPtr(d.Get("locale").(string)), | |
Locale: scw.StringPtr(d.Get("locale").(string)), | |
Email: scw.StringPtr(d.Get("email").(string)), |
{ | ||
Config: ` | ||
resource "scaleway_iam_user" "member_user" { | ||
email = "[email protected]" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
email = "foo@scaleway.com" | |
email = "foobar@scaleway.com" |
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckIamUserExists(tt, "scaleway_iam_user.member_user"), | ||
acctest.CheckResourceAttrUUID("scaleway_iam_user.member_user", "id"), | ||
resource.TestCheckResourceAttr("scaleway_iam_user.member_user", "email", "[email protected]"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resource.TestCheckResourceAttr("scaleway_iam_user.member_user", "email", "foo@scaleway.com"), | |
resource.TestCheckResourceAttr("scaleway_iam_user.member_user", "email", "foobar@scaleway.com"), |
This Pull Request implements the feature requested in the issue #3021