From de636968063c659d82b5f6d7c27a90deb71ac451 Mon Sep 17 00:00:00 2001 From: ParthaI Date: Fri, 6 May 2022 16:28:55 +0530 Subject: [PATCH 1/4] Fix column access_control inconsistent state in table azure_logic_app_workflow closes #484 --- .../test-list-query.sql | 2 +- azure/table_azure_logic_app_workflow.go | 21 ++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/azure-test/tests/azure_logic_app_workflow/test-list-query.sql b/azure-test/tests/azure_logic_app_workflow/test-list-query.sql index 0f1c1bc4..ba40e08c 100644 --- a/azure-test/tests/azure_logic_app_workflow/test-list-query.sql +++ b/azure-test/tests/azure_logic_app_workflow/test-list-query.sql @@ -1,3 +1,3 @@ select name, id, type from azure.azure_logic_app_workflow -where name = '{{ resourceName }}'; \ No newline at end of file +where id = '{{ output.resource_id.value }}'; \ No newline at end of file diff --git a/azure/table_azure_logic_app_workflow.go b/azure/table_azure_logic_app_workflow.go index fab411f2..26bf9a39 100644 --- a/azure/table_azure_logic_app_workflow.go +++ b/azure/table_azure_logic_app_workflow.go @@ -88,7 +88,7 @@ func tableAzureLogicAppWorkflow(_ context.Context) *plugin.Table { Name: "access_control", Description: "The access control configuration.", Type: proto.ColumnType_JSON, - Transform: transform.FromField("WorkflowProperties.AccessControl"), + Transform: transform.From(getAccessControl), }, { Name: "definition", @@ -282,3 +282,22 @@ func listLogicAppWorkflowDiagnosticSettings(ctx context.Context, d *plugin.Query } return diagnosticSettings, nil } + +//// TRANSFORM FUNCTION + +// Access Control configuration for Any IP is comming as "{}" instead of nill if wea re not providing any IP in configuration +func getAccessControl(ctx context.Context, d *transform.TransformData) (interface{}, error) { + data := d.HydrateItem.(logic.Workflow) + if data.WorkflowProperties != nil { + if data.WorkflowProperties.AccessControl == nil { + return nil, nil + } else { + if data.WorkflowProperties.AccessControl.Actions != nil || data.WorkflowProperties.AccessControl.Contents != nil || data.WorkflowProperties.AccessControl.Triggers != nil || data.WorkflowProperties.AccessControl.WorkflowManagement != nil { + return data.WorkflowProperties.AccessControl, nil + } else { + return nil, nil + } + } + } + return data.AccessControl, nil +} From 2fe0cbc002b6c8dda7bfe13b04223132d37352cb Mon Sep 17 00:00:00 2001 From: ParthaI <47887552+ParthaI@users.noreply.github.com> Date: Wed, 11 May 2022 10:29:48 +0530 Subject: [PATCH 2/4] Updated the comment Co-authored-by: cbruno10 --- azure/table_azure_logic_app_workflow.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure/table_azure_logic_app_workflow.go b/azure/table_azure_logic_app_workflow.go index 26bf9a39..d543bd3b 100644 --- a/azure/table_azure_logic_app_workflow.go +++ b/azure/table_azure_logic_app_workflow.go @@ -285,7 +285,7 @@ func listLogicAppWorkflowDiagnosticSettings(ctx context.Context, d *plugin.Query //// TRANSFORM FUNCTION -// Access Control configuration for Any IP is comming as "{}" instead of nill if wea re not providing any IP in configuration +// Access Control configuration for any IP is coming as "{}" instead of nil if we are not providing any IP in configuration func getAccessControl(ctx context.Context, d *transform.TransformData) (interface{}, error) { data := d.HydrateItem.(logic.Workflow) if data.WorkflowProperties != nil { From 40921706c9333c0ed184348b9214e0855f572099 Mon Sep 17 00:00:00 2001 From: ParthaI Date: Thu, 26 May 2022 10:17:53 +0530 Subject: [PATCH 3/4] Changed the transforrm function name and added the comments --- azure/table_azure_logic_app_workflow.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/azure/table_azure_logic_app_workflow.go b/azure/table_azure_logic_app_workflow.go index d543bd3b..f964c2ad 100644 --- a/azure/table_azure_logic_app_workflow.go +++ b/azure/table_azure_logic_app_workflow.go @@ -88,7 +88,7 @@ func tableAzureLogicAppWorkflow(_ context.Context) *plugin.Table { Name: "access_control", Description: "The access control configuration.", Type: proto.ColumnType_JSON, - Transform: transform.From(getAccessControl), + Transform: transform.From(extractAccessControl), }, { Name: "definition", @@ -286,12 +286,13 @@ func listLogicAppWorkflowDiagnosticSettings(ctx context.Context, d *plugin.Query //// TRANSFORM FUNCTION // Access Control configuration for any IP is coming as "{}" instead of nil if we are not providing any IP in configuration -func getAccessControl(ctx context.Context, d *transform.TransformData) (interface{}, error) { +func extractAccessControl(ctx context.Context, d *transform.TransformData) (interface{}, error) { data := d.HydrateItem.(logic.Workflow) if data.WorkflowProperties != nil { if data.WorkflowProperties.AccessControl == nil { return nil, nil } else { + // Due to the inconsistency in the API behaviour we need this check. if data.WorkflowProperties.AccessControl.Actions != nil || data.WorkflowProperties.AccessControl.Contents != nil || data.WorkflowProperties.AccessControl.Triggers != nil || data.WorkflowProperties.AccessControl.WorkflowManagement != nil { return data.WorkflowProperties.AccessControl, nil } else { From 07fad3b8442be8f966fe13665f6f376bef56bcef Mon Sep 17 00:00:00 2001 From: ParthaI Date: Thu, 26 May 2022 10:19:53 +0530 Subject: [PATCH 4/4] Update --- azure/table_azure_logic_app_workflow.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure/table_azure_logic_app_workflow.go b/azure/table_azure_logic_app_workflow.go index f964c2ad..367809ff 100644 --- a/azure/table_azure_logic_app_workflow.go +++ b/azure/table_azure_logic_app_workflow.go @@ -292,7 +292,7 @@ func extractAccessControl(ctx context.Context, d *transform.TransformData) (inte if data.WorkflowProperties.AccessControl == nil { return nil, nil } else { - // Due to the inconsistency in the API behaviour we need this check. + // Due to inconsistency in the API behaviour we need this check. if data.WorkflowProperties.AccessControl.Actions != nil || data.WorkflowProperties.AccessControl.Contents != nil || data.WorkflowProperties.AccessControl.Triggers != nil || data.WorkflowProperties.AccessControl.WorkflowManagement != nil { return data.WorkflowProperties.AccessControl, nil } else {