Skip to content

Commit

Permalink
spec: fix CI errors
Browse files Browse the repository at this point in the history
  • Loading branch information
AstroProfundis committed Feb 24, 2021
1 parent 5689500 commit 196c6be
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pkg/cluster/spec/grafana.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func (i *GrafanaInstance) InitConfig(
if (val == reflect.Value{}) {
return errors.Errorf("field Monitors not found in topology: %v", topo)
}
monitors := val.Interface().([]PrometheusSpec)
monitors := val.Interface().([]*PrometheusSpec)
// transfer datasource.yml
if len(monitors) == 0 {
return errors.New("no prometheus found in topology")
Expand Down
2 changes: 1 addition & 1 deletion pkg/cluster/spec/parse_topology.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func ExpandRelativeDir(topo Topology) {
}

func expandRelativePath(user string, topo interface{}) {
v := reflect.ValueOf(topo).Elem()
v := reflect.Indirect(reflect.ValueOf(topo).Elem())

switch v.Kind() {
case reflect.Slice:
Expand Down
6 changes: 3 additions & 3 deletions pkg/cluster/spec/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,16 +240,16 @@ func (i *MonitorInstance) InitConfig(
}
if servers, found := topoHasField("Masters"); found {
for i := 0; i < servers.Len(); i++ {
master := servers.Index(i)
master := reflect.Indirect(servers.Index(i))
host, port := master.FieldByName("Host").String(), master.FieldByName("Port").Int()
cfig.AddDMMaster(host, uint64(port))
}
}

if servers, found := topoHasField("Workers"); found {
for i := 0; i < servers.Len(); i++ {
master := servers.Index(i)
host, port := master.FieldByName("Host").String(), master.FieldByName("Port").Int()
worker := reflect.Indirect(servers.Index(i))
host, port := worker.FieldByName("Host").String(), worker.FieldByName("Port").Int()
cfig.AddDMWorker(host, uint64(port))
}
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/cluster/spec/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,11 +494,11 @@ func setCustomDefaults(globalOptions *GlobalOptions, field reflect.Value) error
if field.Field(j).String() != "" {
continue
}
host := field.FieldByName("Host").String()
clientPort := field.FieldByName("ClientPort").Int()
host := reflect.Indirect(field).FieldByName("Host").String()
clientPort := reflect.Indirect(field).FieldByName("ClientPort").Int()
field.Field(j).Set(reflect.ValueOf(fmt.Sprintf("pd-%s-%d", host, clientPort)))
case "DataDir":
if field.FieldByName("Imported").Interface().(bool) {
if reflect.Indirect(field).FieldByName("Imported").Interface().(bool) {
setDefaultDir(globalOptions.DataDir, field.Addr().Interface().(InstanceSpec).Role(), getPort(field), field.Field(j))
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/cluster/spec/tispark.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ type TiSparkMasterInstance struct {

// GetCustomFields get custom spark configs of the instance
func (i *TiSparkMasterInstance) GetCustomFields() map[string]interface{} {
v := reflect.ValueOf(i.InstanceSpec).FieldByName("SparkConfigs")
v := reflect.Indirect(reflect.ValueOf(i.InstanceSpec)).FieldByName("SparkConfigs")
if !v.IsValid() {
return nil
}
Expand All @@ -180,7 +180,7 @@ func (i *TiSparkMasterInstance) GetCustomFields() map[string]interface{} {

// GetCustomEnvs get custom spark envionment variables of the instance
func (i *TiSparkMasterInstance) GetCustomEnvs() map[string]string {
v := reflect.ValueOf(i.InstanceSpec).FieldByName("SparkEnvs")
v := reflect.Indirect(reflect.ValueOf(i.InstanceSpec)).FieldByName("SparkEnvs")
if !v.IsValid() {
return nil
}
Expand All @@ -189,7 +189,7 @@ func (i *TiSparkMasterInstance) GetCustomEnvs() map[string]string {

// GetJavaHome returns the java_home value in spec
func (i *TiSparkMasterInstance) GetJavaHome() string {
return reflect.ValueOf(i.InstanceSpec).FieldByName("JavaHome").String()
return reflect.Indirect(reflect.ValueOf(i.InstanceSpec)).FieldByName("JavaHome").String()
}

// InitConfig implement Instance interface
Expand Down Expand Up @@ -338,7 +338,7 @@ type TiSparkWorkerInstance struct {

// GetJavaHome returns the java_home value in spec
func (i *TiSparkWorkerInstance) GetJavaHome() string {
return reflect.ValueOf(i.InstanceSpec).FieldByName("JavaHome").String()
return reflect.Indirect(reflect.ValueOf(i.InstanceSpec)).FieldByName("JavaHome").String()
}

// InitConfig implement Instance interface
Expand Down

0 comments on commit 196c6be

Please sign in to comment.