Merge pull request #586 from weilaaa/fix/remove-duplicated-constants

remove duplicated constants in binding.go
This commit is contained in:
karmada-bot 2021-08-09 09:31:12 +08:00 committed by GitHub
commit 8088121b82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 9 deletions

View File

@ -26,13 +26,6 @@ import (
"github.com/karmada-io/karmada/pkg/util/restmapper" "github.com/karmada-io/karmada/pkg/util/restmapper"
) )
const (
// SpecField indicates the 'spec' field of a deployment
SpecField = "spec"
// ReplicasField indicates the 'replicas' field of a deployment
ReplicasField = "replicas"
)
// ClusterWeightInfo records the weight of a cluster // ClusterWeightInfo records the weight of a cluster
type ClusterWeightInfo struct { type ClusterWeightInfo struct {
ClusterName string ClusterName string
@ -396,12 +389,12 @@ func calculateReplicas(c client.Client, policy *v1alpha1.ReplicaSchedulingPolicy
} }
func applyReplicaSchedulingPolicy(workload *unstructured.Unstructured, desireReplica int64) error { func applyReplicaSchedulingPolicy(workload *unstructured.Unstructured, desireReplica int64) error {
_, ok, err := unstructured.NestedInt64(workload.Object, SpecField, ReplicasField) _, ok, err := unstructured.NestedInt64(workload.Object, util.SpecField, util.ReplicasField)
if err != nil { if err != nil {
return err return err
} }
if ok { if ok {
err := unstructured.SetNestedField(workload.Object, desireReplica, SpecField, ReplicasField) err := unstructured.SetNestedField(workload.Object, desireReplica, util.SpecField, util.ReplicasField)
if err != nil { if err != nil {
return err return err
} }