robocanic commented on code in PR #1371:
URL: https://github.com/apache/dubbo-admin/pull/1371#discussion_r2636734134


##########
pkg/core/resource/apis/mesh/v1alpha1/zkmetadata_types.go:
##########
@@ -0,0 +1,188 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// Generated by tools/resourcegen
+// Run "make generate" to update this file.
+
+// nolint:whitespace
+package v1alpha1
+
+import (
+       "encoding/json"
+
+       "google.golang.org/protobuf/proto"
+       metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+       k8sruntime "k8s.io/apimachinery/pkg/runtime"
+
+       meshproto "github.com/apache/dubbo-admin/api/mesh/v1alpha1"
+       "github.com/apache/dubbo-admin/pkg/core/logger"
+       coremodel "github.com/apache/dubbo-admin/pkg/core/resource/model"
+)
+
+const ZKMetadataKind coremodel.ResourceKind = "ZKMetadata"
+
+func init() {
+       coremodel.RegisterResourceSchema(ZKMetadataKind, NewZKMetadataResource, 
NewZKMetadataResourceList)
+}
+
+type ZKMetadataResource struct {
+       metav1.TypeMeta `json:",inline"`
+
+       metav1.ObjectMeta `json:"metadata,omitempty"`
+
+       // Mesh is the name of the dubbo mesh this resource belongs to.
+       // It may be omitted for cluster-scoped resources.
+       Mesh string `json:"mesh,omitempty"`
+
+       // Spec is the specification of the Dubbo ZKMetadata resource.
+       Spec *meshproto.ZKMetadata `json:"spec,omitempty"`
+
+       // Status is the status of the Dubbo ZKMetadata resource.
+       Status ZKMetadataResourceStatus `json:"status,omitempty"`
+}
+
+type ZKMetadataResourceStatus struct {
+       // define resource-specific status here
+}
+
+func (r *ZKMetadataResource) ResourceKind() coremodel.ResourceKind {
+       return ZKMetadataKind
+}
+
+func (r *ZKMetadataResource) MeshName() string {
+       return r.Mesh
+}
+
+func (r *ZKMetadataResource) ResourceKey() string {
+       return coremodel.BuildResourceKey(r.Mesh, r.Name)
+}
+
+func (r *ZKMetadataResource) ResourceMeta() metav1.ObjectMeta {
+       return r.ObjectMeta
+}
+
+func (r *ZKMetadataResource) ResourceSpec() coremodel.ResourceSpec {
+       return r.Spec
+}
+
+func (r *ZKMetadataResource) DeepCopyObject() k8sruntime.Object {
+       out := &ZKMetadataResource{
+               TypeMeta: r.TypeMeta,
+               Mesh:     r.Mesh,
+               Status:   r.Status,
+       }
+
+       r.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
+
+       if r.Spec != nil {
+               spec, ok := proto.Clone(r.Spec).(*meshproto.ZKMetadata)
+               if !ok {
+                       logger.Warnf("failed to clone spec %v, spec is not 
conformed to %s", r.Spec, r.ResourceKind())
+                       return out
+               }
+               out.Spec = spec
+       }
+
+       return out
+}
+
+func (r *ZKMetadataResource) String() string {
+       jsonStr, err := json.Marshal(r)
+       if err != nil {
+               logger.Errorf("failed to encode ZKMetadataResource: %s to json, 
err: %w", r.ResourceKey(), err)

Review Comment:
   fixed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to