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

Support of Istio Client API #3613

Merged
merged 8 commits into from
Dec 14, 2021
Merged

Support of Istio Client API #3613

merged 8 commits into from
Dec 14, 2021

Conversation

Sgitario
Copy link
Contributor

This PR supports v1alpha3 and v1beta1 Istio API
Solution is based on https://github.com/snowdrop/istio-java-api
Tests have been moved from the above repository to here.
Fixes #3593

Apart from adding the Istio API, we added two changes to the GO generator:

  • Ability to extract the field name from the protobug tag: this is optional and only enabled by a flag
  • Fix mapping of float numbers
    These changes are in separated commits.

@Sgitario
Copy link
Contributor Author

fyi @metacosm

@rohanKanojia
Copy link
Member

rohanKanojia commented Nov 24, 2021

Have you copy-pasted code from Istio Java API? Please preserve commit history We did something similar while porting Service Catalog extension #1605 (review)

@Sgitario
Copy link
Contributor Author

Sgitario commented Nov 24, 2021

Have you copy-pasted code from Istio Java API? Please preserve commit history We did something similar while porting Service Catalog extension #1605 (review)

I didn't copy pasted code from the snowdrop repo. I only used the snowdrop repo as a reference ++ migrated the tests to here.

@Sgitario Sgitario requested a review from metacosm November 25, 2021 06:08
Copy link
Member

@manusa manusa left a comment

Choose a reason for hiding this comment

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

LGTM, with some comments:

  • I think we can fix the most of the test related code smells
  • Some tests are failing on Windows

@Sgitario
Copy link
Contributor Author

FYI, I'm investigating the issue with windows.

@Sgitario
Copy link
Contributor Author

Fixed the Windows check

@rbaeurle
Copy link

rbaeurle commented Dec 3, 2021

I could verify that this PR seems to work fine for us.

Sometimes the go struct is defined like:

```go
type MyClass struct {
   GoField *GoType `protobuf:"...,json=goField,proto3" json:"go_field,omitempty"`
}
```

The json field is wrong ("go_field") and the protobuf field is right "goField". 
I would say that this is a wrong model, however this is a solution to pick the values from the protobuf section.
The "float" is mapped to Object by the json2pojo plugin. 
Using "number" will map the property to "double".
This PR supports v1alpha3 and v1beta1 Istio API
Solution is based on https://github.com/snowdrop/istio-java-api
Tests have been moved from the above repository to here.
Fixes fabric8io#3593
@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 86 Code Smells

0.0% 0.0% Coverage
12.0% 12.0% Duplication

Copy link
Collaborator

@metacosm metacosm left a comment

Choose a reason for hiding this comment

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

Great job overall!
A few comments, though:

  • We probably need to document how to migrate to this new version since some method names have changed and, obviously, the packages are now different
  • This PR only covers the networking part of the Istio API. While this should cover quite a bit of what people use, there are several other APIs that would need to be ported/updated to match what was available in the istio-java-api project (mesh, policy, rbac, security and mixer APIs are missing). Not all of them might need to be ported since some of these are actually obsolete but this is still something that needs to be investigated.
  • The istio-java-api project also provided a CEL (https://opensource.google/projects/cel) parser via ANTLR to support validation of some of the configuration fields. Relevance to this new version needs to be assessed as well.
  • Basically, we need someone who routinely uses Istio to support this API to make sure that the relevant parts are covered correctly.

@manusa manusa added this to the 5.11.0 milestone Dec 14, 2021
README.md Show resolved Hide resolved
extensions/istio/client/pom.xml Show resolved Hide resolved

@Override
public Class<V1alpha3APIGroupDSL> getExtensionType() {
return V1alpha3APIGroupDSL.class;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return V1alpha3APIGroupDSL.class;
return V1beta1APIGroupClient.class;

@rohanKanojia
Copy link
Member

There doesn't seem to be any CRUD test for any resource. Would be nice to add some Crud tests to test suite as well.

@Sgitario
Copy link
Contributor Author

There doesn't seem to be any CRUD test for any resource. Would be nice to add some Crud tests to test suite as well.

Thanks for your review! I will update the PR asap.
One question about the missing CRUD tests: we have tests for create/delete/get only for the latest api v1beta1, example: https://github.com/fabric8io/kubernetes-client/blob/7f9cb03a01d37015268a35ccffe824f7c82f009d/extensions/istio/tests/src/test/java/io/fabric8/istio/test/v1beta1/AuthorizationPolicyTest.java

Do you mean to also cover updates in these resources or something else?

@rohanKanojia
Copy link
Member

Sorry for not being clear, I was referring to CRUD mode in MockServer. You don't need to add expectations in this mode. Here is an example:
https://github.com/fabric8io/kubernetes-client/blob/master/extensions/camel-k/tests/src/test/java/io/fabric8/camelk/test/crud/IntegrationCrudTest.java#L29

@manusa manusa merged commit 1478524 into fabric8io:master Dec 14, 2021
@manusa
Copy link
Member

manusa commented Dec 14, 2021

Sorry, I didn't read the comments, before merging (just saw the approval).

Could you add the requested changes to a new PR?

@Sgitario Sgitario deleted the good_istio branch December 15, 2021 04:59
@Sgitario
Copy link
Contributor Author

Sorry for not being clear, I was referring to CRUD mode in MockServer. You don't need to add expectations in this mode. Here is an example: https://github.com/fabric8io/kubernetes-client/blob/master/extensions/camel-k/tests/src/test/java/io/fabric8/camelk/test/crud/IntegrationCrudTest.java#L29

ok ok! I've added the crud flag to true in the v1beta1 VirtualService test.

Sgitario added a commit to Sgitario/kubernetes-client that referenced this pull request Dec 15, 2021
This PR fixes all the requested changes by Rohan in fabric8io#3613.
@Sgitario
Copy link
Contributor Author

Request changes fixed in #3650

manusa pushed a commit that referenced this pull request Dec 15, 2021
This PR fixes all the requested changes by Rohan in #3613.
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.

Support of Istio Client API Move Snowdrop Istio extension to Fabric8 Kubernetes Client Extensions
5 participants