-
Notifications
You must be signed in to change notification settings - Fork 960
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
Generate fluid-related clients to facilitate go client calls and watch-related resources #3468
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: lgy1027 <[email protected]>
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Hi @lgy1027. Thanks for your PR. I'm waiting for a fluid-cloudnative member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Codecov Report
@@ Coverage Diff @@
## master #3468 +/- ##
==========================================
- Coverage 64.29% 64.28% -0.02%
==========================================
Files 442 443 +1
Lines 26452 26454 +2
==========================================
- Hits 17007 17005 -2
- Misses 7440 7443 +3
- Partials 2005 2006 +1
|
/test fluid-e2e |
Fluid is built by controller runtime and code generation with kubebuilder. I'm wondering if this change can still be compatible with kubebuilder. |
This modification is only to facilitate Go to operate fluid, and also uses code-generator to generate client-related code. In my opinion, it is not intrusive to the original code. As for the submitted script, I can actually delete it. I feel that the official https:// github.com/fluid-cloudnative/fluid/blob/master/docs/zh/dev/use_go_create_resource.md is a bit troublesome to operate, including resource watch |
Add related clients for easy operation. If you make changes and need to regenerate, just execute the script. Some modifications need to be made in the API structure.
Example:
`import (
"context"
"fmt"
"github.com/fluid-cloudnative/fluid/api/v1alpha1"
"github.com/fluid-cloudnative/fluid/pkg/apis/client/clientset/versioned"
"github.com/fluid-cloudnative/fluid/pkg/apis/client/informers/externalversions"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/tools/clientcmd"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"time"
)
const defaultResync = 600 * time.Second
var (
finalizerName = "data.fluid.io/finalizer"
)
func main() {
config, err := clientcmd.BuildConfigFromFlags("", "config")
if err != nil {
panic(err)
}
config.QPS = 1e6
config.Burst = 1e6
client, err := versioned.NewForConfig(config)
if err != nil {
panic(err)
}
informerFactory := externalversions.NewSharedInformerFactory(client, defaultResync)
}`