-
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
Changes from 5 commits
9176291
503d11b
a9a1abc
47705e5
3a33a5e
4988a85
209e99d
5b3801f
60d6800
74231a4
172bd9b
560636f
f980af9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Remove options also from Schema |
||
if err != nil { | ||
return diag.FromErr(err) | ||
} | ||
if err = d.Set("options", []map[string]interface{}{optionsMap}); err != nil { | ||
return diag.FromErr(fmt.Errorf("error setting options: %s", err)) | ||
} | ||
|
||
if err = d.Set("href", policyAssignmentRecord.Href); err != nil { | ||
return diag.FromErr(fmt.Errorf("error setting href: %s", err)) | ||
|
@@ -317,18 +310,10 @@ func dataSourceIBMIAMPolicyAssignmentRead(context context.Context, d *schema.Res | |
return diag.FromErr(fmt.Errorf("error setting created_at: %s", err)) | ||
} | ||
|
||
if err = d.Set("created_by_id", policyAssignmentRecord.CreatedByID); err != nil { | ||
return diag.FromErr(fmt.Errorf("error setting created_by_id: %s", err)) | ||
} | ||
|
||
if err = d.Set("last_modified_at", flex.DateTimeToString(policyAssignmentRecord.LastModifiedAt)); err != nil { | ||
return diag.FromErr(fmt.Errorf("error setting last_modified_at: %s", err)) | ||
} | ||
|
||
if err = d.Set("last_modified_by_id", policyAssignmentRecord.LastModifiedByID); err != nil { | ||
return diag.FromErr(fmt.Errorf("error setting last_modified_by_id: %s", err)) | ||
} | ||
|
||
if err = d.Set("account_id", policyAssignmentRecord.AccountID); err != nil { | ||
return diag.FromErr(fmt.Errorf("error setting account_id: %s", err)) | ||
} | ||
|
@@ -474,45 +459,6 @@ func ResourceIBMPolicyAssignmentPolicyAssignmentV1ResourcesToMap(model *iampolic | |
} | ||
return modelMap, nil | ||
} | ||
func ResourceIBMPolicyAssignmentPolicyAssignmentV1OptionsRootTemplateToMap(model *iampolicymanagementv1.PolicyAssignmentV1OptionsRootTemplate) (map[string]interface{}, error) { | ||
modelMap := make(map[string]interface{}) | ||
if model.ID != nil { | ||
modelMap["id"] = *model.ID | ||
} | ||
if model.Version != nil { | ||
modelMap["version"] = *model.Version | ||
} | ||
return modelMap, nil | ||
} | ||
|
||
func ResourceIBMPolicyAssignmentPolicyAssignmentV1OptionsRootToMap(model *iampolicymanagementv1.PolicyAssignmentV1OptionsRoot) (map[string]interface{}, error) { | ||
modelMap := make(map[string]interface{}) | ||
if model.RequesterID != nil { | ||
modelMap["requester_id"] = *model.RequesterID | ||
} | ||
if model.AssignmentID != nil { | ||
modelMap["assignment_id"] = *model.AssignmentID | ||
} | ||
if model.Template != nil { | ||
templateMap, err := ResourceIBMPolicyAssignmentPolicyAssignmentV1OptionsRootTemplateToMap(model.Template) | ||
if err != nil { | ||
return modelMap, err | ||
} | ||
modelMap["template"] = []map[string]interface{}{templateMap} | ||
} | ||
return modelMap, nil | ||
} | ||
|
||
func ResourceIBMPolicyAssignmentPolicyAssignmentV1OptionsToMap(model *iampolicymanagementv1.PolicyAssignmentV1Options) (map[string]interface{}, error) { | ||
modelMap := make(map[string]interface{}) | ||
rootMap, err := ResourceIBMPolicyAssignmentPolicyAssignmentV1OptionsRootToMap(model.Root) | ||
if err != nil { | ||
return modelMap, err | ||
} | ||
modelMap["root"] = []map[string]interface{}{rootMap} | ||
return modelMap, nil | ||
} | ||
|
||
func DataSourceIBMPolicyAssignmentPolicyAssignmentV1Subject(model *iampolicymanagementv1.GetPolicyAssignmentResponseSubject) (map[string]interface{}, error) { | ||
modelMap := make(map[string]interface{}) | ||
if model.ID != nil { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -370,7 +370,7 @@ func ResourceIBMPolicyAssignmentAssignmentTargetDetailsToMap(model *iampolicyman | |
func ResourceIBMPolicyAssignmentResourceTargetDetailsToMap(model *iampolicymanagementv1.AssignmentTargetDetails) (map[string]interface{}, error) { | ||
modelMap := make(map[string]interface{}) | ||
if model.Type != nil { | ||
modelMap["version"] = *model.Type | ||
modelMap["type"] = *model.Type | ||
} | ||
if model.ID != nil { | ||
modelMap["id"] = *model.ID | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Remove options from Schema |
||
optionsMap, err := DataSourceIBMPolicyAssignmentPolicyAssignmentV1OptionsToMap(model.Options) | ||
if err != nil { | ||
return modelMap, err | ||
} | ||
modelMap["options"] = []map[string]interface{}{optionsMap} | ||
} | ||
if model.ID != nil { | ||
modelMap["id"] = *model.ID | ||
} | ||
|
@@ -476,45 +469,6 @@ func DataSourceIBMPolicyAssignmentAssignmentTargetDetailsToMap(model *iampolicym | |
return modelMap, nil | ||
} | ||
|
||
func DataSourceIBMPolicyAssignmentPolicyAssignmentV1OptionsToMap(model *iampolicymanagementv1.PolicyAssignmentV1Options) (map[string]interface{}, error) { | ||
modelMap := make(map[string]interface{}) | ||
rootMap, err := DataSourceIBMPolicyAssignmentPolicyAssignmentV1OptionsRootToMap(model.Root) | ||
if err != nil { | ||
return modelMap, err | ||
} | ||
modelMap["root"] = []map[string]interface{}{rootMap} | ||
return modelMap, nil | ||
} | ||
|
||
func DataSourceIBMPolicyAssignmentPolicyAssignmentV1OptionsRootToMap(model *iampolicymanagementv1.PolicyAssignmentV1OptionsRoot) (map[string]interface{}, error) { | ||
modelMap := make(map[string]interface{}) | ||
if model.RequesterID != nil { | ||
modelMap["requester_id"] = *model.RequesterID | ||
} | ||
if model.AssignmentID != nil { | ||
modelMap["assignment_id"] = *model.AssignmentID | ||
} | ||
if model.Template != nil { | ||
templateMap, err := DataSourceIBMPolicyAssignmentPolicyAssignmentV1OptionsRootTemplateToMap(model.Template) | ||
if err != nil { | ||
return modelMap, err | ||
} | ||
modelMap["template"] = []map[string]interface{}{templateMap} | ||
} | ||
return modelMap, nil | ||
} | ||
|
||
func DataSourceIBMPolicyAssignmentPolicyAssignmentV1OptionsRootTemplateToMap(model *iampolicymanagementv1.PolicyAssignmentV1OptionsRootTemplate) (map[string]interface{}, error) { | ||
modelMap := make(map[string]interface{}) | ||
if model.ID != nil { | ||
modelMap["id"] = *model.ID | ||
} | ||
if model.Version != nil { | ||
modelMap["version"] = *model.Version | ||
} | ||
return modelMap, nil | ||
} | ||
|
||
func DataSourceIBMPolicyAssignmentPolicyAssignmentV1ResourcesToMap(model *iampolicymanagementv1.PolicyAssignmentV1Resources) (map[string]interface{}, error) { | ||
modelMap := make(map[string]interface{}) | ||
if model.Target != nil { | ||
|
@@ -665,17 +619,6 @@ func DataSourceIBMPolicyAssignmentPolicyTemplateAssignmentItemsPolicyAssignmentT | |
if model.Target != nil { | ||
modelMap["target"] = *model.Target | ||
} | ||
if model.Options != nil { | ||
options := []map[string]interface{}{} | ||
for _, optionsItem := range model.Options { | ||
optionsItemMap, err := DataSourceIBMPolicyAssignmentPolicyAssignmentOptionsToMap(&optionsItem) | ||
if err != nil { | ||
return modelMap, err | ||
} | ||
options = append(options, optionsItemMap) | ||
} | ||
modelMap["options"] = options | ||
} | ||
if model.ID != nil { | ||
modelMap["id"] = *model.ID | ||
} | ||
|
@@ -714,20 +657,6 @@ func DataSourceIBMPolicyAssignmentPolicyTemplateAssignmentItemsPolicyAssignmentT | |
return modelMap, nil | ||
} | ||
|
||
func DataSourceIBMPolicyAssignmentPolicyAssignmentOptionsToMap(model *iampolicymanagementv1.PolicyAssignmentOptions) (map[string]interface{}, error) { | ||
modelMap := make(map[string]interface{}) | ||
modelMap["subject_type"] = *model.SubjectType | ||
modelMap["subject_id"] = *model.SubjectID | ||
modelMap["root_requester_id"] = *model.RootRequesterID | ||
if model.RootTemplateID != nil { | ||
modelMap["root_template_id"] = *model.RootTemplateID | ||
} | ||
if model.RootTemplateVersion != nil { | ||
modelMap["root_template_version"] = *model.RootTemplateVersion | ||
} | ||
return modelMap, nil | ||
} | ||
|
||
func DataSourceIBMPolicyAssignmentPolicyAssignmentResourcesToMap(model *iampolicymanagementv1.PolicyAssignmentResources) (map[string]interface{}, error) { | ||
modelMap := make(map[string]interface{}) | ||
if model.Target != nil { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Why we removed Min and Max Items |
||
MaxItems: 1, | ||
Description: "policy template details.", | ||
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
|
@@ -66,54 +64,6 @@ func ResourceIBMIAMPolicyAssignment() *schema.Resource { | |
}, | ||
}, | ||
}, | ||
"options": { | ||
Type: schema.TypeList, | ||
MinItems: 1, | ||
MaxItems: 1, | ||
Required: true, | ||
Description: "The set of properties required for a policy assignment.", | ||
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"root": { | ||
Type: schema.TypeList, | ||
MinItems: 1, | ||
MaxItems: 1, | ||
Required: true, | ||
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"requester_id": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
}, | ||
"assignment_id": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Description: "Passed in value to correlate with other assignments.", | ||
}, | ||
"template": { | ||
Type: schema.TypeList, | ||
Optional: true, | ||
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"id": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Description: "The template id where this policy is being assigned from.", | ||
}, | ||
"version": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Description: "The template version where this policy is being assigned from.", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
"account_id": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
|
@@ -304,11 +254,6 @@ func resourceIBMPolicyAssignmentCreate(context context.Context, d *schema.Resour | |
return diag.FromErr(err) | ||
} | ||
createPolicyTemplateAssignmentOptions.SetTarget(targetModel) | ||
optionsModel, err := ResourceIBMPolicyAssignmentMapToPolicyAssignmentV1Options(d.Get("options.0").(map[string]interface{})) | ||
if err != nil { | ||
return diag.FromErr(err) | ||
} | ||
createPolicyTemplateAssignmentOptions.SetOptions(optionsModel) | ||
var templates []iampolicymanagementv1.AssignmentTemplateDetails | ||
for _, v := range d.Get("templates").([]interface{}) { | ||
value := v.(map[string]interface{}) | ||
|
@@ -368,13 +313,6 @@ func resourceIBMPolicyAssignmentRead(context context.Context, d *schema.Resource | |
if err = d.Set("target", targetMap); err != nil { | ||
return diag.FromErr(fmt.Errorf("error setting target: %s", err)) | ||
} | ||
optionsMap, err := ResourceIBMPolicyAssignmentPolicyAssignmentV1OptionsToMap(assignmentDetails.Options) | ||
if err != nil { | ||
return diag.FromErr(err) | ||
} | ||
if err = d.Set("options", []map[string]interface{}{optionsMap}); err != nil { | ||
return diag.FromErr(fmt.Errorf("error setting options: %s", err)) | ||
} | ||
if !core.IsNil(assignmentDetails.AccountID) { | ||
if err = d.Set("account_id", assignmentDetails.AccountID); err != nil { | ||
return diag.FromErr(fmt.Errorf("error setting account_id: %s", err)) | ||
|
@@ -516,45 +454,6 @@ func ResourceIBMPolicyAssignmentMapToAssignmentTargetDetails(modelMap map[string | |
return model, nil | ||
} | ||
|
||
func ResourceIBMPolicyAssignmentMapToPolicyAssignmentV1Options(modelMap map[string]interface{}) (*iampolicymanagementv1.PolicyAssignmentV1Options, error) { | ||
model := &iampolicymanagementv1.PolicyAssignmentV1Options{} | ||
RootModel, err := ResourceIBMPolicyAssignmentMapToPolicyAssignmentV1OptionsRoot(modelMap["root"].([]interface{})[0].(map[string]interface{})) | ||
if err != nil { | ||
return model, err | ||
} | ||
model.Root = RootModel | ||
return model, nil | ||
} | ||
|
||
func ResourceIBMPolicyAssignmentMapToPolicyAssignmentV1OptionsRoot(modelMap map[string]interface{}) (*iampolicymanagementv1.PolicyAssignmentV1OptionsRoot, error) { | ||
model := &iampolicymanagementv1.PolicyAssignmentV1OptionsRoot{} | ||
if modelMap["requester_id"] != nil && modelMap["requester_id"].(string) != "" { | ||
model.RequesterID = core.StringPtr(modelMap["requester_id"].(string)) | ||
} | ||
if modelMap["assignment_id"] != nil && modelMap["assignment_id"].(string) != "" { | ||
model.AssignmentID = core.StringPtr(modelMap["assignment_id"].(string)) | ||
} | ||
if modelMap["template"] != nil && len(modelMap["template"].([]interface{})) > 0 { | ||
TemplateModel, err := ResourceIBMPolicyAssignmentMapToPolicyAssignmentV1OptionsRootTemplate(modelMap["template"].([]interface{})[0].(map[string]interface{})) | ||
if err != nil { | ||
return model, err | ||
} | ||
model.Template = TemplateModel | ||
} | ||
return model, nil | ||
} | ||
|
||
func ResourceIBMPolicyAssignmentMapToPolicyAssignmentV1OptionsRootTemplate(modelMap map[string]interface{}) (*iampolicymanagementv1.PolicyAssignmentV1OptionsRootTemplate, error) { | ||
model := &iampolicymanagementv1.PolicyAssignmentV1OptionsRootTemplate{} | ||
if modelMap["id"] != nil && modelMap["id"].(string) != "" { | ||
model.ID = core.StringPtr(modelMap["id"].(string)) | ||
} | ||
if modelMap["version"] != nil && modelMap["version"].(string) != "" { | ||
model.Version = core.StringPtr(modelMap["version"].(string)) | ||
} | ||
return model, nil | ||
} | ||
|
||
func ResourceIBMPolicyAssignmentMapToAssignmentTemplateDetails(modelMap map[string]interface{}) (*iampolicymanagementv1.AssignmentTemplateDetails, error) { | ||
model := &iampolicymanagementv1.AssignmentTemplateDetails{} | ||
if modelMap["id"] != nil && modelMap["id"].(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.
rolling back to previous version shd n't override other services go sdk's verison