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

avoid escaping json schema and fix bugs related to multi-level dynamic object #272

Merged
merged 4 commits into from
Oct 18, 2021
Merged

avoid escaping json schema and fix bugs related to multi-level dynamic object #272

merged 4 commits into from
Oct 18, 2021

Conversation

localvar
Copy link
Collaborator

No description provided.

@localvar localvar changed the title fix multi-level custom object json marshal error fix multi-level custom resource json marshal error Sep 24, 2021
Copy link

@megaeasex megaeasex left a comment

Choose a reason for hiding this comment

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

[TASK:easegress-pr-test FAILED]megaease/easegress Pull Request 272 Deploy Test failed

@codecov-commenter
Copy link

codecov-commenter commented Sep 24, 2021

Codecov Report

Merging #272 (89fd45e) into main (c0f5200) will increase coverage by 0.07%.
The diff coverage is 89.65%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #272      +/-   ##
==========================================
+ Coverage   80.22%   80.30%   +0.07%     
==========================================
  Files          53       53              
  Lines        5897     5926      +29     
==========================================
+ Hits         4731     4759      +28     
  Misses        907      907              
- Partials      259      260       +1     
Impacted Files Coverage Δ
pkg/object/meshcontroller/spec/spec.go 89.52% <89.65%> (+0.01%) ⬆️
pkg/object/mqttproxy/client.go 80.26% <0.00%> (+1.31%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c0f5200...89fd45e. Read the comment docs.

Copy link

@megaeasex megaeasex left a comment

Choose a reason for hiding this comment

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

[TASK:easegress-pr-test FAILED]megaease/easegress Pull Request 272 Deploy Test failed

@@ -312,6 +313,39 @@ func (cr CustomResource) Kind() string {
return ""
}

// MarshalJSON implements json.Marshaler
Copy link
Contributor

Choose a reason for hiding this comment

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

You can do a research of https://github.com/json-iterator/go , which might already have done it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, json-iterator can handle this case, thanks for the advice.

btw, I think the document of json-iterator is inaccurate as it says "100% compatible with encoding/json", at least in this case.

Copy link
Contributor

Choose a reason for hiding this comment

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

Compatible means it includes standard lib here. it depends on how you understand it. Golang1.17 is compatible with Golang 1.0 with bringing a lot of new features.

Copy link
Collaborator Author

@localvar localvar Sep 24, 2021

Choose a reason for hiding this comment

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

After thinking the issue twice, I think it is better to keep this function:

This function is always a correct solution, no matter we are using encoding/json or json-iterator.
If we remove it, then we are forcing future code to use json-iterator, but this is an implicit requirement, which means we are very possible to meet this bug again if encoding/json is used in new code.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, I have no opposite opinion

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because I found other issues with this implementation, I've moved the type conversion stuff to UnmarshalYAML.

Copy link

@megaeasex megaeasex left a comment

Choose a reason for hiding this comment

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

[TASK:easegress-pr-test SUCCESS]megaease/easegress Pull Request 272 Deploy Test Success

@localvar localvar marked this pull request as draft September 24, 2021 10:21
Copy link

@megaeasex megaeasex left a comment

Choose a reason for hiding this comment

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

[TASK:easegress-pr-test SUCCESS]megaease/easegress Pull Request 272 Deploy Test Success

Copy link

@megaeasex megaeasex left a comment

Choose a reason for hiding this comment

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

[TASK:easegress-pr-test SUCCESS]megaease/easegress Pull Request 272 Deploy Test Success

Copy link

@megaeasex megaeasex left a comment

Choose a reason for hiding this comment

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

[TASK:easegress-pr-test SUCCESS]megaease/easegress Pull Request 272 Deploy Test Success

@localvar localvar changed the title fix multi-level custom resource json marshal error avoid escaping json schema and fix bugs related to multi-level dynamic object Sep 26, 2021
@localvar localvar marked this pull request as ready for review September 26, 2021 02:12
Copy link

@megaeasex megaeasex left a comment

Choose a reason for hiding this comment

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

[TASK:easegress-pr-test SUCCESS]megaease/easegress Pull Request 272 Deploy Test Success

Copy link
Contributor

@benja-wu benja-wu left a comment

Choose a reason for hiding this comment

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

LGTM

@localvar localvar closed this Oct 12, 2021
@localvar localvar deleted the custom-object branch October 12, 2021 00:43
@localvar localvar restored the custom-object branch October 12, 2021 00:43
@localvar localvar reopened this Oct 12, 2021
Copy link

@megaeasex megaeasex left a comment

Choose a reason for hiding this comment

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

[TASK:easegress-pr-test SUCCESS]megaease/easegress Pull Request 272 Deploy Test Success

Copy link

@megaeasex megaeasex left a comment

Choose a reason for hiding this comment

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

[TASK:easegress-pr-test SUCCESS]megaease/easegress Pull Request 272 Deploy Test Success

@localvar localvar merged commit 265d91a into easegress-io:main Oct 18, 2021
@localvar localvar deleted the custom-object branch October 18, 2021 02:14
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.

None yet

6 participants