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

Add option to enable JSON output for diff/sync #798

Merged
merged 39 commits into from
Jul 19, 2023

Conversation

DanielRailean
Copy link
Contributor

We’ve been having an issue with deck where we wanted to parse its output to something meaningful like an object so we think that it would be useful to have an option that would allow its output to be a JSON object that can be then used with pretty much any language to build SDKs/clients.

This PR does exactly that, enabling the above-mentioned feature using the enable-json-output flag.

You can check out a small demo below:

deck2

@DanielRailean DanielRailean requested a review from a team November 28, 2022 13:15
@CLAassistant
Copy link

CLAassistant commented Nov 28, 2022

CLA assistant check
All committers have signed the CLA.

@DanielRailean DanielRailean temporarily deployed to Configure ci December 6, 2022 13:14 Inactive
utils/types.go Outdated Show resolved Hide resolved
cmd/common.go Outdated Show resolved Hide resolved
cmd/common.go Outdated Show resolved Hide resolved
cmd/common.go Outdated Show resolved Hide resolved
cmd/common.go Outdated Show resolved Hide resolved
cmd/common.go Outdated Show resolved Hide resolved
cmd/common.go Outdated Show resolved Hide resolved
cmd/common.go Outdated Show resolved Hide resolved
cmd/diff.go Outdated Show resolved Hide resolved
@GGabriele
Copy link
Collaborator

Hi @DanielRailean ,

thanks for your contribution!

I gave this a first review. Other than the comments I left, can you please make sure to address the linting errors?

@DanielRailean
Copy link
Contributor Author

Hi @GGabriele, please have a second look when you got a moment, and let me know if other changes are needed.

@DanielRailean
Copy link
Contributor Author

Hey there, @GGabriele please have a second look at this.

It says change requested, but this seems to be a GitHub bug.

@DanielRailean DanielRailean force-pushed the feat/json-output branch 2 times, most recently from 0ebbd1a to e13e34c Compare April 5, 2023 13:26
@alexpopaconst
Copy link

@GGabriele updates here?

@DanielRailean DanielRailean temporarily deployed to Configure ci April 17, 2023 07:32 — with GitHub Actions Inactive
@alexpopaconst
Copy link

@hbagdi @GGabriele pinging you guys again

@DanielRailean DanielRailean temporarily deployed to Configure ci April 27, 2023 09:24 — with GitHub Actions Inactive
cmd/diff.go Outdated Show resolved Hide resolved
cmd/diff.go Outdated Show resolved Hide resolved
cmd/sync.go Outdated Show resolved Hide resolved
cmd/sync.go Outdated Show resolved Hide resolved
utils/types.go Outdated Show resolved Hide resolved
cmd/common.go Outdated Show resolved Hide resolved
cmd/common.go Outdated Show resolved Hide resolved
diff/diff.go Outdated Show resolved Hide resolved
diff/diff.go Outdated Show resolved Hide resolved
diff/diff.go Outdated Show resolved Hide resolved
cmd/common.go Outdated Show resolved Hide resolved
cmd/common.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@GGabriele GGabriele left a comment

Choose a reason for hiding this comment

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

@DanielRailean apologies for the delay in coming back to you

I've added some comments and asks for changes. On top of those, I kindly ask you to please:

  • make sure your branch is in sync with the main branch
  • make sure you add some unit tests (I pointed out where this is needed in the code)
  • add some simple integration tests as well (you can find some example here)
  • make sure lint tests pass

Thanks for your patience!

@GGabriele
Copy link
Collaborator

@DanielRailean nice improvements!

Feel free to "pin" the diff integration tests for post-3.x versions to avoid failures due to schema changes.

For example:

-                       runWhen(t, "kong", ">=3.0.0")
+                       runWhen(t, "kong", ">=3.0.0 <3.1.0")

DanielRailean and others added 2 commits July 19, 2023 11:01
Co-authored-by: Gabriele <gabrielegerbino@gmail.com>
Co-authored-by: Gabriele <gabrielegerbino@gmail.com>
Co-authored-by: Gabriele <gabrielegerbino@gmail.com>
@codecov-commenter
Copy link

codecov-commenter commented Jul 19, 2023

Codecov Report

Patch coverage: 0.80% and project coverage change: -0.33 ⚠️

Comparison is base (9aa351b) 34.03% compared to head (990ac49) 33.70%.

❗ Current head 990ac49 differs from pull request most recent head 66698e6. Consider uploading reports for the commit 66698e6 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #798      +/-   ##
==========================================
- Coverage   34.03%   33.70%   -0.33%     
==========================================
  Files         100      100              
  Lines       11884    12000     +116     
==========================================
  Hits         4045     4045              
- Misses       7446     7562     +116     
  Partials      393      393              
Impacted Files Coverage Δ
cmd/common.go 4.29% <0.00%> (-0.81%) ⬇️
cmd/common_konnect.go 6.71% <0.00%> (ø)
cmd/diff.go 0.00% <0.00%> (ø)
cmd/reset.go 0.00% <0.00%> (ø)
cmd/sync.go 0.00% <0.00%> (ø)
cmd/validate.go 0.00% <0.00%> (ø)
cprint/color.go 82.85% <0.00%> (-7.77%) ⬇️
diff/diff.go 0.00% <0.00%> (ø)
utils/types.go 14.12% <0.00%> (-0.59%) ⬇️
diff/diff_helpers.go 70.73% <100.00%> (ø)

... and 7 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@DanielRailean
Copy link
Contributor Author

was trying to test the v3.0.0 but if you're ok with it, I'm giving up on them.

@GGabriele
Copy link
Collaborator

was trying to test the v3.0.0 but if you're ok with it, I'm giving up on them.

Feel free to give up on them. The easy alternative would be to create expectedOutputUnMasked30x and expectedOutputMasked30x to hold the diff without the error_code and error_message fields.

I'm okay either ways.

@DanielRailean
Copy link
Contributor Author

Thanks for the approval :)
Do you have a time estimate when you think it could be merged?

@GGabriele
Copy link
Collaborator

Do you want to manually squash it and add some description in your commit? Otherwise I'll squash myself via GH and merge it right away.

This should be released later today :)

Thanks for your great work and apologies once more for the looong delay.

@DanielRailean
Copy link
Contributor Author

I don't think I have the permissions to squash. (or maybe it's because of some of the failed actions), so it's better if you do it 😃

Thank you too for the help and patience. 🚀

@GGabriele GGabriele merged commit 7352609 into Kong:main Jul 19, 2023
18 of 34 checks passed
@DanielRailean DanielRailean deleted the feat/json-output branch July 19, 2023 09:50
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