Skip to content
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

IAM Policy Assignment: S2S Policy Assignments #5499

Merged
merged 13 commits into from
Jul 15, 2024

Conversation

siddhuvarma1997
Copy link
Contributor

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Relates OR Closes #0000

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccXXX'

...

Signed-off-by: Alluri-Varma <alluri.varma@ibm.com>
Signed-off-by: Alluri-Varma <alluri.varma@ibm.com>
Signed-off-by: Alluri-Varma <alluri.varma@ibm.com>
@@ -44,6 +44,34 @@ func TestAccIBMIAMPolicyTemplateBasic(t *testing.T) {
})
}

func TestAccIBMIAMPolicyTemplateBasicUpdateTest(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we change the testcase name to include S2S

}
attributes {
key = "volumeId"
operator = "stringEquals"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stringEquals -> "stringExists"

ResourceModel, roleList, err := generateTemplatePolicyResource(modelMap["resource"].([]interface{})[0].(map[string]interface{}), iamPolicyManagementClient)
var roleList *iampolicymanagementv1.RoleCollection
listRoleOptions := &iampolicymanagementv1.ListRolesOptions{}
// var ResourceModel *iampolicymanagementv1.V2PolicyResource
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left over

// var ResourceModel *iampolicymanagementv1.V2PolicyResource
var err error
if _, ok := d.GetOk("policy.0.resource"); ok {
// ResourceModel, roleList, err = generateTemplatePolicyAttributes(modelMap["resource"].([]interface{})[0].(map[string]interface{}),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leftover comments

modelMap := modelMap["resource"].([]interface{})[0].(map[string]interface{})
modelResource := &iampolicymanagementv1.V2PolicyResource{}
attributes := []iampolicymanagementv1.V2PolicyResourceAttribute{}
// roleList := &iampolicymanagementv1.RoleCollection{}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

*attributesItemModel.Operator == "stringEquals") {
targetServiceName = fmt.Sprintf("%v", attributesItemModel.Value)

// listRoleOptions.ServiceName = core.StringPtr(attributesItemModel.Value.(string))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above


// check subject only for authorization type
if _, ok := d.GetOk("policy.0.subject"); ok {
// subjectModel, err := generateTemplatePolicySubject(((modelMap["subject"]).(*schema.Set).List()))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

return model, fmt.Errorf("[ERROR] Only values \"true\" and \"false\" are allowed when operator is \"stringExists\". Received %s.", attributesItemModel.Value)
}
}
if *attributesItemModel.Operator == "" && attributesItemModel.Value == "*" && *attributesItemModel.Key == "resourceGroupId" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this may be for authorization type only

listRoleOptions.ServiceName = core.StringPtr("alliamserviceroles")
}

if *attributesItemModel.Key == "resourceType" && targetServiceName == "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this check also mostly for "authorization" type templates

@siddhuvarma1997
Copy link
Contributor Author

image

Signed-off-by: Alluri-Varma <alluri.varma@ibm.com>
@siddhuvarma1997
Copy link
Contributor Author

image

@siddhuvarma1997
Copy link
Contributor Author

Uploading image.png…

@siddhuvarma1997
Copy link
Contributor Author

image

Signed-off-by: Alluri-Varma <alluri.varma@ibm.com>
modelMap := make(map[string]interface{})
attributes := []map[string]interface{}{}
listRoleOptions := &iampolicymanagementv1.ListRolesOptions{}
var roles *iampolicymanagementv1.RoleCollection
// var roles *iampolicymanagementv1.RoleCollection
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftover comment.

Signed-off-by: Alluri-Varma <alluri.varma@ibm.com>
@siddhuvarma1997
Copy link
Contributor Author

image

@siddhuvarma1997 siddhuvarma1997 marked this pull request as ready for review July 12, 2024 10:51
Copy link
Contributor

@swcolley swcolley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Need terraform team to review.

go.mod Outdated
github.com/IBM/platform-services-go-sdk v0.62.11
github.com/IBM/project-go-sdk v0.3.5
github.com/IBM/platform-services-go-sdk v0.64.3
github.com/IBM/project-go-sdk v0.3.4
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rolling back to previous version shd n't override other services go sdk's verison

@@ -301,13 +301,6 @@ func dataSourceIBMIAMPolicyAssignmentRead(context context.Context, d *schema.Res
return diag.FromErr(fmt.Errorf("error setting template: %s", err))
}
}
optionsMap, err := ResourceIBMPolicyAssignmentPolicyAssignmentV1OptionsToMap(policyAssignmentRecord.Options)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove options also from Schema

@@ -394,13 +394,6 @@ func DataSourceIBMPolicyAssignmentPolicyTemplateAssignmentItemsToMap(model iampo
}
modelMap["target"] = targetMap
}
if model.Options != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove options from Schema

@@ -48,8 +48,6 @@ func ResourceIBMIAMPolicyAssignment() *schema.Resource {
"templates": {
Type: schema.TypeList,
Required: true,
MinItems: 1,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we removed Min and Max Items

@hkantare
Copy link
Collaborator

hkantare commented Jul 12, 2024

Update respective docs (resources/datasources) as per the above code changes

Signed-off-by: Alluri-Varma <alluri.varma@ibm.com>
Signed-off-by: Alluri-Varma <alluri.varma@ibm.com>
Signed-off-by: Alluri-Varma <alluri.varma@ibm.com>
Signed-off-by: Alluri-Varma <alluri.varma@ibm.com>
@hkantare hkantare merged commit 553c670 into IBM-Cloud:master Jul 15, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants