Skip to content

Commit

Permalink
add Monitor Portname access
Browse files Browse the repository at this point in the history
  • Loading branch information
Song Gao committed Jan 17, 2020
1 parent bacda91 commit 73f8ebb
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
29 changes: 29 additions & 0 deletions pkg/apis/pingcap/v1alpha1/tidbmonitor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright 2019 PingCAP, Inc.
//
// Licensed 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,
// See the License for the specific language governing permissions and
// limitations under the License.

package v1alpha1

func (tm *TidbMonitor) PrometheusPortName() *string {
return tm.Spec.Prometheus.Service.PortName
}

func (tm *TidbMonitor) GrafanaPortName() *string {
if tm.Spec.Grafana != nil {
return tm.Spec.Grafana.Service.PortName
}
return nil
}

func (tm *TidbMonitor) ReloaderPortName() *string {
return tm.Spec.Reloader.Service.PortName
}
6 changes: 3 additions & 3 deletions pkg/monitor/monitor/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -643,13 +643,13 @@ func getMonitorService(monitor *v1alpha1.TidbMonitor) []*core.Service {
prometheusPortName := "http-prometheus"
grafanaPortName := "http-grafana"

if monitor.Spec.Reloader.Service.PortName != nil {
if monitor.ReloaderPortName() != nil {
reloaderPortName = *monitor.Spec.Reloader.Service.PortName
}
if monitor.Spec.Prometheus.Service.PortName != nil {
if monitor.PrometheusPortName() != nil {
prometheusPortName = *monitor.Spec.Prometheus.Service.PortName
}
if monitor.Spec.Grafana != nil && monitor.Spec.Grafana.Service.PortName != nil {
if monitor.GrafanaPortName() != nil {
grafanaPortName = *monitor.Spec.Grafana.Service.PortName
}

Expand Down

0 comments on commit 73f8ebb

Please sign in to comment.