K8s: Add App SDK installer (#107773)

This commit is contained in:
Todd Treece
2025-07-21 13:32:15 -04:00
committed by GitHub
parent 548964f728
commit e5d2f92384
107 changed files with 2772 additions and 1891 deletions
+27 -15
View File
@@ -8,6 +8,7 @@ package apis
import (
"encoding/json"
"fmt"
"strings"
"github.com/grafana/grafana-app-sdk/app"
"github.com/grafana/grafana-app-sdk/resource"
@@ -27,14 +28,16 @@ var (
var appManifestData = app.ManifestData{
AppName: "advisor",
Group: "advisor.grafana.app",
Kinds: []app.ManifestKind{
Versions: []app.ManifestVersion{
{
Kind: "Check",
Scope: "Namespaced",
Conversion: false,
Versions: []app.ManifestKindVersion{
Name: "v0alpha1",
Served: true,
Kinds: []app.ManifestVersionKind{
{
Name: "v0alpha1",
Kind: "Check",
Plural: "Checks",
Scope: "Namespaced",
Conversion: false,
Admission: &app.AdmissionCapabilities{
Validation: &app.ValidationCapability{
Operations: []app.AdmissionOperation{
@@ -45,17 +48,13 @@ var appManifestData = app.ManifestData{
},
Schema: &versionSchemaCheckv0alpha1,
},
},
},
{
Kind: "CheckType",
Scope: "Namespaced",
Conversion: false,
Versions: []app.ManifestKindVersion{
{
Name: "v0alpha1",
Schema: &versionSchemaCheckTypev0alpha1,
Kind: "CheckType",
Plural: "CheckTypes",
Scope: "Namespaced",
Conversion: false,
Schema: &versionSchemaCheckTypev0alpha1,
},
},
},
@@ -81,3 +80,16 @@ func ManifestGoTypeAssociator(kind, version string) (goType resource.Kind, exist
goType, exists = kindVersionToGoType[fmt.Sprintf("%s/%s", kind, version)]
return goType, exists
}
var customRouteToGoResponseType = map[string]any{}
// ManifestCustomRouteResponsesAssociator returns the associated response go type for a given kind, version, custom route path, and method, if one exists.
// kind may be empty for custom routes which are not kind subroutes. Leading slashes are removed from subroute paths.
// If there is no association for the provided kind, version, custom route path, and method, exists will return false.
func ManifestCustomRouteResponsesAssociator(kind, version, path, verb string) (goType any, exists bool) {
if len(path) > 0 && path[0] == '/' {
path = path[1:]
}
goType, exists = customRouteToGoResponseType[fmt.Sprintf("%s|%s|%s|%s", version, kind, path, strings.ToUpper(verb))]
return goType, exists
}
+1
View File
@@ -170,6 +170,7 @@ func processCheckRetry(ctx context.Context, log logging.Logger, client resource.
}
// Delete the retry annotation to mark the check as processed
annotations := checks.DeleteAnnotations(ctx, obj, []string{checks.RetryAnnotation})
return checks.SetAnnotations(ctx, client, obj, annotations)
}
+2 -1
View File
@@ -295,7 +295,8 @@ type mockClient struct {
}
func (m *mockClient) PatchInto(ctx context.Context, id resource.Identifier, req resource.PatchRequest, opts resource.PatchOptions, obj resource.Object) error {
m.values = append(m.values, req.Operations[0].Value)
value := req.Operations[0].Value
m.values = append(m.values, value)
return nil
}