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

chore: Apply new resource conventions to scim integration #2891

Merged
merged 3 commits into from
Jun 28, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Changes after review
sfc-gh-jcieslak committed Jun 27, 2024
commit aebfbde6da5e6119597846b44d6052438fb306ae
2 changes: 1 addition & 1 deletion docs/resources/scim_integration.md
Original file line number Diff line number Diff line change
@@ -49,7 +49,7 @@ resource "snowflake_scim_integration" "test" {

### Read-Only

- `describe_output` (List of Object) Outputs the result of `SHOW SECURITY INTEGRATIONS` for the given security integration. (see [below for nested schema](#nestedatt--describe_output))
- `describe_output` (List of Object) Outputs the result of `DESCRIBE SECURITY INTEGRATIONS` for the given security integration. (see [below for nested schema](#nestedatt--describe_output))
- `id` (String) The ID of this resource.
- `show_output` (List of Object) Outputs the result of `SHOW SECURITY INTEGRATIONS` for the given security integration. (see [below for nested schema](#nestedatt--show_output))

6 changes: 3 additions & 3 deletions pkg/resources/scim_integration.go
Original file line number Diff line number Diff line change
@@ -88,9 +88,9 @@ var scimIntegrationSchema = map[string]*schema.Schema{
describeOutputAttributeName: {
Type: schema.TypeList,
Computed: true,
Description: "Outputs the result of `SHOW SECURITY INTEGRATIONS` for the given security integration.",
Description: "Outputs the result of `DESCRIBE SECURITY INTEGRATIONS` for the given security integration.",
Elem: &schema.Resource{
Schema: schemas.DescribeSecurityIntegrationSchema,
Schema: schemas.DescribeScimSecurityIntegrationSchema,
},
},
}
@@ -331,7 +331,7 @@ func ReadContextSCIMIntegration(withExternalChangesMarking bool) schema.ReadCont
return diag.FromErr(err)
}

if err = d.Set(describeOutputAttributeName, []map[string]any{schemas.SecurityIntegrationPropertiesToSchema(integrationProperties)}); err != nil {
if err = d.Set(describeOutputAttributeName, []map[string]any{schemas.ScimSecurityIntegrationPropertiesToSchema(integrationProperties)}); err != nil {
return diag.FromErr(err)
}

6 changes: 3 additions & 3 deletions pkg/resources/warehouse_rework_show_output_proposal.go
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ type showMapping struct {

// handleExternalChangesToObjectInDescribe assumes that show output is kept in describeOutputAttributeName attribute
func handleExternalChangesToObjectInDescribe(d *schema.ResourceData, mappings ...describeMapping) error {
if describeOutput, ok := d.GetOk(showOutputAttributeName); ok {
if describeOutput, ok := d.GetOk(describeOutputAttributeName); ok {
describeOutputList := describeOutput.([]any)
if len(describeOutputList) == 1 {
result := describeOutputList[0].(map[string]any)
@@ -51,12 +51,12 @@ func handleExternalChangesToObjectInDescribe(d *schema.ResourceData, mappings ..
continue
}

valueToCompareFromList := result[mapping.nameInDescribe].([]map[string]any)
valueToCompareFromList := result[mapping.nameInDescribe].([]any)
if len(valueToCompareFromList) != 1 {
continue
}

valueToCompareFrom := valueToCompareFromList[0]["value"]
valueToCompareFrom := valueToCompareFromList[0].(map[string]any)["value"]
if mapping.normalizeFunc != nil {
valueToCompareFrom = mapping.normalizeFunc(valueToCompareFrom)
}
Original file line number Diff line number Diff line change
@@ -7,18 +7,18 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

// DescribeSecurityIntegrationSchema represents output of DESCRIBE query for the single SecurityIntegration.
var DescribeSecurityIntegrationSchema = map[string]*schema.Schema{
// DescribeScimSecurityIntegrationSchema represents output of DESCRIBE query for the single SecurityIntegration.
var DescribeScimSecurityIntegrationSchema = map[string]*schema.Schema{
"enabled": DescribePropertyListSchema,
"network_policy": DescribePropertyListSchema,
"run_as_role": DescribePropertyListSchema,
"sync_password": DescribePropertyListSchema,
"comment": DescribePropertyListSchema,
}

var _ = DescribeSecurityIntegrationSchema
var _ = DescribeScimSecurityIntegrationSchema

func SecurityIntegrationPropertiesToSchema(securityIntegrationProperties []sdk.SecurityIntegrationProperty) map[string]any {
func ScimSecurityIntegrationPropertiesToSchema(securityIntegrationProperties []sdk.SecurityIntegrationProperty) map[string]any {
securityIntegrationSchema := make(map[string]any)
for _, securityIntegrationProperty := range securityIntegrationProperties {
switch securityIntegrationProperty.Name {
@@ -40,4 +40,4 @@ func SecurityIntegrationPropertiesToSchema(securityIntegrationProperties []sdk.S
return securityIntegrationSchema
}

var _ = SecurityIntegrationPropertiesToSchema
var _ = ScimSecurityIntegrationPropertiesToSchema