apache / rocketmq-operator

Apache RocketMQ Operator
https://rocketmq.apache.org/
Apache License 2.0
309 stars 126 forks source link

got error when import pkg/apis/rocketmq to get broker list #168

Closed drivebyer closed 10 months ago

drivebyer commented 11 months ago

Hello Developers,

I am using the rocketmq-operator to manage multiple rocketmq clusters. I plan to write a management tool in Go to carry out some other operations. My approach is to import the pkg/apis/rocketmq package, then use client-go to get the current broker clusters in k8s. The code looks something like this:

data := &operatorv1alpha1.Broker{
    ObjectMeta: metav1.ObjectMeta{
        Name:      req.Name,
        Namespace: req.Namespace,
    },
}
err = client.Get(ctx, client.ObjectKeyFromObject(data), data)
if err != nil {
    return nil, err
}

However, I am getting an error message:

Cannot use 'data' (type *operatorv1alpha1.Broker) as the type Object Type does not implement 'Object' as some methods are missing: DeepCopyObject() Object

I later realized this is because certain relevant files were ignored during upload. See https://github.com/apache/rocketmq-operator/blob/007810f70d814505a66cfcdb8631e51b52a74df6/.gitignore#L89

I suggest that these files be uploaded to the GitHub repository, so that third-party users can more conveniently refer to this api module.