Skip to content

Add dryRun property for API Import action#1261

Merged
AnuGayan merged 3 commits intowso2:masterfrom
AnuGayan:master
Feb 26, 2025
Merged

Add dryRun property for API Import action#1261
AnuGayan merged 3 commits intowso2:masterfrom
AnuGayan:master

Conversation

@AnuGayan
Copy link
Copy Markdown
Contributor

@AnuGayan AnuGayan commented Feb 21, 2025

This pull request introduces several enhancements and new features to the import-export-cli tool, including the addition of a dry-run mode for API imports and improved logging for policy violations. The most important changes include adding new flags for the dry-run mode, implementing a new JSON data structure for compliance checks, and updating the import API functions to support the new features.

Enhancements to API Import Functionality:

  • Added dryRun and apiLoggingCmdFormat flags to the importAPI command to support dry-run mode and specify the output format for violation results. (import-export-cli/cmd/importAPI.go [1] [2] [3]
  • Updated the ImportAPIToEnv function to handle the new dry-run and logging format parameters. (import-export-cli/impl/importAPI.go [1] [2] [3]

New Data Structures and Logging:

  • Introduced new data structures JSONData, ComplianceCheck, and Violation to represent compliance check results and violations in JSON format. (import-export-cli/impl/importAPI.go import-export-cli/impl/importAPI.goR43-R53)
  • Implemented the PrintViolations function to print policy violations in different formats (table, JSON, list) based on the specified logging format. (import-export-cli/impl/printPolicyViolations.go import-export-cli/impl/printPolicyViolations.goR1-R97)

Dependency Updates:

  • Added new dependencies github.com/olekukonko/tablewriter and github.com/mattn/go-runewidth to support table formatting in the violation logging. (import-export-cli/go.mod [1] [2]

Minor Code Improvements:

  • Added missing documentation comments and improved existing ones for better code readability and maintenance. (import-export-cli/git/gitUtils.go [1] [2] [3] [4]## Purpose

Fixes issue reported in wso2/api-manager#2341

npamudika
npamudika previously approved these changes Feb 22, 2025
ashera96
ashera96 previously approved these changes Feb 22, 2025
var data JSONData
err := json.Unmarshal([]byte(resp.String()), &data)
if err != nil {
fmt.Println("Error parsing JSON:", err)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does err go to the tool execution level? If that is the case, I think we should print this entire error message in the verbose mode.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will get logged in the console, will add a single line error and print the stack trace in verbose mode

@AnuGayan AnuGayan dismissed stale reviews from ashera96 and npamudika via 2f80b64 February 26, 2025 10:35
@AnuGayan AnuGayan merged commit 064647a into wso2:master Feb 26, 2025
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants