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

Fix column access_control inconsistent state in table azure_logic_app_workflow closes #484 #486

Merged
merged 4 commits into from
Jun 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
select name, id, type
from azure.azure_logic_app_workflow
where name = '{{ resourceName }}';
where id = '{{ output.resource_id.value }}';
22 changes: 21 additions & 1 deletion azure/table_azure_logic_app_workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(extractAccessControl),
},
{
Name: "definition",
Expand Down Expand Up @@ -282,3 +282,23 @@ func listLogicAppWorkflowDiagnosticSettings(ctx context.Context, d *plugin.Query
}
return diagnosticSettings, nil
}

//// TRANSFORM FUNCTION

// Access Control configuration for any IP is coming as "{}" instead of nil if we are not providing any IP in configuration
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 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 {
return nil, nil
}
}
}
return data.AccessControl, nil
}