mirror of
https://github.com/prometheus-operator/prometheus-operator.git
synced 2025-04-09 02:24:16 +00:00
Fix prometheus types generation
This commit is contained in:
parent
348fd1636f
commit
2e1e1a4c01
4 changed files with 45 additions and 67 deletions
|
@ -72,12 +72,6 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
|
|||
Format: "",
|
||||
},
|
||||
},
|
||||
"metadata": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "Standard object’s metadata. More info: https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata",
|
||||
Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"),
|
||||
},
|
||||
},
|
||||
"spec": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "Specification of the desired behavior of the Alertmanager cluster. More info: https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status",
|
||||
|
@ -95,7 +89,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
|
|||
},
|
||||
},
|
||||
Dependencies: []string{
|
||||
"github.com/coreos/prometheus-operator/pkg/client/monitoring/v1.AlertmanagerSpec", "github.com/coreos/prometheus-operator/pkg/client/monitoring/v1.AlertmanagerStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"},
|
||||
"github.com/coreos/prometheus-operator/pkg/client/monitoring/v1.AlertmanagerSpec", "github.com/coreos/prometheus-operator/pkg/client/monitoring/v1.AlertmanagerStatus"},
|
||||
},
|
||||
"github.com/coreos/prometheus-operator/pkg/client/monitoring/v1.AlertmanagerEndpoints": {
|
||||
Schema: spec.Schema{
|
||||
|
@ -137,7 +131,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
|
|||
},
|
||||
},
|
||||
},
|
||||
Required: []string{"namespace", "name", "port", "scheme", "pathPrefix"},
|
||||
Required: []string{"namespace", "name", "port"},
|
||||
},
|
||||
},
|
||||
Dependencies: []string{
|
||||
|
@ -536,12 +530,6 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
|
|||
Format: "",
|
||||
},
|
||||
},
|
||||
"metadata": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "Standard object’s metadata. More info: https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata",
|
||||
Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"),
|
||||
},
|
||||
},
|
||||
"spec": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "Specification of the desired behavior of the Prometheus cluster. More info: https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status",
|
||||
|
@ -559,7 +547,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
|
|||
},
|
||||
},
|
||||
Dependencies: []string{
|
||||
"github.com/coreos/prometheus-operator/pkg/client/monitoring/v1.PrometheusSpec", "github.com/coreos/prometheus-operator/pkg/client/monitoring/v1.PrometheusStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"},
|
||||
"github.com/coreos/prometheus-operator/pkg/client/monitoring/v1.PrometheusSpec", "github.com/coreos/prometheus-operator/pkg/client/monitoring/v1.PrometheusStatus"},
|
||||
},
|
||||
"github.com/coreos/prometheus-operator/pkg/client/monitoring/v1.PrometheusList": {
|
||||
Schema: spec.Schema{
|
||||
|
@ -824,14 +812,13 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
|
|||
},
|
||||
},
|
||||
},
|
||||
"SecurityContext": {
|
||||
"securityContext": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "SecurityContext holds pod-level security attributes and common container settings. This defaults to non root user with uid 1000 and gid 2000 for Prometheus >v2.0 and default PodSecurityContext for other versions.",
|
||||
Ref: ref("k8s.io/api/core/v1.PodSecurityContext"),
|
||||
},
|
||||
},
|
||||
},
|
||||
Required: []string{"SecurityContext"},
|
||||
},
|
||||
},
|
||||
Dependencies: []string{
|
||||
|
@ -1100,12 +1087,6 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
|
|||
Format: "",
|
||||
},
|
||||
},
|
||||
"metadata": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "Standard object’s metadata. More info: https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata",
|
||||
Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"),
|
||||
},
|
||||
},
|
||||
"spec": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "Specification of desired Service selection for target discrovery by Prometheus.",
|
||||
|
@ -1117,7 +1098,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
|
|||
},
|
||||
},
|
||||
Dependencies: []string{
|
||||
"github.com/coreos/prometheus-operator/pkg/client/monitoring/v1.ServiceMonitorSpec", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"},
|
||||
"github.com/coreos/prometheus-operator/pkg/client/monitoring/v1.ServiceMonitorSpec"},
|
||||
},
|
||||
"github.com/coreos/prometheus-operator/pkg/client/monitoring/v1.ServiceMonitorList": {
|
||||
Schema: spec.Schema{
|
||||
|
|
|
@ -15,25 +15,19 @@
|
|||
package v1
|
||||
|
||||
import (
|
||||
spec "github.com/go-openapi/spec"
|
||||
"k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
)
|
||||
|
||||
// CustomResourceValidation is a list of validation methods for CustomResources.
|
||||
type CustomResourceValidation struct {
|
||||
// OpenAPIV3Schema is the OpenAPI v3 schema to be validated against.
|
||||
OpenAPIV3Schema *spec.Schema `json:"openAPIV3Schema,omitempty" protobuf:"bytes,1,opt,name=openAPIV3Schema"`
|
||||
}
|
||||
|
||||
// Prometheus defines a Prometheus deployment.
|
||||
// +k8s:openapi-gen=true
|
||||
type Prometheus struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
// Standard object’s metadata. More info:
|
||||
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata
|
||||
// +k8s:openapi-gen=false
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
// Specification of the desired behavior of the Prometheus cluster. More info:
|
||||
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status
|
||||
|
@ -131,7 +125,7 @@ type PrometheusSpec struct {
|
|||
// SecurityContext holds pod-level security attributes and common container settings.
|
||||
// This defaults to non root user with uid 1000 and gid 2000 for Prometheus >v2.0 and
|
||||
// default PodSecurityContext for other versions.
|
||||
SecurityContext *v1.PodSecurityContext
|
||||
SecurityContext *v1.PodSecurityContext `json:"securityContext,omitempty"`
|
||||
}
|
||||
|
||||
// Most recent observed status of the Prometheus cluster. Read-only. Not
|
||||
|
@ -258,9 +252,9 @@ type AlertmanagerEndpoints struct {
|
|||
// Port the Alertmanager API is exposed on.
|
||||
Port intstr.IntOrString `json:"port"`
|
||||
// Scheme to use when firing alerts.
|
||||
Scheme string `json:"scheme"`
|
||||
Scheme string `json:"scheme,omitempty"`
|
||||
// Prefix for the HTTP path alerts are pushed to.
|
||||
PathPrefix string `json:"pathPrefix"`
|
||||
PathPrefix string `json:"pathPrefix,omitempty"`
|
||||
}
|
||||
|
||||
// ServiceMonitor defines monitoring for a set of services.
|
||||
|
@ -269,6 +263,7 @@ type ServiceMonitor struct {
|
|||
metav1.TypeMeta `json:",inline"`
|
||||
// Standard object’s metadata. More info:
|
||||
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata
|
||||
// +k8s:openapi-gen=false
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
// Specification of desired Service selection for target discrovery by
|
||||
// Prometheus.
|
||||
|
@ -360,6 +355,7 @@ type Alertmanager struct {
|
|||
metav1.TypeMeta `json:",inline"`
|
||||
// Standard object’s metadata. More info:
|
||||
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata
|
||||
// +k8s:openapi-gen=false
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
// Specification of the desired behavior of the Alertmanager cluster. More info:
|
||||
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status
|
||||
|
|
|
@ -165,9 +165,9 @@ type AlertmanagerEndpoints struct {
|
|||
// Port the Alertmanager API is exposed on.
|
||||
Port intstr.IntOrString `json:"port"`
|
||||
// Scheme to use when firing alerts.
|
||||
Scheme string `json:"scheme"`
|
||||
Scheme string `json:"scheme,omitempty"`
|
||||
// Prefix for the HTTP path alerts are pushed to.
|
||||
PathPrefix string `json:"pathPrefix"`
|
||||
PathPrefix string `json:"pathPrefix,omitempty"`
|
||||
}
|
||||
|
||||
// ServiceMonitor defines monitoring for a set of services.
|
||||
|
|
|
@ -103,37 +103,38 @@ func SchemaPropsToJsonProps(schema *spec.Schema, openapiSpec map[string]common.O
|
|||
}
|
||||
|
||||
props = &extensionsobj.JSONSchemaProps{
|
||||
Ref: ref,
|
||||
ID: schemaProps.ID,
|
||||
Schema: extensionsobj.JSONSchemaURL(string(schema.Schema)),
|
||||
Description: schemaProps.Description,
|
||||
Type: StringOrArrayToString(schemaProps.Type),
|
||||
Format: schemaProps.Format,
|
||||
Title: schemaProps.Title,
|
||||
Maximum: schemaProps.Maximum,
|
||||
ExclusiveMaximum: schemaProps.ExclusiveMaximum,
|
||||
Minimum: schemaProps.Minimum,
|
||||
ExclusiveMinimum: schemaProps.ExclusiveMinimum,
|
||||
MaxLength: schemaProps.MaxLength,
|
||||
MinLength: schemaProps.MinLength,
|
||||
Pattern: schemaProps.Pattern,
|
||||
MaxItems: schemaProps.MaxItems,
|
||||
MinItems: schemaProps.MinItems,
|
||||
UniqueItems: schemaProps.UniqueItems,
|
||||
MultipleOf: schemaProps.MultipleOf,
|
||||
Enum: EnumJSON(schemaProps.Enum),
|
||||
MaxProperties: schemaProps.MaxProperties,
|
||||
MinProperties: schemaProps.MinProperties,
|
||||
Required: schemaProps.Required,
|
||||
Items: SchemaOrArrayToJsonItems(schemaProps.Items, openapiSpec, nested),
|
||||
AllOf: SchemaPropsToJsonPropsArray(schemaProps.AllOf, openapiSpec, nested),
|
||||
OneOf: SchemaPropsToJsonPropsArray(schemaProps.OneOf, openapiSpec, nested),
|
||||
AnyOf: SchemaPropsToJsonPropsArray(schemaProps.AnyOf, openapiSpec, nested),
|
||||
Not: SchemaPropsToJsonProps(schemaProps.Not, openapiSpec, nested),
|
||||
Properties: SchemPropsMapToJsonMap(schemaProps.Properties, openapiSpec, nested),
|
||||
AdditionalProperties: SchemaOrBoolToJsonProps(schemaProps.AdditionalProperties, openapiSpec, nested),
|
||||
PatternProperties: SchemPropsMapToJsonMap(schemaProps.PatternProperties, openapiSpec, nested),
|
||||
AdditionalItems: SchemaOrBoolToJsonProps(schemaProps.AdditionalItems, openapiSpec, nested),
|
||||
Ref: ref,
|
||||
ID: schemaProps.ID,
|
||||
Schema: extensionsobj.JSONSchemaURL(string(schema.Schema)),
|
||||
Description: schemaProps.Description,
|
||||
Type: StringOrArrayToString(schemaProps.Type),
|
||||
Format: schemaProps.Format,
|
||||
Title: schemaProps.Title,
|
||||
Maximum: schemaProps.Maximum,
|
||||
ExclusiveMaximum: schemaProps.ExclusiveMaximum,
|
||||
Minimum: schemaProps.Minimum,
|
||||
ExclusiveMinimum: schemaProps.ExclusiveMinimum,
|
||||
MaxLength: schemaProps.MaxLength,
|
||||
MinLength: schemaProps.MinLength,
|
||||
Pattern: schemaProps.Pattern,
|
||||
MaxItems: schemaProps.MaxItems,
|
||||
MinItems: schemaProps.MinItems,
|
||||
UniqueItems: schemaProps.UniqueItems,
|
||||
MultipleOf: schemaProps.MultipleOf,
|
||||
Enum: EnumJSON(schemaProps.Enum),
|
||||
MaxProperties: schemaProps.MaxProperties,
|
||||
MinProperties: schemaProps.MinProperties,
|
||||
Required: schemaProps.Required,
|
||||
Items: SchemaOrArrayToJsonItems(schemaProps.Items, openapiSpec, nested),
|
||||
AllOf: SchemaPropsToJsonPropsArray(schemaProps.AllOf, openapiSpec, nested),
|
||||
OneOf: SchemaPropsToJsonPropsArray(schemaProps.OneOf, openapiSpec, nested),
|
||||
AnyOf: SchemaPropsToJsonPropsArray(schemaProps.AnyOf, openapiSpec, nested),
|
||||
Not: SchemaPropsToJsonProps(schemaProps.Not, openapiSpec, nested),
|
||||
Properties: SchemPropsMapToJsonMap(schemaProps.Properties, openapiSpec, nested),
|
||||
// @TODO(01-25-2018) Field not accepted by the current CRD Validation Spec
|
||||
// AdditionalProperties: SchemaOrBoolToJsonProps(schemaProps.AdditionalProperties, openapiSpec, nested),
|
||||
PatternProperties: SchemPropsMapToJsonMap(schemaProps.PatternProperties, openapiSpec, nested),
|
||||
AdditionalItems: SchemaOrBoolToJsonProps(schemaProps.AdditionalItems, openapiSpec, nested),
|
||||
}
|
||||
return props
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue