custom jsonschema for testdata

This commit is contained in:
Ryan McKinley
2025-07-03 13:03:41 -07:00
parent 01926ab3c8
commit ea38c4ad5a
11 changed files with 207 additions and 116 deletions
+7
View File
@@ -7,6 +7,8 @@ import (
secret "github.com/grafana/grafana/pkg/apis/secret/v0alpha1"
)
// +k8s:deepcopy-gen=true
// +k8s:openapi-gen=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type DataSource struct {
metav1.TypeMeta `json:",inline"`
@@ -20,6 +22,7 @@ type DataSource struct {
}
// DsAccess represents how the datasource connects to the remote service
// +k8s:openapi-gen=true
// +enum
type DsAccess string
@@ -36,6 +39,8 @@ func (dsa DsAccess) String() string {
return string(dsa)
}
// +k8s:deepcopy-gen=true
// +k8s:openapi-gen=true
type DataSourceSpec struct {
// The diplay name (previously saved as the "name" property)
Title string `json:"title"`
@@ -57,6 +62,8 @@ type DataSourceSpec struct {
JsonData common.Unstructured `json:"jsonData,omitzero"`
}
// +k8s:deepcopy-gen=true
// +k8s:openapi-gen=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type DataSourceList struct {
metav1.TypeMeta `json:",inline"`
-3
View File
@@ -1,6 +1,3 @@
// +k8s:deepcopy-gen=package
// +k8s:openapi-gen=true
// +k8s:defaulter-gen=TypeMeta
// +groupName=datasource.grafana.com
package v0alpha1
+35
View File
@@ -0,0 +1,35 @@
package v0alpha1
import (
"k8s.io/kube-openapi/pkg/spec3"
"k8s.io/kube-openapi/pkg/validation/spec"
)
// Optional extensions for an explict datasource type
type DataSourceOpenAPIExtension struct {
// When specified, this will replace the default spec
DataSourceSpec *spec.Schema `json:"spec,omitempty"`
// The raw value is never returned in an API response
SecureValues []SecureValueInfo `json:"secureValues"`
// Additional Schemas added to the response
Schemas map[string]*spec.Schema `json:"schemas,omitempty"`
// Resource routes
Routes *spec3.Paths `json:"routes,omitempty"`
// Proxy routes
Proxy *spec3.Paths `json:"proxy,omitempty"`
}
type SecureValueInfo struct {
// The key
Key string `json:"string"`
// Description
Description string `json:"description,omitempty"`
// Required secure values
Required bool `json:"required,omitempty"`
}
+2
View File
@@ -6,6 +6,8 @@ import (
common "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1"
)
// +k8s:deepcopy-gen=true
// +k8s:openapi-gen=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type HealthCheckResult struct {
metav1.TypeMeta `json:",inline"`
@@ -1,19 +0,0 @@
//go:build !ignore_autogenerated
// +build !ignore_autogenerated
// SPDX-License-Identifier: AGPL-3.0-only
// Code generated by defaulter-gen. DO NOT EDIT.
package v0alpha1
import (
runtime "k8s.io/apimachinery/pkg/runtime"
)
// RegisterDefaults adds defaulters functions to the given scheme.
// Public to allow building arbitrary schemes.
// All generated defaulters are covering - they call all nested defaulters.
func RegisterDefaults(scheme *runtime.Scheme) error {
return nil
}