Add support for Workflows resource type#66
Open
RovinKYK wants to merge 9 commits intowso2-extensions:masterfrom
Open
Add support for Workflows resource type#66RovinKYK wants to merge 9 commits intowso2-extensions:masterfrom
RovinKYK wants to merge 9 commits intowso2-extensions:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds first-class Workflows support to iamctl, enabling workflow export/import (including workflow associations) and integrating workflow-specific keyword/reference handling into the existing resource pipeline.
Changes:
- Introduces a new
workflowspackage with export/import logic, including handling of workflow associations and workflow-step sanitization. - Extends
utilsto recognize the new resource types/configs (WORKFLOWS + WORKFLOW_ASSOCIATIONS), add API paths, add workflow array/reference metadata, and support GET list query params. - Updates roles import/export to populate the identifier map so workflow role references can be replaced during export/import.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| iamctl/pkg/workflows/workflowUtils.go | Workflow + association helper logic (list/retrieve/process/serialize; export summary helper). |
| iamctl/pkg/workflows/import.go | Imports workflows and syncs/deletes workflow associations. |
| iamctl/pkg/workflows/export.go | Exports workflows, collects association names, writes association list file. |
| iamctl/pkg/utils/setup.go | Adds WorkflowConfigs to tool/keyword config structs. |
| iamctl/pkg/utils/resourceOrder.go | Adds WORKFLOWS to the processing order. |
| iamctl/pkg/utils/keywordUtils.go | Registers workflow array identifiers. |
| iamctl/pkg/utils/init.go | Adds workflow/workflow-association OAuth scopes. |
| iamctl/pkg/utils/constants.go | Adds new resource types/config constants and workflow reference metadata (Workflows → Roles). |
| iamctl/pkg/utils/apiUtils.go | Adds query param support for list requests + workflow API paths. |
| iamctl/pkg/roles/rolesUtils.go | Simplifies role ID lookup helper. |
| iamctl/pkg/roles/import.go | Registers role identifiers during import (needed for reference replacement). |
| iamctl/pkg/roles/export.go | Registers role identifiers during export (needed for reference replacement). |
| iamctl/cmd/cli/importAll.go | Wires workflows into importAll. |
| iamctl/cmd/cli/exportAll.go | Wires workflows into exportAll. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Add export/import support for the Workflows resource type, including Workflow Associations as a dependent sub-resource. Introduces role identifier reference resolution within workflow templates and fixes association
isEnabledstate not being applied on creation.Related to https://github.com/wso2-enterprise/iam-product-management/issues/662
Goals
WorkflowAssociations.*) to drive stale association cleanup without requiring a per-workflow association lookup on importisEnabled: falseon initial creationAddToIdentifierMapon both export and import so that workflows processed later in the pipeline can resolve role references correctlyApproach
Two resource types: WORKFLOWS and WORKFLOW_ASSOCIATIONS
Workflows introduce two resource types:
WORKFLOWSas the primary resource andWORKFLOW_ASSOCIATIONSas a sub-resource. Associations are not exported as standalone files. Instead, each workflow file embeds its associations under anassociationskey. On export, a separate flatWorkflowAssociations.*file records only association names, used purely as a deletion manifest on import.WORKFLOW_ASSOCIATIONSis declared as a sub-resource constant (not added toResourceOrder) and gets its own entry ingetResourcePath()andinit.goscopes. This keeps it invisible as a standalone resource while still allowing shared utilities to route API calls. Failures are summarized in Workflows.Sub-resource failure mapping to main resource summary
Association failures during import are attributed to the parent
WORKFLOWSresource type in the summary rather than creating a separateWORKFLOW_ASSOCIATIONSfailure row. WhenremoveDeletedDeployedWfAssociationsfails to delete a stale association, the affected workflow name is added to afailedWorkflowsset. The main import loop skips those workflows and records the failure underWORKFLOWS. This surfaces the problem at the workflow level, which is the actionable unit for the operator.Explicit association list for delete
Rather than fetching all deployed associations and matching them against per-workflow lookups, a single
WorkflowAssociations.*file is written during export containing all exported association names. On import, this file is read once and diffed against the full deployed association list to identify and delete stale entries before any workflow create/update is attempted. This avoids N+1 API calls and provides a clear, auditable local record of which associations are under management.Fixing
isEnabled: falsenot applied on creationThe IS workflow association POST API creates associations in an enabled state regardless of the
isEnabledfield in the request body.createAssociationdetects when the local definition hasisEnabled: false, reads the created association's ID from the POST response body, and immediately issues a PATCH to disable it. This two-step sequence is encapsulated indisableAssociationinworkflowUtils.go.Role reference resolution in workflow templates
Workflow template steps contain
optionsarrays with role values stored as server-specific IDs (e.g."abc123"). On export,ReplaceReferencesis called with the reference metadata defined inconstants.go:This replaces role IDs with display names in the exported file. On import, references are resolved back to IDs using the identifier map populated during the roles import step, which runs earlier in
ResourceOrder. To support this,roles/export.goandroles/import.gonow callAddToIdentifierMapon each successfully processed role so the map is populated regardless of which direction the pipeline runs.Stripping user step options
User-type step options (entity == "users") reference specific user accounts by server-specific identifiers and cannot be meaningfully ported across environments.
removeUserStepOptionsfilters them out during export. Steps that become empty after filtering are also removed. A warning is logged on both export and import to makethe omission explicit to the operator.
Workflow associations sync
syncWorkflowAssociationsreconciles the associations declared in the local workflow file against the currently deployed association list. For each association in the file it either creates (if not deployed) or updates via PATCH (if deployed). Association identity is matched by name. The full association body is sent on both create and PATCH to keep the logic uniform.User Stories
As a system administrator, I want to export and import approval workflows using IAM-CTL to enable version control and maintain consistent IAM configurations.
Release Note
Added Workflow management support to IAM-CTL tool.
Documentation
Training
Certification
Marketing
Automation tests
Security checks
Samples
Related PRs
Migrations (if applicable)
Test environment
Learning