Skip to content

Commit

Permalink
fixed user-invite issue (IBM-Cloud#1114)
Browse files Browse the repository at this point in the history
  • Loading branch information
Anil-CM committed Feb 25, 2020
1 parent 58d18ad commit 9a774f3
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 24 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.12

require (
github.com/Bowery/prompt v0.0.0-20190916142128-fa8279994f75 // indirect
github.com/IBM-Cloud/bluemix-go v0.0.0-20200221095222-69e3682d6f5b
github.com/IBM-Cloud/bluemix-go v0.0.0-20200225052022-0d5220c9f2ba
github.com/IBM-Cloud/power-go-client v0.0.0-00010101000000-000000000000
github.com/IBM/ibm-cos-sdk-go v1.2.0
github.com/IBM/keyprotect-go-client v0.3.2
Expand Down Expand Up @@ -50,7 +50,7 @@ require (
github.com/softlayer/softlayer-go v0.0.0-20190814165317-b9062a914a22
github.com/stretchr/testify v1.4.0 // indirect
github.ibm.com/Bluemix/riaas-go-client v0.0.0-20191018070922-afd27ac04d4f
golang.org/x/tools v0.0.0-20200204005449-35ac94b00d9e // indirect
golang.org/x/tools v0.0.0-20200225022059-a0ec867d517c // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce // indirect
)
Expand Down
8 changes: 6 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ github.com/IBM-Cloud/bluemix-go v0.0.0-20200131055858-778531c8c923 h1:ZVA8uE2ca3
github.com/IBM-Cloud/bluemix-go v0.0.0-20200131055858-778531c8c923/go.mod h1:gPJbH1etcDj7qS/hBRiLuYW9CY0bRcostSKusa51xR0=
github.com/IBM-Cloud/bluemix-go v0.0.0-20200131101958-825d126550e4 h1:SvzuJKIreVsYR7aYhj1LAmigp8CK/XgxCLVI+bB+nAM=
github.com/IBM-Cloud/bluemix-go v0.0.0-20200131101958-825d126550e4/go.mod h1:gPJbH1etcDj7qS/hBRiLuYW9CY0bRcostSKusa51xR0=
github.com/IBM-Cloud/bluemix-go v0.0.0-20200221095222-69e3682d6f5b h1:nqvojaTNFdlpNxI9UnKP1GAkcaLgLCx2E59c1UkYOck=
github.com/IBM-Cloud/bluemix-go v0.0.0-20200221095222-69e3682d6f5b/go.mod h1:gPJbH1etcDj7qS/hBRiLuYW9CY0bRcostSKusa51xR0=
github.com/IBM-Cloud/bluemix-go v0.0.0-20200225052022-0d5220c9f2ba h1:w203mfjLYpOrXP9A+uVncqx/fTnErv+pL9DxhSwkM2U=
github.com/IBM-Cloud/bluemix-go v0.0.0-20200225052022-0d5220c9f2ba/go.mod h1:gPJbH1etcDj7qS/hBRiLuYW9CY0bRcostSKusa51xR0=
github.com/IBM/ibm-cos-sdk-go v1.2.0 h1:oJG2eWmAhmz3XAkQLsmQweT7hmxoM3jKQkwLBZz6b5o=
github.com/IBM/ibm-cos-sdk-go v1.2.0/go.mod h1:YLBAYobEA8bD27P7xpMwSQeNQu6W3DNBtBComXrRzRY=
github.com/IBM/keyprotect-go-client v0.3.2 h1:JmGkHQEAJ9VWsKglc474Ahg/f0FZaRZ0X+3clDdTX6A=
Expand Down Expand Up @@ -539,6 +539,10 @@ golang.org/x/tools v0.0.0-20200128002243-345141a36859 h1:xIszjAtlVeHg9hhv6Zhntvw
golang.org/x/tools v0.0.0-20200128002243-345141a36859/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200204005449-35ac94b00d9e h1:o1E/dn6ydYwYuZkF+6kaoS6ON5TokWgL24pxcgxd5MM=
golang.org/x/tools v0.0.0-20200204005449-35ac94b00d9e/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200221224223-e1da425f72fd h1:hHkvGJK23seRCflePJnVa9IMv8fsuavSCWKd11kDQFs=
golang.org/x/tools v0.0.0-20200221224223-e1da425f72fd/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200225022059-a0ec867d517c h1:cmkqWf0jTLsPn3dn28dkzCF+MoDvuZS7pTwHwGmkqiU=
golang.org/x/tools v0.0.0-20200225022059-a0ec867d517c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
Expand Down
43 changes: 29 additions & 14 deletions ibm/resource_ibm_iam_user_invite.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,17 +318,25 @@ func resourceIBMIAMInviteUsers(d *schema.ResourceData, meta interface{}) error {
}
}

infraPermissions := getInfraPermissions(d, meta)
inviteUserPayload := v2.UserInvite{}
log.Println(inviteUserPayload)
inviteUserPayload.Users = users
if len(accessGroups) != 0 {
inviteUserPayload.AccessGroup = accessGroups
}
if len(accessPolicies) != 0 {
inviteUserPayload.IAMPolicy = accessPolicies
}

if infraPermissions := getInfraPermissions(d, meta); len(infraPermissions) != 0 {
inviteUserPayload.InfrastructureRoles = &v2.InfraPermissions{Permissions: infraPermissions}
}
orgRoles, err := getCloudFoundryRoles(d, meta)
if err != nil {
return err
}
inviteUserPayload := v2.UserInvite{
Users: users,
AccessGroup: accessGroups,
IAMPolicy: accessPolicies,
InfrastructureRoles: v2.InfraPermissions{Permissions: infraPermissions},
OrganizationRoles: orgRoles,
if len(orgRoles) != 0 {
inviteUserPayload.OrganizationRoles = orgRoles
}

accountID, err := getAccountID(d, meta)
Expand Down Expand Up @@ -424,14 +432,21 @@ func resourceIBMIAMUpdateUserProfile(d *schema.ResourceData, meta interface{}) e
return err
}

inviteUserPayload := v2.UserInvite{
Users: users,
AccessGroup: accessGroups,
IAMPolicy: accessPolicies,
InfrastructureRoles: v2.InfraPermissions{Permissions: infraPermissions},
OrganizationRoles: orgRoles,
}
inviteUserPayload := v2.UserInvite{}

inviteUserPayload.Users = users
if len(accessGroups) != 0 {
inviteUserPayload.AccessGroup = accessGroups
}
if len(accessPolicies) != 0 {
inviteUserPayload.IAMPolicy = accessPolicies
}
if len(infraPermissions) != 0 {
inviteUserPayload.InfrastructureRoles = &v2.InfraPermissions{Permissions: infraPermissions}
}
if len(orgRoles) != 0 {
inviteUserPayload.OrganizationRoles = orgRoles
}
_, InviteUserError := Client.InviteUsers(accountID, inviteUserPayload)
if InviteUserError != nil {
return InviteUserError
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cloud.google.com/go/internal/optional
cloud.google.com/go/internal/trace
cloud.google.com/go/internal/version
cloud.google.com/go/storage
# github.com/IBM-Cloud/bluemix-go v0.0.0-20200221095222-69e3682d6f5b
# github.com/IBM-Cloud/bluemix-go v0.0.0-20200225052022-0d5220c9f2ba
github.com/IBM-Cloud/bluemix-go
github.com/IBM-Cloud/bluemix-go/api/account/accountv1
github.com/IBM-Cloud/bluemix-go/api/account/accountv2
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/iam_user_invite.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ Nested `resources` blocks have the following structure:
* `space_guid` - (Required, string) ID of the cloud foundry space.
* `space_roles` - (Required, list) The space roles assigned for the inviting user. The supported space roles are Manager, Developer, Auditor.

**NOTE**: ibmcloud `Lite account` does not support classic infrastructure roles. For more info refer [whats available in lite account?](https://cloud.ibm.com/docs/account?topic=account-accounts#lite-account-features).

## Import

Import functionality not supported for this resource.

0 comments on commit 9a774f3

Please sign in to comment.