From cbda8520cf7fc59f136e540272e1e2bed5a235e8 Mon Sep 17 00:00:00 2001 From: nexustar Date: Wed, 9 Aug 2023 16:01:03 +0800 Subject: [PATCH] fix --- components/dm/spec/topology_dm.go | 10 ++++------ pkg/cluster/spec/cdc.go | 5 ++--- pkg/cluster/spec/dashboard.go | 5 ++--- pkg/cluster/spec/drainer.go | 5 ++--- pkg/cluster/spec/instance.go | 5 ++--- pkg/cluster/spec/pd.go | 5 ++--- pkg/cluster/spec/pump.go | 7 +++---- pkg/cluster/spec/tidb.go | 5 ++--- pkg/cluster/spec/tiflash.go | 5 ++--- pkg/cluster/spec/tikv.go | 5 ++--- pkg/cluster/spec/tikv_cdc.go | 5 ++--- 11 files changed, 25 insertions(+), 37 deletions(-) diff --git a/components/dm/spec/topology_dm.go b/components/dm/spec/topology_dm.go index d2015bac84..6e073fb7c3 100644 --- a/components/dm/spec/topology_dm.go +++ b/components/dm/spec/topology_dm.go @@ -205,11 +205,10 @@ func (s *MasterSpec) GetAdvertisePeerURL(enableTLS bool) string { // GetSource returns source to download the component func (s *MasterSpec) GetSource() string { - if s.Source != "" { - return s.Source - } else { + if s.Source == "" { return ComponentDMMaster } + return s.Source } // WorkerSpec represents the Master topology specification in topology.yaml @@ -285,11 +284,10 @@ func (s *WorkerSpec) IgnoreMonitorAgent() bool { // GetSource returns source to download the component func (s *WorkerSpec) GetSource() string { - if s.Source != "" { - return s.Source - } else { + if s.Source == "" { return ComponentDMWorker } + return s.Source } // UnmarshalYAML sets default values when unmarshaling the topology file diff --git a/pkg/cluster/spec/cdc.go b/pkg/cluster/spec/cdc.go index b3d1a3d69d..5ba4646f3b 100644 --- a/pkg/cluster/spec/cdc.go +++ b/pkg/cluster/spec/cdc.go @@ -94,11 +94,10 @@ func (s *CDCSpec) IgnoreMonitorAgent() bool { // GetSource returns source to download the component func (s *CDCSpec) GetSource() string { - if s.Source != "" { - return s.Source - } else { + if s.Source == "" { return ComponentCDC } + return s.Source } // CDCComponent represents CDC component. diff --git a/pkg/cluster/spec/dashboard.go b/pkg/cluster/spec/dashboard.go index a42ea65efe..75f36db7f2 100644 --- a/pkg/cluster/spec/dashboard.go +++ b/pkg/cluster/spec/dashboard.go @@ -97,11 +97,10 @@ func (s *DashboardSpec) IgnoreMonitorAgent() bool { // GetSource returns source to download the component func (s *DashboardSpec) GetSource() string { - if s.Source != "" { - return s.Source - } else { + if s.Source == "" { return ComponentDashboard } + return s.Source } // DashboardComponent represents Drainer component. diff --git a/pkg/cluster/spec/drainer.go b/pkg/cluster/spec/drainer.go index 39cf0ee53e..1ad3360a82 100644 --- a/pkg/cluster/spec/drainer.go +++ b/pkg/cluster/spec/drainer.go @@ -115,11 +115,10 @@ func (s *DrainerSpec) IgnoreMonitorAgent() bool { // GetSource returns source to download the component func (s *DrainerSpec) GetSource() string { - if s.Source != "" { - return s.Source - } else { + if s.Source == "" { return ComponentDrainer } + return s.Source } // DrainerComponent represents Drainer component. diff --git a/pkg/cluster/spec/instance.go b/pkg/cluster/spec/instance.go index b7a203ff0e..769ec93bd4 100644 --- a/pkg/cluster/spec/instance.go +++ b/pkg/cluster/spec/instance.go @@ -306,11 +306,10 @@ func (i *BaseInstance) ComponentName() string { // ComponentSource implements Instance interface func (i *BaseInstance) ComponentSource() string { - if i.Source != "" { - return i.Source - } else { + if i.Source == "" { return i.Name } + return i.Source } // InstanceName implements Instance interface diff --git a/pkg/cluster/spec/pd.go b/pkg/cluster/spec/pd.go index d512681d27..008d1917da 100644 --- a/pkg/cluster/spec/pd.go +++ b/pkg/cluster/spec/pd.go @@ -140,11 +140,10 @@ func (s *PDSpec) GetAdvertisePeerURL(enableTLS bool) string { // GetSource returns source to download the component func (s *PDSpec) GetSource() string { - if s.Source != "" { - return s.Source - } else { + if s.Source == "" { return ComponentPD } + return s.Source } // PDComponent represents PD component. diff --git a/pkg/cluster/spec/pump.go b/pkg/cluster/spec/pump.go index 39b64085e5..7428105d08 100644 --- a/pkg/cluster/spec/pump.go +++ b/pkg/cluster/spec/pump.go @@ -114,11 +114,10 @@ func (s *PumpSpec) IgnoreMonitorAgent() bool { // GetSource returns source to download the component func (s *PumpSpec) GetSource() string { - if s.Source != "" { - return s.Source - } else { - return ComponentCDC + if s.Source == "" { + return ComponentPump } + return s.Source } // PumpComponent represents Pump component. diff --git a/pkg/cluster/spec/tidb.go b/pkg/cluster/spec/tidb.go index 77ecd4818f..668bc15e57 100644 --- a/pkg/cluster/spec/tidb.go +++ b/pkg/cluster/spec/tidb.go @@ -91,11 +91,10 @@ func (s *TiDBSpec) IgnoreMonitorAgent() bool { // GetSource returns source to download the component func (s *TiDBSpec) GetSource() string { - if s.Source != "" { - return s.Source - } else { + if s.Source == "" { return ComponentTiDB } + return s.Source } // TiDBComponent represents TiDB component. diff --git a/pkg/cluster/spec/tiflash.go b/pkg/cluster/spec/tiflash.go index c4516212e1..d19eab1f92 100644 --- a/pkg/cluster/spec/tiflash.go +++ b/pkg/cluster/spec/tiflash.go @@ -164,11 +164,10 @@ func (s *TiFlashSpec) IgnoreMonitorAgent() bool { // GetSource returns source to download the component func (s *TiFlashSpec) GetSource() string { - if s.Source != "" { - return s.Source - } else { + if s.Source == "" { return ComponentTiFlash } + return s.Source } // key names for storage config diff --git a/pkg/cluster/spec/tikv.go b/pkg/cluster/spec/tikv.go index dabe96ebdd..270bae06c2 100644 --- a/pkg/cluster/spec/tikv.go +++ b/pkg/cluster/spec/tikv.go @@ -166,11 +166,10 @@ func (s *TiKVSpec) Labels() (map[string]string, error) { // GetSource returns source to download the component func (s *TiKVSpec) GetSource() string { - if s.Source != "" { - return s.Source - } else { + if s.Source == "" { return ComponentTiKV } + return s.Source } // TiKVComponent represents TiKV component. diff --git a/pkg/cluster/spec/tikv_cdc.go b/pkg/cluster/spec/tikv_cdc.go index 1406834424..55c393d099 100644 --- a/pkg/cluster/spec/tikv_cdc.go +++ b/pkg/cluster/spec/tikv_cdc.go @@ -107,11 +107,10 @@ func (c *TiKVCDCComponent) Role() string { // GetSource returns source to download the component func (s *TiKVCDCSpec) GetSource() string { - if s.Source != "" { - return s.Source - } else { + if s.Source == "" { return ComponentTiKVCDC } + return s.Source } // Instances implements Component interface.