Skip to content

Commit 845f99c

Browse files
authored
[Feature] Allow to change ServiceMonitor labels (#812)
1 parent 876acfb commit 845f99c

11 files changed

+173
-10
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2016-2021 ArangoDB GmbH, Cologne, Germany
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
//
20+
21+
package v1
22+
23+
type MetricsServiceMonitorSpec struct {
24+
Enabled *bool `json:"enabled,omitempty"`
25+
Labels map[string]string `json:"labels,omitempty"`
26+
}
27+
28+
func (m *MetricsServiceMonitorSpec) IsEnabled() bool {
29+
if m == nil || m.Enabled == nil {
30+
return true
31+
}
32+
33+
return *m.Enabled
34+
}
35+
36+
func (m *MetricsServiceMonitorSpec) GetLabels(def map[string]string) map[string]string {
37+
if len(m.Labels) == 0 {
38+
return def
39+
}
40+
41+
return m.Labels
42+
}

pkg/apis/deployment/v1/metrics_spec.go renamed to pkg/apis/deployment/v1/deployment_metrics_spec.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ type MetricsSpec struct {
7474
Mode *MetricsMode `json:"mode,omitempty"`
7575
TLS *bool `json:"tls,omitempty"`
7676

77+
ServiceMonitor *MetricsServiceMonitorSpec `json:"serviceMonitor,omitempty"`
78+
7779
Port *uint16 `json:"port,omitempty"`
7880
}
7981

File renamed without changes.
File renamed without changes.

pkg/apis/deployment/v1/zz_generated.deepcopy.go

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2016-2021 ArangoDB GmbH, Cologne, Germany
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
//
20+
21+
package v2alpha1
22+
23+
type MetricsServiceMonitorSpec struct {
24+
Enabled *bool `json:"enabled,omitempty"`
25+
Labels map[string]string `json:"labels,omitempty"`
26+
}
27+
28+
func (m *MetricsServiceMonitorSpec) IsEnabled() bool {
29+
if m == nil || m.Enabled == nil {
30+
return true
31+
}
32+
33+
return *m.Enabled
34+
}
35+
36+
func (m *MetricsServiceMonitorSpec) GetLabels(def map[string]string) map[string]string {
37+
if len(m.Labels) == 0 {
38+
return def
39+
}
40+
41+
return m.Labels
42+
}

pkg/apis/deployment/v2alpha1/metrics_spec.go renamed to pkg/apis/deployment/v2alpha1/deployment_metrics_spec.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ type MetricsSpec struct {
7474
Mode *MetricsMode `json:"mode,omitempty"`
7575
TLS *bool `json:"tls,omitempty"`
7676

77+
ServiceMonitor *MetricsServiceMonitorSpec `json:"serviceMonitor,omitempty"`
78+
7779
Port *uint16 `json:"port,omitempty"`
7880
}
7981

File renamed without changes.

pkg/apis/deployment/v2alpha1/monitoring_spec_test.go renamed to pkg/apis/deployment/v2alpha1/sync_monitoring_spec_test.go

File renamed without changes.

pkg/apis/deployment/v2alpha1/zz_generated.deepcopy.go

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)