mirror of
https://github.com/rancher/types.git
synced 2025-08-31 21:00:16 +00:00
Add Prometheus operrator crds into schema
This commit is contained in:
committed by
Craig Jellick
parent
6adc7c9769
commit
25fb96b983
@@ -3,6 +3,7 @@ package schema
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
monitoringv1 "github.com/coreos/prometheus-operator/pkg/client/monitoring/v1"
|
||||
"github.com/rancher/norman/types"
|
||||
m "github.com/rancher/norman/types/mapper"
|
||||
"github.com/rancher/types/apis/project.cattle.io/v3"
|
||||
@@ -42,7 +43,8 @@ var (
|
||||
Init(podTemplateSpecTypes).
|
||||
Init(workloadTypes).
|
||||
Init(appTypes).
|
||||
Init(pipelineTypes)
|
||||
Init(pipelineTypes).
|
||||
Init(monitoringTypes)
|
||||
)
|
||||
|
||||
func configMapTypes(schemas *types.Schemas) *types.Schemas {
|
||||
@@ -923,3 +925,88 @@ func pipelineTypes(schema *types.Schemas) *types.Schemas {
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
func monitoringTypes(schemas *types.Schemas) *types.Schemas {
|
||||
return schemas.
|
||||
AddMapperForType(&Version, monitoringv1.StorageSpec{},
|
||||
&m.Drop{Field: "class"},
|
||||
&m.Drop{Field: "selector"},
|
||||
&m.Drop{Field: "resources"},
|
||||
).
|
||||
AddMapperForType(&Version, monitoringv1.Prometheus{},
|
||||
&m.Drop{Field: "status"},
|
||||
&m.AnnotationField{Field: "description"},
|
||||
).
|
||||
AddMapperForType(&Version, monitoringv1.PrometheusSpec{},
|
||||
&m.Drop{Field: "thanos"},
|
||||
&m.Drop{Field: "apiserverConfig"},
|
||||
&m.Drop{Field: "serviceMonitorNamespaceSelector"},
|
||||
&m.Drop{Field: "ruleNamespaceSelector"},
|
||||
&m.Drop{Field: "paused"},
|
||||
&m.Enum{
|
||||
Field: "logLevel",
|
||||
Options: []string{
|
||||
"all",
|
||||
"debug",
|
||||
"info",
|
||||
"warn",
|
||||
"error",
|
||||
"none",
|
||||
},
|
||||
},
|
||||
).
|
||||
MustImportAndCustomize(&Version, monitoringv1.Prometheus{}, func(schema *types.Schema) {
|
||||
schema.MustCustomizeField("name", func(field types.Field) types.Field {
|
||||
field.Type = "dnsLabelRestricted"
|
||||
field.Nullable = false
|
||||
field.Required = true
|
||||
return field
|
||||
})
|
||||
}, projectOverride{}, struct {
|
||||
Description string `json:"description"`
|
||||
}{}).
|
||||
AddMapperForType(&Version, monitoringv1.RelabelConfig{},
|
||||
&m.Enum{
|
||||
Field: "action",
|
||||
Options: []string{
|
||||
"replace",
|
||||
"keep",
|
||||
"drop",
|
||||
"hashmod",
|
||||
"labelmap",
|
||||
"labeldrop",
|
||||
"labelkeep",
|
||||
},
|
||||
},
|
||||
).
|
||||
AddMapperForType(&Version, monitoringv1.Endpoint{},
|
||||
&m.Drop{Field: "port"},
|
||||
&m.Drop{Field: "tlsConfig"},
|
||||
&m.Drop{Field: "bearerTokenFile"},
|
||||
&m.Drop{Field: "honorLabels"},
|
||||
&m.Drop{Field: "basicAuth"},
|
||||
&m.Drop{Field: "metricRelabelings"},
|
||||
&m.Drop{Field: "proxyUrl"},
|
||||
).
|
||||
AddMapperForType(&Version, monitoringv1.ServiceMonitorSpec{},
|
||||
&m.Embed{Field: "namespaceSelector"},
|
||||
&m.Drop{Field: "any"},
|
||||
&m.Move{From: "matchNames", To: "namespaceSelector"},
|
||||
).
|
||||
AddMapperForType(&Version, monitoringv1.ServiceMonitor{},
|
||||
&m.AnnotationField{Field: "displayName"},
|
||||
&m.DisplayName{},
|
||||
&m.AnnotationField{Field: "targetService"},
|
||||
&m.AnnotationField{Field: "targetWorkload"},
|
||||
).
|
||||
MustImport(&Version, monitoringv1.ServiceMonitor{}, projectOverride{}, struct {
|
||||
DisplayName string `json:"displayName,omitempty"`
|
||||
TargetService string `json:"targetService,omitempty"`
|
||||
TargetWorkload string `json:"targetWorkload,omitempty"`
|
||||
}{}).
|
||||
MustImport(&Version, monitoringv1.PrometheusRule{}, projectOverride{}).
|
||||
AddMapperForType(&Version, monitoringv1.Alertmanager{},
|
||||
&m.Drop{Field: "status"},
|
||||
).
|
||||
MustImport(&Version, monitoringv1.Alertmanager{}, projectOverride{})
|
||||
}
|
||||
|
Reference in New Issue
Block a user