update name comment

This commit is contained in:
Ryan McKinley
2025-08-19 13:03:02 +03:00
parent 5a2351387a
commit f6b6b62f5e
4 changed files with 18 additions and 10 deletions
+3 -3
View File
@@ -8,7 +8,7 @@ import (
)
// Connection to a datasource instance
// The connection name must be 'ds:{group}:{name}'
// The connection name must be '{group}:{name}'
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type DataSourceConnection struct {
metav1.TypeMeta `json:",inline"`
@@ -26,8 +26,8 @@ type DataSourceConnectionRef struct {
Version string `json:"version"`
Name string `json:"name"`
// The plugin ID -- NOTE, this has a 1:1 mapping with apiGroup and should likely be removed
PluginID string `json:"pluginId"`
// The plugin -- NOTE, this has a 1:1 mapping with apiGroup and should likely be removed
Plugin string `json:"plugin"`
}
// The valid connection name for a group + identifier
@@ -153,7 +153,7 @@ func schema_pkg_apis_query_v0alpha1_DataSourceConnection(ref common.ReferenceCal
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "Connection to a datasource instance The connection name must be 'ds:{group}:{name}'",
Description: "Connection to a datasource instance The connection name must be '{group}:{name}'",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"kind": {
@@ -276,16 +276,16 @@ func schema_pkg_apis_query_v0alpha1_DataSourceConnectionRef(ref common.Reference
Format: "",
},
},
"pluginId": {
"plugin": {
SchemaProps: spec.SchemaProps{
Description: "The plugin ID -- NOTE, this has a 1:1 mapping with apiGroup and should likely be removed",
Description: "The plugin -- NOTE, this has a 1:1 mapping with apiGroup and should likely be removed",
Default: "",
Type: []string{"string"},
Format: "",
},
},
},
Required: []string{"group", "version", "name", "pluginId"},
Required: []string{"group", "version", "name", "plugin"},
},
},
}
@@ -1,2 +1 @@
API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/query/v0alpha1,DataSourceApiServer,AliasIDs
API rule violation: names_match,github.com/grafana/grafana/pkg/apis/query/v0alpha1,DataSourceConnectionRef,PluginID
+11 -2
View File
@@ -7,6 +7,7 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/internalversion"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/rest"
@@ -121,7 +122,10 @@ func (q *connectionsProvider) ListConnections(ctx context.Context, namespace str
}
for _, ds := range dss {
// TODO, access control?!
v, _ := q.asConnection(ds, namespace)
v, err := q.asConnection(ds, namespace)
if err != nil {
return nil, err
}
result.Items = append(result.Items, *v)
}
return result, nil
@@ -130,7 +134,12 @@ func (q *connectionsProvider) ListConnections(ctx context.Context, namespace str
func (q *connectionsProvider) asConnection(ds *datasources.DataSource, ns string) (v *queryV0.DataSourceConnection, err error) {
gv, err := q.registry.GetDatasourceGroupVersion(ds.Type)
if err != nil {
return nil, err
// how does this happen? (grafana-e2etest-datasource)
gv = schema.GroupVersion{
Group: "unknown-" + ds.Type,
Version: "unknown",
}
err = nil
}
v = &queryV0.DataSourceConnection{