-
Notifications
You must be signed in to change notification settings - Fork 669
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
Conversation
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) { |
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.
can we change the testcase name to include S2S
} | ||
attributes { | ||
key = "volumeId" | ||
operator = "stringEquals" |
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.
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 |
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.
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{}), |
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.
leftover comments
modelMap := modelMap["resource"].([]interface{})[0].(map[string]interface{}) | ||
modelResource := &iampolicymanagementv1.V2PolicyResource{} | ||
attributes := []iampolicymanagementv1.V2PolicyResourceAttribute{} | ||
// roleList := &iampolicymanagementv1.RoleCollection{} |
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.
same as above
*attributesItemModel.Operator == "stringEquals") { | ||
targetServiceName = fmt.Sprintf("%v", attributesItemModel.Value) | ||
|
||
// listRoleOptions.ServiceName = core.StringPtr(attributesItemModel.Value.(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.
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())) |
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.
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" { |
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.
this may be for authorization type only
listRoleOptions.ServiceName = core.StringPtr("alliamserviceroles") | ||
} | ||
|
||
if *attributesItemModel.Key == "resourceType" && targetServiceName == "" { |
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.
this check also mostly for "authorization" type templates
Signed-off-by: Alluri-Varma <alluri.varma@ibm.com>
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 |
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.
Leftover comment.
Signed-off-by: Alluri-Varma <alluri.varma@ibm.com>
Signed-off-by: Alluri-Varma <alluri.varma@ibm.com>
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.
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 |
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.
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) |
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 options also from Schema
@@ -394,13 +394,6 @@ func DataSourceIBMPolicyAssignmentPolicyTemplateAssignmentItemsToMap(model iampo | |||
} | |||
modelMap["target"] = targetMap | |||
} | |||
if model.Options != nil { |
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 options from Schema
@@ -48,8 +48,6 @@ func ResourceIBMIAMPolicyAssignment() *schema.Resource { | |||
"templates": { | |||
Type: schema.TypeList, | |||
Required: true, | |||
MinItems: 1, |
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.
Why we removed Min and Max Items
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>
Community Note
Relates OR Closes #0000
Output from acceptance testing: