mirror of
https://github.com/grafana/grafana.git
synced 2025-09-20 07:06:08 +08:00
Advisor: Update app-sdk and regenerate code (#107786)
This commit is contained in:

committed by
GitHub

parent
85a6a7b9c1
commit
e4650d3d8f
@ -1,3 +1,22 @@
|
|||||||
|
APP_SDK_VERSION := v0.39.2
|
||||||
|
APP_SDK_DIR := $(shell go env GOPATH)/bin/app-sdk-$(APP_SDK_VERSION)
|
||||||
|
APP_SDK_BIN := $(APP_SDK_DIR)/grafana-app-sdk
|
||||||
|
|
||||||
|
.PHONY: install-app-sdk
|
||||||
|
install-app-sdk: $(APP_SDK_BIN) ## Install the Grafana App SDK
|
||||||
|
|
||||||
|
$(APP_SDK_BIN):
|
||||||
|
@echo "Installing Grafana App SDK version $(APP_SDK_VERSION)"
|
||||||
|
@mkdir -p $(APP_SDK_DIR)
|
||||||
|
# The only way to install specific versions of binaries using `go install`
|
||||||
|
# is by setting GOBIN to the directory you want to install the binary to.
|
||||||
|
GOBIN=$(APP_SDK_DIR) go install github.com/grafana/grafana-app-sdk/cmd/grafana-app-sdk@$(APP_SDK_VERSION)
|
||||||
|
@touch $@
|
||||||
|
|
||||||
|
.PHONY: update-app-sdk
|
||||||
|
update-app-sdk: ## Update the Grafana App SDK dependency in go.mod
|
||||||
|
go get github.com/grafana/grafana-app-sdk@$(APP_SDK_VERSION)
|
||||||
|
|
||||||
.PHONY: generate
|
.PHONY: generate
|
||||||
generate:
|
generate: ## Run Grafana App SDK code generation
|
||||||
@grafana-app-sdk generate -g ./pkg/apis --grouping=group --postprocess --defencoding=none
|
@$(APP_SDK_BIN) generate -g ./pkg/apis --grouping=group --postprocess --defencoding=none
|
||||||
|
@ -3,8 +3,8 @@ module github.com/grafana/grafana/apps/advisor
|
|||||||
go 1.24.4
|
go 1.24.4
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/grafana/grafana-app-sdk v0.39.0
|
github.com/grafana/grafana-app-sdk v0.39.2
|
||||||
k8s.io/apimachinery v0.33.1
|
k8s.io/apimachinery v0.33.2
|
||||||
k8s.io/klog/v2 v2.130.1
|
k8s.io/klog/v2 v2.130.1
|
||||||
k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff
|
k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff
|
||||||
)
|
)
|
||||||
@ -33,7 +33,7 @@ require (
|
|||||||
github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad // indirect
|
github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad // indirect
|
||||||
github.com/google/uuid v1.6.0 // indirect
|
github.com/google/uuid v1.6.0 // indirect
|
||||||
github.com/grafana/authlib v0.0.0-20250515162837-2f4a8263eabb // indirect
|
github.com/grafana/authlib v0.0.0-20250515162837-2f4a8263eabb // indirect
|
||||||
github.com/grafana/grafana-app-sdk/logging v0.38.2 // indirect
|
github.com/grafana/grafana-app-sdk/logging v0.39.1 // indirect
|
||||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 // indirect
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 // indirect
|
||||||
github.com/hashicorp/errwrap v1.1.0 // indirect
|
github.com/hashicorp/errwrap v1.1.0 // indirect
|
||||||
github.com/hashicorp/go-multierror v1.1.1 // indirect
|
github.com/hashicorp/go-multierror v1.1.1 // indirect
|
||||||
@ -79,9 +79,9 @@ require (
|
|||||||
google.golang.org/protobuf v1.36.6 // indirect
|
google.golang.org/protobuf v1.36.6 // indirect
|
||||||
gopkg.in/inf.v0 v0.9.1 // indirect
|
gopkg.in/inf.v0 v0.9.1 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
k8s.io/api v0.33.1 // indirect
|
k8s.io/api v0.33.2 // indirect
|
||||||
k8s.io/apiextensions-apiserver v0.33.1 // indirect
|
k8s.io/apiextensions-apiserver v0.33.2 // indirect
|
||||||
k8s.io/client-go v0.33.1 // indirect
|
k8s.io/client-go v0.33.2 // indirect
|
||||||
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect
|
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect
|
||||||
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect
|
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect
|
||||||
sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect
|
sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect
|
||||||
|
@ -63,11 +63,14 @@ github.com/grafana/grafana-app-sdk v0.30.0/go.mod h1:jhfqNIovb+Mes2vdMf9iMCWQkp1
|
|||||||
github.com/grafana/grafana-app-sdk v0.31.0/go.mod h1:Xw00NL7qpRLo5r3Gn48Bl1Xn2n4eUDI5pYf/wMufKWs=
|
github.com/grafana/grafana-app-sdk v0.31.0/go.mod h1:Xw00NL7qpRLo5r3Gn48Bl1Xn2n4eUDI5pYf/wMufKWs=
|
||||||
github.com/grafana/grafana-app-sdk v0.35.1/go.mod h1:Zx5MkVppYK+ElSDUAR6+fjzOVo6I/cIgk+ty+LmNOxI=
|
github.com/grafana/grafana-app-sdk v0.35.1/go.mod h1:Zx5MkVppYK+ElSDUAR6+fjzOVo6I/cIgk+ty+LmNOxI=
|
||||||
github.com/grafana/grafana-app-sdk v0.39.0/go.mod h1:xRyBQOttgWTc3tGe9pI0upnpEPVhzALf7Mh/61O4zyY=
|
github.com/grafana/grafana-app-sdk v0.39.0/go.mod h1:xRyBQOttgWTc3tGe9pI0upnpEPVhzALf7Mh/61O4zyY=
|
||||||
|
github.com/grafana/grafana-app-sdk v0.39.2 h1:ymfr+1318t+JC9U2OYrzVpGmNG/aJONUmFFu/G98Xh8=
|
||||||
|
github.com/grafana/grafana-app-sdk v0.39.2/go.mod h1:t0m6q561lpoHQCixS9LUHFUhUzDClzNtm7BH60gHVSY=
|
||||||
github.com/grafana/grafana-app-sdk/logging v0.29.0 h1:mgbXaAf33aFwqwGVeaX30l8rkeAJH0iACgX5Rn6YkN4=
|
github.com/grafana/grafana-app-sdk/logging v0.29.0 h1:mgbXaAf33aFwqwGVeaX30l8rkeAJH0iACgX5Rn6YkN4=
|
||||||
github.com/grafana/grafana-app-sdk/logging v0.29.0/go.mod h1:xy6ZyVXl50Z3DBDLybvBPphbykPhuVNed/VNmen9DQM=
|
github.com/grafana/grafana-app-sdk/logging v0.29.0/go.mod h1:xy6ZyVXl50Z3DBDLybvBPphbykPhuVNed/VNmen9DQM=
|
||||||
github.com/grafana/grafana-app-sdk/logging v0.30.0/go.mod h1:xy6ZyVXl50Z3DBDLybvBPphbykPhuVNed/VNmen9DQM=
|
github.com/grafana/grafana-app-sdk/logging v0.30.0/go.mod h1:xy6ZyVXl50Z3DBDLybvBPphbykPhuVNed/VNmen9DQM=
|
||||||
github.com/grafana/grafana-app-sdk/logging v0.35.0/go.mod h1:Y/bvbDhBiV/tkIle9RW49pgfSPIPSON8Q4qjx3pyqDk=
|
github.com/grafana/grafana-app-sdk/logging v0.35.0/go.mod h1:Y/bvbDhBiV/tkIle9RW49pgfSPIPSON8Q4qjx3pyqDk=
|
||||||
github.com/grafana/grafana-app-sdk/logging v0.38.2/go.mod h1:Y/bvbDhBiV/tkIle9RW49pgfSPIPSON8Q4qjx3pyqDk=
|
github.com/grafana/grafana-app-sdk/logging v0.38.2/go.mod h1:Y/bvbDhBiV/tkIle9RW49pgfSPIPSON8Q4qjx3pyqDk=
|
||||||
|
github.com/grafana/grafana-app-sdk/logging v0.39.1/go.mod h1:WhDENSnaGHtyVVwZGVnAR7YLvh2xlLDYR3D7E6h7XVk=
|
||||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.25.1 h1:VNqngBF40hVlDloBruUehVYC3ArSgIyScOAyMRqBxRg=
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.25.1 h1:VNqngBF40hVlDloBruUehVYC3ArSgIyScOAyMRqBxRg=
|
||||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.25.1/go.mod h1:RBRO7fro65R6tjKzYgLAFo0t1QEXY1Dp+i/bvpRiqiQ=
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.25.1/go.mod h1:RBRO7fro65R6tjKzYgLAFo0t1QEXY1Dp+i/bvpRiqiQ=
|
||||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.1/go.mod h1:tIxuGz/9mpox++sgp9fJjHO0+q1X9/UOWd798aAm22M=
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.1/go.mod h1:tIxuGz/9mpox++sgp9fJjHO0+q1X9/UOWd798aAm22M=
|
||||||
@ -302,21 +305,25 @@ k8s.io/api v0.32.0/go.mod h1:4LEwHZEf6Q/cG96F3dqR965sYOfmPM7rq81BLgsE0p0=
|
|||||||
k8s.io/api v0.32.1/go.mod h1:/Yi/BqkuueW1BgpoePYBRdDYfjPF5sgTr5+YqDZra5k=
|
k8s.io/api v0.32.1/go.mod h1:/Yi/BqkuueW1BgpoePYBRdDYfjPF5sgTr5+YqDZra5k=
|
||||||
k8s.io/api v0.32.3/go.mod h1:2wEDTXADtm/HA7CCMD8D8bK4yuBUptzaRhYcYEEYA3k=
|
k8s.io/api v0.32.3/go.mod h1:2wEDTXADtm/HA7CCMD8D8bK4yuBUptzaRhYcYEEYA3k=
|
||||||
k8s.io/api v0.33.1/go.mod h1:87esjTn9DRSRTD4fWMXamiXxJhpOIREjWOSjsW1kEHw=
|
k8s.io/api v0.33.1/go.mod h1:87esjTn9DRSRTD4fWMXamiXxJhpOIREjWOSjsW1kEHw=
|
||||||
|
k8s.io/api v0.33.2/go.mod h1:fhrbphQJSM2cXzCWgqU29xLDuks4mu7ti9vveEnpSXs=
|
||||||
k8s.io/apiextensions-apiserver v0.32.0 h1:S0Xlqt51qzzqjKPxfgX1xh4HBZE+p8KKBq+k2SWNOE0=
|
k8s.io/apiextensions-apiserver v0.32.0 h1:S0Xlqt51qzzqjKPxfgX1xh4HBZE+p8KKBq+k2SWNOE0=
|
||||||
k8s.io/apiextensions-apiserver v0.32.0/go.mod h1:86hblMvN5yxMvZrZFX2OhIHAuFIMJIZ19bTvzkP+Fmw=
|
k8s.io/apiextensions-apiserver v0.32.0/go.mod h1:86hblMvN5yxMvZrZFX2OhIHAuFIMJIZ19bTvzkP+Fmw=
|
||||||
k8s.io/apiextensions-apiserver v0.32.1/go.mod h1:sxWIGuGiYov7Io1fAS2X06NjMIk5CbRHc2StSmbaQto=
|
k8s.io/apiextensions-apiserver v0.32.1/go.mod h1:sxWIGuGiYov7Io1fAS2X06NjMIk5CbRHc2StSmbaQto=
|
||||||
k8s.io/apiextensions-apiserver v0.32.3/go.mod h1:8YwcvVRMVzw0r1Stc7XfGAzB/SIVLunqApySV5V7Dss=
|
k8s.io/apiextensions-apiserver v0.32.3/go.mod h1:8YwcvVRMVzw0r1Stc7XfGAzB/SIVLunqApySV5V7Dss=
|
||||||
k8s.io/apiextensions-apiserver v0.33.1/go.mod h1:uNQ52z1A1Gu75QSa+pFK5bcXc4hq7lpOXbweZgi4dqA=
|
k8s.io/apiextensions-apiserver v0.33.1/go.mod h1:uNQ52z1A1Gu75QSa+pFK5bcXc4hq7lpOXbweZgi4dqA=
|
||||||
|
k8s.io/apiextensions-apiserver v0.33.2/go.mod h1:IvVanieYsEHJImTKXGP6XCOjTwv2LUMos0YWc9O+QP8=
|
||||||
k8s.io/apimachinery v0.32.0 h1:cFSE7N3rmEEtv4ei5X6DaJPHHX0C+upp+v5lVPiEwpg=
|
k8s.io/apimachinery v0.32.0 h1:cFSE7N3rmEEtv4ei5X6DaJPHHX0C+upp+v5lVPiEwpg=
|
||||||
k8s.io/apimachinery v0.32.0/go.mod h1:GpHVgxoKlTxClKcteaeuF1Ul/lDVb74KpZcxcmLDElE=
|
k8s.io/apimachinery v0.32.0/go.mod h1:GpHVgxoKlTxClKcteaeuF1Ul/lDVb74KpZcxcmLDElE=
|
||||||
k8s.io/apimachinery v0.32.1/go.mod h1:GpHVgxoKlTxClKcteaeuF1Ul/lDVb74KpZcxcmLDElE=
|
k8s.io/apimachinery v0.32.1/go.mod h1:GpHVgxoKlTxClKcteaeuF1Ul/lDVb74KpZcxcmLDElE=
|
||||||
k8s.io/apimachinery v0.32.3/go.mod h1:GpHVgxoKlTxClKcteaeuF1Ul/lDVb74KpZcxcmLDElE=
|
k8s.io/apimachinery v0.32.3/go.mod h1:GpHVgxoKlTxClKcteaeuF1Ul/lDVb74KpZcxcmLDElE=
|
||||||
k8s.io/apimachinery v0.33.1/go.mod h1:BHW0YOu7n22fFv/JkYOEfkUYNRN0fj0BlvMFWA7b+SM=
|
k8s.io/apimachinery v0.33.1/go.mod h1:BHW0YOu7n22fFv/JkYOEfkUYNRN0fj0BlvMFWA7b+SM=
|
||||||
|
k8s.io/apimachinery v0.33.2/go.mod h1:BHW0YOu7n22fFv/JkYOEfkUYNRN0fj0BlvMFWA7b+SM=
|
||||||
k8s.io/client-go v0.32.0 h1:DimtMcnN/JIKZcrSrstiwvvZvLjG0aSxy8PxN8IChp8=
|
k8s.io/client-go v0.32.0 h1:DimtMcnN/JIKZcrSrstiwvvZvLjG0aSxy8PxN8IChp8=
|
||||||
k8s.io/client-go v0.32.0/go.mod h1:boDWvdM1Drk4NJj/VddSLnx59X3OPgwrOo0vGbtq9+8=
|
k8s.io/client-go v0.32.0/go.mod h1:boDWvdM1Drk4NJj/VddSLnx59X3OPgwrOo0vGbtq9+8=
|
||||||
k8s.io/client-go v0.32.1/go.mod h1:aTTKZY7MdxUaJ/KiUs8D+GssR9zJZi77ZqtzcGXIiDg=
|
k8s.io/client-go v0.32.1/go.mod h1:aTTKZY7MdxUaJ/KiUs8D+GssR9zJZi77ZqtzcGXIiDg=
|
||||||
k8s.io/client-go v0.32.3/go.mod h1:3v0+3k4IcT9bXTc4V2rt+d2ZPPG700Xy6Oi0Gdl2PaY=
|
k8s.io/client-go v0.32.3/go.mod h1:3v0+3k4IcT9bXTc4V2rt+d2ZPPG700Xy6Oi0Gdl2PaY=
|
||||||
k8s.io/client-go v0.33.1/go.mod h1:JAsUrl1ArO7uRVFWfcj6kOomSlCv+JpvIsp6usAGefA=
|
k8s.io/client-go v0.33.1/go.mod h1:JAsUrl1ArO7uRVFWfcj6kOomSlCv+JpvIsp6usAGefA=
|
||||||
|
k8s.io/client-go v0.33.2/go.mod h1:9mCgT4wROvL948w6f6ArJNb7yQd7QsvqavDeZHvNmHo=
|
||||||
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
|
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
|
||||||
k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
|
k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
|
||||||
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f h1:GA7//TjRY9yWGy1poLzYYJJ4JRdzg3+O6e8I+e+8T5Y=
|
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f h1:GA7//TjRY9yWGy1poLzYYJJ4JRdzg3+O6e8I+e+8T5Y=
|
||||||
|
@ -24,5 +24,8 @@ type CheckMetadata struct {
|
|||||||
|
|
||||||
// NewCheckMetadata creates a new CheckMetadata object.
|
// NewCheckMetadata creates a new CheckMetadata object.
|
||||||
func NewCheckMetadata() *CheckMetadata {
|
func NewCheckMetadata() *CheckMetadata {
|
||||||
return &CheckMetadata{}
|
return &CheckMetadata{
|
||||||
|
Finalizers: []string{},
|
||||||
|
Labels: map[string]string{},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,11 @@ import (
|
|||||||
type Check struct {
|
type Check struct {
|
||||||
metav1.TypeMeta `json:",inline" yaml:",inline"`
|
metav1.TypeMeta `json:",inline" yaml:",inline"`
|
||||||
metav1.ObjectMeta `json:"metadata" yaml:"metadata"`
|
metav1.ObjectMeta `json:"metadata" yaml:"metadata"`
|
||||||
Spec CheckSpec `json:"spec" yaml:"spec"`
|
|
||||||
CheckStatus CheckStatus `json:"status" yaml:"status"`
|
// Spec is the spec of the Check
|
||||||
|
Spec CheckSpec `json:"spec" yaml:"spec"`
|
||||||
|
|
||||||
|
Status CheckStatus `json:"status" yaml:"status"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Check) GetSpec() any {
|
func (o *Check) GetSpec() any {
|
||||||
@ -37,14 +40,14 @@ func (o *Check) SetSpec(spec any) error {
|
|||||||
|
|
||||||
func (o *Check) GetSubresources() map[string]any {
|
func (o *Check) GetSubresources() map[string]any {
|
||||||
return map[string]any{
|
return map[string]any{
|
||||||
"status": o.CheckStatus,
|
"status": o.Status,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Check) GetSubresource(name string) (any, bool) {
|
func (o *Check) GetSubresource(name string) (any, bool) {
|
||||||
switch name {
|
switch name {
|
||||||
case "status":
|
case "status":
|
||||||
return o.CheckStatus, true
|
return o.Status, true
|
||||||
default:
|
default:
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
@ -57,7 +60,7 @@ func (o *Check) SetSubresource(name string, value any) error {
|
|||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("cannot set status type %#v, not of type CheckStatus", value)
|
return fmt.Errorf("cannot set status type %#v, not of type CheckStatus", value)
|
||||||
}
|
}
|
||||||
o.CheckStatus = cast
|
o.Status = cast
|
||||||
return nil
|
return nil
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("subresource '%s' does not exist", name)
|
return fmt.Errorf("subresource '%s' does not exist", name)
|
||||||
@ -219,6 +222,20 @@ func (o *Check) DeepCopyObject() runtime.Object {
|
|||||||
return o.Copy()
|
return o.Copy()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *Check) DeepCopy() *Check {
|
||||||
|
cpy := &Check{}
|
||||||
|
o.DeepCopyInto(cpy)
|
||||||
|
return cpy
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *Check) DeepCopyInto(dst *Check) {
|
||||||
|
dst.TypeMeta.APIVersion = o.TypeMeta.APIVersion
|
||||||
|
dst.TypeMeta.Kind = o.TypeMeta.Kind
|
||||||
|
o.ObjectMeta.DeepCopyInto(&dst.ObjectMeta)
|
||||||
|
o.Spec.DeepCopyInto(&dst.Spec)
|
||||||
|
o.Status.DeepCopyInto(&dst.Status)
|
||||||
|
}
|
||||||
|
|
||||||
// Interface compliance compile-time check
|
// Interface compliance compile-time check
|
||||||
var _ resource.Object = &Check{}
|
var _ resource.Object = &Check{}
|
||||||
|
|
||||||
@ -262,5 +279,41 @@ func (o *CheckList) SetItems(items []resource.Object) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *CheckList) DeepCopy() *CheckList {
|
||||||
|
cpy := &CheckList{}
|
||||||
|
o.DeepCopyInto(cpy)
|
||||||
|
return cpy
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *CheckList) DeepCopyInto(dst *CheckList) {
|
||||||
|
resource.CopyObjectInto(dst, o)
|
||||||
|
}
|
||||||
|
|
||||||
// Interface compliance compile-time check
|
// Interface compliance compile-time check
|
||||||
var _ resource.ListObject = &CheckList{}
|
var _ resource.ListObject = &CheckList{}
|
||||||
|
|
||||||
|
// Copy methods for all subresource types
|
||||||
|
|
||||||
|
// DeepCopy creates a full deep copy of Spec
|
||||||
|
func (s *CheckSpec) DeepCopy() *CheckSpec {
|
||||||
|
cpy := &CheckSpec{}
|
||||||
|
s.DeepCopyInto(cpy)
|
||||||
|
return cpy
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopyInto deep copies Spec into another Spec object
|
||||||
|
func (s *CheckSpec) DeepCopyInto(dst *CheckSpec) {
|
||||||
|
resource.CopyObjectInto(dst, s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopy creates a full deep copy of CheckStatus
|
||||||
|
func (s *CheckStatus) DeepCopy() *CheckStatus {
|
||||||
|
cpy := &CheckStatus{}
|
||||||
|
s.DeepCopyInto(cpy)
|
||||||
|
return cpy
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopyInto deep copies CheckStatus into another CheckStatus object
|
||||||
|
func (s *CheckStatus) DeepCopyInto(dst *CheckStatus) {
|
||||||
|
resource.CopyObjectInto(dst, s)
|
||||||
|
}
|
||||||
|
@ -3,16 +3,18 @@
|
|||||||
package v0alpha1
|
package v0alpha1
|
||||||
|
|
||||||
// +k8s:openapi-gen=true
|
// +k8s:openapi-gen=true
|
||||||
type CheckErrorLink struct {
|
type CheckReport struct {
|
||||||
// URL to a page with more information about the error
|
// Number of elements analyzed
|
||||||
Url string `json:"url"`
|
Count int64 `json:"count"`
|
||||||
// Human readable error message
|
// List of failures
|
||||||
Message string `json:"message"`
|
Failures []CheckReportFailure `json:"failures"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewCheckErrorLink creates a new CheckErrorLink object.
|
// NewCheckReport creates a new CheckReport object.
|
||||||
func NewCheckErrorLink() *CheckErrorLink {
|
func NewCheckReport() *CheckReport {
|
||||||
return &CheckErrorLink{}
|
return &CheckReport{
|
||||||
|
Failures: []CheckReportFailure{},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// +k8s:openapi-gen=true
|
// +k8s:openapi-gen=true
|
||||||
@ -33,7 +35,22 @@ type CheckReportFailure struct {
|
|||||||
|
|
||||||
// NewCheckReportFailure creates a new CheckReportFailure object.
|
// NewCheckReportFailure creates a new CheckReportFailure object.
|
||||||
func NewCheckReportFailure() *CheckReportFailure {
|
func NewCheckReportFailure() *CheckReportFailure {
|
||||||
return &CheckReportFailure{}
|
return &CheckReportFailure{
|
||||||
|
Links: []CheckErrorLink{},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// +k8s:openapi-gen=true
|
||||||
|
type CheckErrorLink struct {
|
||||||
|
// URL to a page with more information about the error
|
||||||
|
Url string `json:"url"`
|
||||||
|
// Human readable error message
|
||||||
|
Message string `json:"message"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewCheckErrorLink creates a new CheckErrorLink object.
|
||||||
|
func NewCheckErrorLink() *CheckErrorLink {
|
||||||
|
return &CheckErrorLink{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// +k8s:openapi-gen=true
|
// +k8s:openapi-gen=true
|
||||||
@ -56,7 +73,7 @@ func NewCheckstatusOperatorState() *CheckstatusOperatorState {
|
|||||||
|
|
||||||
// +k8s:openapi-gen=true
|
// +k8s:openapi-gen=true
|
||||||
type CheckStatus struct {
|
type CheckStatus struct {
|
||||||
Report CheckV0alpha1StatusReport `json:"report"`
|
Report CheckReport `json:"report"`
|
||||||
// operatorStates is a map of operator ID to operator state evaluations.
|
// operatorStates is a map of operator ID to operator state evaluations.
|
||||||
// Any operator which consumes this kind SHOULD add its state evaluation information to this field.
|
// Any operator which consumes this kind SHOULD add its state evaluation information to this field.
|
||||||
OperatorStates map[string]CheckstatusOperatorState `json:"operatorStates,omitempty"`
|
OperatorStates map[string]CheckstatusOperatorState `json:"operatorStates,omitempty"`
|
||||||
@ -67,7 +84,7 @@ type CheckStatus struct {
|
|||||||
// NewCheckStatus creates a new CheckStatus object.
|
// NewCheckStatus creates a new CheckStatus object.
|
||||||
func NewCheckStatus() *CheckStatus {
|
func NewCheckStatus() *CheckStatus {
|
||||||
return &CheckStatus{
|
return &CheckStatus{
|
||||||
Report: *NewCheckV0alpha1StatusReport(),
|
Report: *NewCheckReport(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,16 +104,3 @@ const (
|
|||||||
CheckStatusOperatorStateStateInProgress CheckStatusOperatorStateState = "in_progress"
|
CheckStatusOperatorStateStateInProgress CheckStatusOperatorStateState = "in_progress"
|
||||||
CheckStatusOperatorStateStateFailed CheckStatusOperatorStateState = "failed"
|
CheckStatusOperatorStateStateFailed CheckStatusOperatorStateState = "failed"
|
||||||
)
|
)
|
||||||
|
|
||||||
// +k8s:openapi-gen=true
|
|
||||||
type CheckV0alpha1StatusReport struct {
|
|
||||||
// Number of elements analyzed
|
|
||||||
Count int64 `json:"count"`
|
|
||||||
// List of failures
|
|
||||||
Failures []CheckReportFailure `json:"failures"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewCheckV0alpha1StatusReport creates a new CheckV0alpha1StatusReport object.
|
|
||||||
func NewCheckV0alpha1StatusReport() *CheckV0alpha1StatusReport {
|
|
||||||
return &CheckV0alpha1StatusReport{}
|
|
||||||
}
|
|
||||||
|
@ -24,5 +24,8 @@ type CheckTypeMetadata struct {
|
|||||||
|
|
||||||
// NewCheckTypeMetadata creates a new CheckTypeMetadata object.
|
// NewCheckTypeMetadata creates a new CheckTypeMetadata object.
|
||||||
func NewCheckTypeMetadata() *CheckTypeMetadata {
|
func NewCheckTypeMetadata() *CheckTypeMetadata {
|
||||||
return &CheckTypeMetadata{}
|
return &CheckTypeMetadata{
|
||||||
|
Finalizers: []string{},
|
||||||
|
Labels: map[string]string{},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,11 @@ import (
|
|||||||
type CheckType struct {
|
type CheckType struct {
|
||||||
metav1.TypeMeta `json:",inline" yaml:",inline"`
|
metav1.TypeMeta `json:",inline" yaml:",inline"`
|
||||||
metav1.ObjectMeta `json:"metadata" yaml:"metadata"`
|
metav1.ObjectMeta `json:"metadata" yaml:"metadata"`
|
||||||
Spec CheckTypeSpec `json:"spec" yaml:"spec"`
|
|
||||||
CheckTypeStatus CheckTypeStatus `json:"status" yaml:"status"`
|
// Spec is the spec of the CheckType
|
||||||
|
Spec CheckTypeSpec `json:"spec" yaml:"spec"`
|
||||||
|
|
||||||
|
Status CheckTypeStatus `json:"status" yaml:"status"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *CheckType) GetSpec() any {
|
func (o *CheckType) GetSpec() any {
|
||||||
@ -37,14 +40,14 @@ func (o *CheckType) SetSpec(spec any) error {
|
|||||||
|
|
||||||
func (o *CheckType) GetSubresources() map[string]any {
|
func (o *CheckType) GetSubresources() map[string]any {
|
||||||
return map[string]any{
|
return map[string]any{
|
||||||
"status": o.CheckTypeStatus,
|
"status": o.Status,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *CheckType) GetSubresource(name string) (any, bool) {
|
func (o *CheckType) GetSubresource(name string) (any, bool) {
|
||||||
switch name {
|
switch name {
|
||||||
case "status":
|
case "status":
|
||||||
return o.CheckTypeStatus, true
|
return o.Status, true
|
||||||
default:
|
default:
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
@ -57,7 +60,7 @@ func (o *CheckType) SetSubresource(name string, value any) error {
|
|||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("cannot set status type %#v, not of type CheckTypeStatus", value)
|
return fmt.Errorf("cannot set status type %#v, not of type CheckTypeStatus", value)
|
||||||
}
|
}
|
||||||
o.CheckTypeStatus = cast
|
o.Status = cast
|
||||||
return nil
|
return nil
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("subresource '%s' does not exist", name)
|
return fmt.Errorf("subresource '%s' does not exist", name)
|
||||||
@ -219,6 +222,20 @@ func (o *CheckType) DeepCopyObject() runtime.Object {
|
|||||||
return o.Copy()
|
return o.Copy()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *CheckType) DeepCopy() *CheckType {
|
||||||
|
cpy := &CheckType{}
|
||||||
|
o.DeepCopyInto(cpy)
|
||||||
|
return cpy
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *CheckType) DeepCopyInto(dst *CheckType) {
|
||||||
|
dst.TypeMeta.APIVersion = o.TypeMeta.APIVersion
|
||||||
|
dst.TypeMeta.Kind = o.TypeMeta.Kind
|
||||||
|
o.ObjectMeta.DeepCopyInto(&dst.ObjectMeta)
|
||||||
|
o.Spec.DeepCopyInto(&dst.Spec)
|
||||||
|
o.Status.DeepCopyInto(&dst.Status)
|
||||||
|
}
|
||||||
|
|
||||||
// Interface compliance compile-time check
|
// Interface compliance compile-time check
|
||||||
var _ resource.Object = &CheckType{}
|
var _ resource.Object = &CheckType{}
|
||||||
|
|
||||||
@ -262,5 +279,41 @@ func (o *CheckTypeList) SetItems(items []resource.Object) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *CheckTypeList) DeepCopy() *CheckTypeList {
|
||||||
|
cpy := &CheckTypeList{}
|
||||||
|
o.DeepCopyInto(cpy)
|
||||||
|
return cpy
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *CheckTypeList) DeepCopyInto(dst *CheckTypeList) {
|
||||||
|
resource.CopyObjectInto(dst, o)
|
||||||
|
}
|
||||||
|
|
||||||
// Interface compliance compile-time check
|
// Interface compliance compile-time check
|
||||||
var _ resource.ListObject = &CheckTypeList{}
|
var _ resource.ListObject = &CheckTypeList{}
|
||||||
|
|
||||||
|
// Copy methods for all subresource types
|
||||||
|
|
||||||
|
// DeepCopy creates a full deep copy of Spec
|
||||||
|
func (s *CheckTypeSpec) DeepCopy() *CheckTypeSpec {
|
||||||
|
cpy := &CheckTypeSpec{}
|
||||||
|
s.DeepCopyInto(cpy)
|
||||||
|
return cpy
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopyInto deep copies Spec into another Spec object
|
||||||
|
func (s *CheckTypeSpec) DeepCopyInto(dst *CheckTypeSpec) {
|
||||||
|
resource.CopyObjectInto(dst, s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopy creates a full deep copy of CheckTypeStatus
|
||||||
|
func (s *CheckTypeStatus) DeepCopy() *CheckTypeStatus {
|
||||||
|
cpy := &CheckTypeStatus{}
|
||||||
|
s.DeepCopyInto(cpy)
|
||||||
|
return cpy
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopyInto deep copies CheckTypeStatus into another CheckTypeStatus object
|
||||||
|
func (s *CheckTypeStatus) DeepCopyInto(dst *CheckTypeStatus) {
|
||||||
|
resource.CopyObjectInto(dst, s)
|
||||||
|
}
|
||||||
|
@ -23,5 +23,7 @@ type CheckTypeSpec struct {
|
|||||||
|
|
||||||
// NewCheckTypeSpec creates a new CheckTypeSpec object.
|
// NewCheckTypeSpec creates a new CheckTypeSpec object.
|
||||||
func NewCheckTypeSpec() *CheckTypeSpec {
|
func NewCheckTypeSpec() *CheckTypeSpec {
|
||||||
return &CheckTypeSpec{}
|
return &CheckTypeSpec{
|
||||||
|
Steps: []CheckTypeStep{},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,16 +3,16 @@ package v0alpha1
|
|||||||
import "k8s.io/apimachinery/pkg/runtime/schema"
|
import "k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// Group is the API group used by all kinds in this package
|
// APIGroup is the API group used by all kinds in this package
|
||||||
Group = "advisor.grafana.app"
|
APIGroup = "advisor.grafana.app"
|
||||||
// Version is the API version used by all kinds in this package
|
// APIVersion is the API version used by all kinds in this package
|
||||||
Version = "v0alpha1"
|
APIVersion = "v0alpha1"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// GroupVersion is a schema.GroupVersion consisting of the Group and Version constants for this package
|
// GroupVersion is a schema.GroupVersion consisting of the Group and Version constants for this package
|
||||||
GroupVersion = schema.GroupVersion{
|
GroupVersion = schema.GroupVersion{
|
||||||
Group: Group,
|
Group: APIGroup,
|
||||||
Version: Version,
|
Version: APIVersion,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -15,6 +15,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
|
|||||||
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.Check": schema_pkg_apis_advisor_v0alpha1_Check(ref),
|
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.Check": schema_pkg_apis_advisor_v0alpha1_Check(ref),
|
||||||
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckErrorLink": schema_pkg_apis_advisor_v0alpha1_CheckErrorLink(ref),
|
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckErrorLink": schema_pkg_apis_advisor_v0alpha1_CheckErrorLink(ref),
|
||||||
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckList": schema_pkg_apis_advisor_v0alpha1_CheckList(ref),
|
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckList": schema_pkg_apis_advisor_v0alpha1_CheckList(ref),
|
||||||
|
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckReport": schema_pkg_apis_advisor_v0alpha1_CheckReport(ref),
|
||||||
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckReportFailure": schema_pkg_apis_advisor_v0alpha1_CheckReportFailure(ref),
|
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckReportFailure": schema_pkg_apis_advisor_v0alpha1_CheckReportFailure(ref),
|
||||||
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckSpec": schema_pkg_apis_advisor_v0alpha1_CheckSpec(ref),
|
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckSpec": schema_pkg_apis_advisor_v0alpha1_CheckSpec(ref),
|
||||||
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckStatus": schema_pkg_apis_advisor_v0alpha1_CheckStatus(ref),
|
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckStatus": schema_pkg_apis_advisor_v0alpha1_CheckStatus(ref),
|
||||||
@ -24,7 +25,6 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
|
|||||||
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckTypeStatus": schema_pkg_apis_advisor_v0alpha1_CheckTypeStatus(ref),
|
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckTypeStatus": schema_pkg_apis_advisor_v0alpha1_CheckTypeStatus(ref),
|
||||||
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckTypeStep": schema_pkg_apis_advisor_v0alpha1_CheckTypeStep(ref),
|
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckTypeStep": schema_pkg_apis_advisor_v0alpha1_CheckTypeStep(ref),
|
||||||
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckTypestatusOperatorState": schema_pkg_apis_advisor_v0alpha1_CheckTypestatusOperatorState(ref),
|
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckTypestatusOperatorState": schema_pkg_apis_advisor_v0alpha1_CheckTypestatusOperatorState(ref),
|
||||||
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckV0alpha1StatusReport": schema_pkg_apis_advisor_v0alpha1_CheckV0alpha1StatusReport(ref),
|
|
||||||
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckstatusOperatorState": schema_pkg_apis_advisor_v0alpha1_CheckstatusOperatorState(ref),
|
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckstatusOperatorState": schema_pkg_apis_advisor_v0alpha1_CheckstatusOperatorState(ref),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -57,8 +57,9 @@ func schema_pkg_apis_advisor_v0alpha1_Check(ref common.ReferenceCallback) common
|
|||||||
},
|
},
|
||||||
"spec": {
|
"spec": {
|
||||||
SchemaProps: spec.SchemaProps{
|
SchemaProps: spec.SchemaProps{
|
||||||
Default: map[string]interface{}{},
|
Description: "Spec is the spec of the Check",
|
||||||
Ref: ref("github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckSpec"),
|
Default: map[string]interface{}{},
|
||||||
|
Ref: ref("github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckSpec"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"status": {
|
"status": {
|
||||||
@ -153,6 +154,43 @@ func schema_pkg_apis_advisor_v0alpha1_CheckList(ref common.ReferenceCallback) co
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func schema_pkg_apis_advisor_v0alpha1_CheckReport(ref common.ReferenceCallback) common.OpenAPIDefinition {
|
||||||
|
return common.OpenAPIDefinition{
|
||||||
|
Schema: spec.Schema{
|
||||||
|
SchemaProps: spec.SchemaProps{
|
||||||
|
Type: []string{"object"},
|
||||||
|
Properties: map[string]spec.Schema{
|
||||||
|
"count": {
|
||||||
|
SchemaProps: spec.SchemaProps{
|
||||||
|
Description: "Number of elements analyzed",
|
||||||
|
Default: 0,
|
||||||
|
Type: []string{"integer"},
|
||||||
|
Format: "int64",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"failures": {
|
||||||
|
SchemaProps: spec.SchemaProps{
|
||||||
|
Description: "List of failures",
|
||||||
|
Type: []string{"array"},
|
||||||
|
Items: &spec.SchemaOrArray{
|
||||||
|
Schema: &spec.Schema{
|
||||||
|
SchemaProps: spec.SchemaProps{
|
||||||
|
Default: map[string]interface{}{},
|
||||||
|
Ref: ref("github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckReportFailure"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Required: []string{"count", "failures"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Dependencies: []string{
|
||||||
|
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckReportFailure"},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func schema_pkg_apis_advisor_v0alpha1_CheckReportFailure(ref common.ReferenceCallback) common.OpenAPIDefinition {
|
func schema_pkg_apis_advisor_v0alpha1_CheckReportFailure(ref common.ReferenceCallback) common.OpenAPIDefinition {
|
||||||
return common.OpenAPIDefinition{
|
return common.OpenAPIDefinition{
|
||||||
Schema: spec.Schema{
|
Schema: spec.Schema{
|
||||||
@ -258,7 +296,7 @@ func schema_pkg_apis_advisor_v0alpha1_CheckStatus(ref common.ReferenceCallback)
|
|||||||
"report": {
|
"report": {
|
||||||
SchemaProps: spec.SchemaProps{
|
SchemaProps: spec.SchemaProps{
|
||||||
Default: map[string]interface{}{},
|
Default: map[string]interface{}{},
|
||||||
Ref: ref("github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckV0alpha1StatusReport"),
|
Ref: ref("github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckReport"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"operatorStates": {
|
"operatorStates": {
|
||||||
@ -296,7 +334,7 @@ func schema_pkg_apis_advisor_v0alpha1_CheckStatus(ref common.ReferenceCallback)
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Dependencies: []string{
|
Dependencies: []string{
|
||||||
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckV0alpha1StatusReport", "github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckstatusOperatorState"},
|
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckReport", "github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckstatusOperatorState"},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,8 +366,9 @@ func schema_pkg_apis_advisor_v0alpha1_CheckType(ref common.ReferenceCallback) co
|
|||||||
},
|
},
|
||||||
"spec": {
|
"spec": {
|
||||||
SchemaProps: spec.SchemaProps{
|
SchemaProps: spec.SchemaProps{
|
||||||
Default: map[string]interface{}{},
|
Description: "Spec is the spec of the CheckType",
|
||||||
Ref: ref("github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckTypeSpec"),
|
Default: map[string]interface{}{},
|
||||||
|
Ref: ref("github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckTypeSpec"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"status": {
|
"status": {
|
||||||
@ -566,43 +605,6 @@ func schema_pkg_apis_advisor_v0alpha1_CheckTypestatusOperatorState(ref common.Re
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func schema_pkg_apis_advisor_v0alpha1_CheckV0alpha1StatusReport(ref common.ReferenceCallback) common.OpenAPIDefinition {
|
|
||||||
return common.OpenAPIDefinition{
|
|
||||||
Schema: spec.Schema{
|
|
||||||
SchemaProps: spec.SchemaProps{
|
|
||||||
Type: []string{"object"},
|
|
||||||
Properties: map[string]spec.Schema{
|
|
||||||
"count": {
|
|
||||||
SchemaProps: spec.SchemaProps{
|
|
||||||
Description: "Number of elements analyzed",
|
|
||||||
Default: 0,
|
|
||||||
Type: []string{"integer"},
|
|
||||||
Format: "int64",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"failures": {
|
|
||||||
SchemaProps: spec.SchemaProps{
|
|
||||||
Description: "List of failures",
|
|
||||||
Type: []string{"array"},
|
|
||||||
Items: &spec.SchemaOrArray{
|
|
||||||
Schema: &spec.Schema{
|
|
||||||
SchemaProps: spec.SchemaProps{
|
|
||||||
Default: map[string]interface{}{},
|
|
||||||
Ref: ref("github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckReportFailure"),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Required: []string{"count", "failures"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Dependencies: []string{
|
|
||||||
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckReportFailure"},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func schema_pkg_apis_advisor_v0alpha1_CheckstatusOperatorState(ref common.ReferenceCallback) common.OpenAPIDefinition {
|
func schema_pkg_apis_advisor_v0alpha1_CheckstatusOperatorState(ref common.ReferenceCallback) common.OpenAPIDefinition {
|
||||||
return common.OpenAPIDefinition{
|
return common.OpenAPIDefinition{
|
||||||
Schema: spec.Schema{
|
Schema: spec.Schema{
|
||||||
|
@ -7,15 +7,19 @@ package apis
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/grafana/grafana-app-sdk/app"
|
"github.com/grafana/grafana-app-sdk/app"
|
||||||
|
"github.com/grafana/grafana-app-sdk/resource"
|
||||||
|
|
||||||
|
v0alpha1 "github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
rawSchemaCheckv0alpha1 = []byte(`{"spec":{"properties":{"data":{"additionalProperties":{"type":"string"},"description":"Generic data input that a check can receive","type":"object"}},"type":"object"},"status":{"properties":{"additionalFields":{"description":"additionalFields is reserved for future use","type":"object","x-kubernetes-preserve-unknown-fields":true},"operatorStates":{"additionalProperties":{"properties":{"descriptiveState":{"description":"descriptiveState is an optional more descriptive state field which has no requirements on format","type":"string"},"details":{"description":"details contains any extra information that is operator-specific","type":"object","x-kubernetes-preserve-unknown-fields":true},"lastEvaluation":{"description":"lastEvaluation is the ResourceVersion last evaluated","type":"string"},"state":{"description":"state describes the state of the lastEvaluation.\nIt is limited to three possible states for machine evaluation.","enum":["success","in_progress","failed"],"type":"string"}},"required":["lastEvaluation","state"],"type":"object"},"description":"operatorStates is a map of operator ID to operator state evaluations.\nAny operator which consumes this kind SHOULD add its state evaluation information to this field.","type":"object"},"report":{"properties":{"count":{"description":"Number of elements analyzed","type":"integer"},"failures":{"description":"List of failures","items":{"properties":{"item":{"description":"Human readable identifier of the item that failed","type":"string"},"itemID":{"description":"ID of the item that failed","type":"string"},"links":{"description":"Links to actions that can be taken to resolve the failure","items":{"properties":{"message":{"description":"Human readable error message","type":"string"},"url":{"description":"URL to a page with more information about the error","type":"string"}},"required":["url","message"],"type":"object"},"type":"array"},"moreInfo":{"description":"More information about the failure, not meant to be displayed to the user. Used for LLM suggestions.","type":"string"},"severity":{"description":"Severity of the failure","enum":["high","low"],"type":"string"},"stepID":{"description":"Step ID that the failure is associated with","type":"string"}},"required":["severity","stepID","item","itemID","links"],"type":"object"},"type":"array"}},"required":["count","failures"],"type":"object"}},"required":["report"],"type":"object","x-kubernetes-preserve-unknown-fields":true}}`)
|
rawSchemaCheckv0alpha1 = []byte(`{"spec":{"properties":{"data":{"additionalProperties":{"type":"string"},"description":"Generic data input that a check can receive","type":"object"}},"type":"object"},"status":{"properties":{"additionalFields":{"description":"additionalFields is reserved for future use","type":"object","x-kubernetes-preserve-unknown-fields":true},"operatorStates":{"additionalProperties":{"properties":{"descriptiveState":{"description":"descriptiveState is an optional more descriptive state field which has no requirements on format","type":"string"},"details":{"description":"details contains any extra information that is operator-specific","type":"object","x-kubernetes-preserve-unknown-fields":true},"lastEvaluation":{"description":"lastEvaluation is the ResourceVersion last evaluated","type":"string"},"state":{"description":"state describes the state of the lastEvaluation.\nIt is limited to three possible states for machine evaluation.","enum":["success","in_progress","failed"],"type":"string"}},"required":["lastEvaluation","state"],"type":"object"},"description":"operatorStates is a map of operator ID to operator state evaluations.\nAny operator which consumes this kind SHOULD add its state evaluation information to this field.","type":"object"},"report":{"properties":{"count":{"description":"Number of elements analyzed","type":"integer"},"failures":{"description":"List of failures","items":{"properties":{"item":{"description":"Human readable identifier of the item that failed","type":"string"},"itemID":{"description":"ID of the item that failed","type":"string"},"links":{"description":"Links to actions that can be taken to resolve the failure","items":{"properties":{"message":{"description":"Human readable error message","type":"string"},"url":{"description":"URL to a page with more information about the error","type":"string"}},"required":["url","message"],"type":"object"},"type":"array"},"moreInfo":{"description":"More information about the failure, not meant to be displayed to the user. Used for LLM suggestions.","type":"string"},"severity":{"description":"Severity of the failure","enum":["high","low"],"type":"string"},"stepID":{"description":"Step ID that the failure is associated with","type":"string"}},"required":["severity","stepID","item","itemID","links"],"type":"object"},"type":"array"}},"required":["count","failures"],"type":"object"}},"required":["report"],"type":"object"}}`)
|
||||||
versionSchemaCheckv0alpha1 app.VersionSchema
|
versionSchemaCheckv0alpha1 app.VersionSchema
|
||||||
_ = json.Unmarshal(rawSchemaCheckv0alpha1, &versionSchemaCheckv0alpha1)
|
_ = json.Unmarshal(rawSchemaCheckv0alpha1, &versionSchemaCheckv0alpha1)
|
||||||
rawSchemaCheckTypev0alpha1 = []byte(`{"spec":{"properties":{"name":{"type":"string"},"steps":{"items":{"properties":{"description":{"type":"string"},"resolution":{"type":"string"},"stepID":{"type":"string"},"title":{"type":"string"}},"required":["title","description","stepID","resolution"],"type":"object"},"type":"array"}},"required":["name","steps"],"type":"object"},"status":{"properties":{"additionalFields":{"description":"additionalFields is reserved for future use","type":"object","x-kubernetes-preserve-unknown-fields":true},"operatorStates":{"additionalProperties":{"properties":{"descriptiveState":{"description":"descriptiveState is an optional more descriptive state field which has no requirements on format","type":"string"},"details":{"description":"details contains any extra information that is operator-specific","type":"object","x-kubernetes-preserve-unknown-fields":true},"lastEvaluation":{"description":"lastEvaluation is the ResourceVersion last evaluated","type":"string"},"state":{"description":"state describes the state of the lastEvaluation.\nIt is limited to three possible states for machine evaluation.","enum":["success","in_progress","failed"],"type":"string"}},"required":["lastEvaluation","state"],"type":"object"},"description":"operatorStates is a map of operator ID to operator state evaluations.\nAny operator which consumes this kind SHOULD add its state evaluation information to this field.","type":"object"}},"type":"object","x-kubernetes-preserve-unknown-fields":true}}`)
|
rawSchemaCheckTypev0alpha1 = []byte(`{"spec":{"properties":{"name":{"type":"string"},"steps":{"items":{"properties":{"description":{"type":"string"},"resolution":{"type":"string"},"stepID":{"type":"string"},"title":{"type":"string"}},"required":["title","description","stepID","resolution"],"type":"object"},"type":"array"}},"required":["name","steps"],"type":"object"},"status":{"properties":{"additionalFields":{"description":"additionalFields is reserved for future use","type":"object","x-kubernetes-preserve-unknown-fields":true},"operatorStates":{"additionalProperties":{"properties":{"descriptiveState":{"description":"descriptiveState is an optional more descriptive state field which has no requirements on format","type":"string"},"details":{"description":"details contains any extra information that is operator-specific","type":"object","x-kubernetes-preserve-unknown-fields":true},"lastEvaluation":{"description":"lastEvaluation is the ResourceVersion last evaluated","type":"string"},"state":{"description":"state describes the state of the lastEvaluation.\nIt is limited to three possible states for machine evaluation.","enum":["success","in_progress","failed"],"type":"string"}},"required":["lastEvaluation","state"],"type":"object"},"description":"operatorStates is a map of operator ID to operator state evaluations.\nAny operator which consumes this kind SHOULD add its state evaluation information to this field.","type":"object"}},"type":"object"}}`)
|
||||||
versionSchemaCheckTypev0alpha1 app.VersionSchema
|
versionSchemaCheckTypev0alpha1 app.VersionSchema
|
||||||
_ = json.Unmarshal(rawSchemaCheckTypev0alpha1, &versionSchemaCheckTypev0alpha1)
|
_ = json.Unmarshal(rawSchemaCheckTypev0alpha1, &versionSchemaCheckTypev0alpha1)
|
||||||
)
|
)
|
||||||
@ -58,12 +62,6 @@ var appManifestData = app.ManifestData{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func jsonToMap(j string) map[string]any {
|
|
||||||
m := make(map[string]any)
|
|
||||||
json.Unmarshal([]byte(j), &j)
|
|
||||||
return m
|
|
||||||
}
|
|
||||||
|
|
||||||
func LocalManifest() app.Manifest {
|
func LocalManifest() app.Manifest {
|
||||||
return app.NewEmbeddedManifest(appManifestData)
|
return app.NewEmbeddedManifest(appManifestData)
|
||||||
}
|
}
|
||||||
@ -71,3 +69,15 @@ func LocalManifest() app.Manifest {
|
|||||||
func RemoteManifest() app.Manifest {
|
func RemoteManifest() app.Manifest {
|
||||||
return app.NewAPIServerManifest("advisor")
|
return app.NewAPIServerManifest("advisor")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var kindVersionToGoType = map[string]resource.Kind{
|
||||||
|
"Check/v0alpha1": v0alpha1.CheckKind(),
|
||||||
|
"CheckType/v0alpha1": v0alpha1.CheckTypeKind(),
|
||||||
|
}
|
||||||
|
|
||||||
|
// ManifestGoTypeAssociator returns the associated resource.Kind instance for a given Kind and Version, if one exists.
|
||||||
|
// If there is no association for the provided Kind and Version, exists will return false.
|
||||||
|
func ManifestGoTypeAssociator(kind, version string) (goType resource.Kind, exists bool) {
|
||||||
|
goType, exists = kindVersionToGoType[fmt.Sprintf("%s/%s", kind, version)]
|
||||||
|
return goType, exists
|
||||||
|
}
|
||||||
|
@ -106,3 +106,25 @@ func SetStatusAnnotation(ctx context.Context, client resource.Client, obj resour
|
|||||||
}},
|
}},
|
||||||
}, resource.PatchOptions{}, obj)
|
}, resource.PatchOptions{}, obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SetAnnotations(ctx context.Context, client resource.Client, obj resource.Object, annotations map[string]string) error {
|
||||||
|
return client.PatchInto(ctx, obj.GetStaticMetadata().Identifier(), resource.PatchRequest{
|
||||||
|
Operations: []resource.PatchOperation{{
|
||||||
|
Operation: resource.PatchOpAdd,
|
||||||
|
Path: "/metadata/annotations",
|
||||||
|
Value: annotations,
|
||||||
|
}},
|
||||||
|
}, resource.PatchOptions{}, obj)
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetStatus(ctx context.Context, client resource.Client, obj resource.Object, status any) error {
|
||||||
|
return client.PatchInto(ctx, obj.GetStaticMetadata().Identifier(), resource.PatchRequest{
|
||||||
|
Operations: []resource.PatchOperation{{
|
||||||
|
Operation: resource.PatchOpAdd,
|
||||||
|
Path: "/status",
|
||||||
|
Value: status,
|
||||||
|
}},
|
||||||
|
}, resource.PatchOptions{
|
||||||
|
Subresource: "status",
|
||||||
|
}, obj)
|
||||||
|
}
|
||||||
|
@ -78,28 +78,21 @@ func processCheck(ctx context.Context, log logging.Logger, client resource.Clien
|
|||||||
return fmt.Errorf("error running steps: %w", err)
|
return fmt.Errorf("error running steps: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
report := &advisorv0alpha1.CheckV0alpha1StatusReport{
|
report := &advisorv0alpha1.CheckReport{
|
||||||
Failures: failures,
|
Failures: failures,
|
||||||
Count: int64(len(items)),
|
Count: int64(len(items)),
|
||||||
}
|
}
|
||||||
|
c.Status.Report = *report
|
||||||
|
err = checks.SetStatus(ctx, client, obj, c.Status)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
// Set the status annotation to processed and annotate the steps ignored
|
// Set the status annotation to processed and annotate the steps ignored
|
||||||
annotations := checks.AddAnnotations(ctx, obj, map[string]string{
|
annotations := checks.AddAnnotations(ctx, obj, map[string]string{
|
||||||
checks.StatusAnnotation: checks.StatusAnnotationProcessed,
|
checks.StatusAnnotation: checks.StatusAnnotationProcessed,
|
||||||
checks.IgnoreStepsAnnotationList: checkType.GetAnnotations()[checks.IgnoreStepsAnnotationList],
|
checks.IgnoreStepsAnnotationList: checkType.GetAnnotations()[checks.IgnoreStepsAnnotationList],
|
||||||
})
|
})
|
||||||
return client.PatchInto(ctx, obj.GetStaticMetadata().Identifier(), resource.PatchRequest{
|
return checks.SetAnnotations(ctx, client, obj, annotations)
|
||||||
Operations: []resource.PatchOperation{
|
|
||||||
{
|
|
||||||
Operation: resource.PatchOpAdd,
|
|
||||||
Path: "/status/report",
|
|
||||||
Value: *report,
|
|
||||||
}, {
|
|
||||||
Operation: resource.PatchOpAdd,
|
|
||||||
Path: "/metadata/annotations",
|
|
||||||
Value: annotations,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}, resource.PatchOptions{}, obj)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func processCheckRetry(ctx context.Context, log logging.Logger, client resource.Client, typesClient resource.Client, obj resource.Object, check checks.Check) error {
|
func processCheckRetry(ctx context.Context, log logging.Logger, client resource.Client, typesClient resource.Client, obj resource.Object, check checks.Check) error {
|
||||||
@ -157,7 +150,7 @@ func processCheckRetry(ctx context.Context, log logging.Logger, client resource.
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Pull failures from the report for the items to retry
|
// Pull failures from the report for the items to retry
|
||||||
c.CheckStatus.Report.Failures = slices.DeleteFunc(c.CheckStatus.Report.Failures, func(f advisorv0alpha1.CheckReportFailure) bool {
|
c.Status.Report.Failures = slices.DeleteFunc(c.Status.Report.Failures, func(f advisorv0alpha1.CheckReportFailure) bool {
|
||||||
if f.ItemID == itemToRetry {
|
if f.ItemID == itemToRetry {
|
||||||
for _, newFailure := range failures {
|
for _, newFailure := range failures {
|
||||||
if newFailure.StepID == f.StepID {
|
if newFailure.StepID == f.StepID {
|
||||||
@ -171,19 +164,13 @@ func processCheckRetry(ctx context.Context, log logging.Logger, client resource.
|
|||||||
// Failure not in the list of items to retry, keep it
|
// Failure not in the list of items to retry, keep it
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
|
err = checks.SetStatus(ctx, client, obj, c.Status)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
// Delete the retry annotation to mark the check as processed
|
// Delete the retry annotation to mark the check as processed
|
||||||
annotations := checks.DeleteAnnotations(ctx, obj, []string{checks.RetryAnnotation})
|
annotations := checks.DeleteAnnotations(ctx, obj, []string{checks.RetryAnnotation})
|
||||||
return client.PatchInto(ctx, obj.GetStaticMetadata().Identifier(), resource.PatchRequest{
|
return checks.SetAnnotations(ctx, client, obj, annotations)
|
||||||
Operations: []resource.PatchOperation{{
|
|
||||||
Operation: resource.PatchOpAdd,
|
|
||||||
Path: "/status/report",
|
|
||||||
Value: c.CheckStatus.Report,
|
|
||||||
}, {
|
|
||||||
Operation: resource.PatchOpAdd,
|
|
||||||
Path: "/metadata/annotations",
|
|
||||||
Value: annotations,
|
|
||||||
}},
|
|
||||||
}, resource.PatchOptions{}, obj)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func runStepsInParallel(ctx context.Context, log logging.Logger, spec *advisorv0alpha1.CheckSpec, steps []checks.Step, items []any) ([]advisorv0alpha1.CheckReportFailure, error) {
|
func runStepsInParallel(ctx context.Context, log logging.Logger, spec *advisorv0alpha1.CheckSpec, steps []checks.Step, items []any) ([]advisorv0alpha1.CheckReportFailure, error) {
|
||||||
|
@ -95,9 +95,9 @@ func TestProcessMultipleCheckItems(t *testing.T) {
|
|||||||
err = processCheck(ctx, logging.DefaultLogger, client, typesClient, obj, check)
|
err = processCheck(ctx, logging.DefaultLogger, client, typesClient, obj, check)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, checks.StatusAnnotationProcessed, obj.GetAnnotations()[checks.StatusAnnotation])
|
assert.Equal(t, checks.StatusAnnotationProcessed, obj.GetAnnotations()[checks.StatusAnnotation])
|
||||||
r := client.lastValue.(advisorv0alpha1.CheckV0alpha1StatusReport)
|
r := client.values[0].(advisorv0alpha1.CheckStatus)
|
||||||
assert.Equal(t, r.Count, int64(100))
|
assert.Equal(t, r.Report.Count, int64(100))
|
||||||
assert.Len(t, r.Failures, 50)
|
assert.Len(t, r.Report.Failures, 50)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestProcessCheck_AlreadyProcessed(t *testing.T) {
|
func TestProcessCheck_AlreadyProcessed(t *testing.T) {
|
||||||
@ -231,7 +231,7 @@ func TestProcessCheckRetry_SkipMissingItem(t *testing.T) {
|
|||||||
checks.RetryAnnotation: "item",
|
checks.RetryAnnotation: "item",
|
||||||
checks.StatusAnnotation: checks.StatusAnnotationProcessed,
|
checks.StatusAnnotation: checks.StatusAnnotationProcessed,
|
||||||
})
|
})
|
||||||
obj.CheckStatus.Report.Failures = []advisorv0alpha1.CheckReportFailure{
|
obj.Status.Report.Failures = []advisorv0alpha1.CheckReportFailure{
|
||||||
{
|
{
|
||||||
ItemID: "item",
|
ItemID: "item",
|
||||||
StepID: "step",
|
StepID: "step",
|
||||||
@ -254,7 +254,7 @@ func TestProcessCheckRetry_SkipMissingItem(t *testing.T) {
|
|||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, checks.StatusAnnotationProcessed, obj.GetAnnotations()[checks.StatusAnnotation])
|
assert.Equal(t, checks.StatusAnnotationProcessed, obj.GetAnnotations()[checks.StatusAnnotation])
|
||||||
assert.Empty(t, obj.GetAnnotations()[checks.RetryAnnotation])
|
assert.Empty(t, obj.GetAnnotations()[checks.RetryAnnotation])
|
||||||
assert.Empty(t, obj.CheckStatus.Report.Failures)
|
assert.Empty(t, obj.Status.Report.Failures)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestProcessCheckRetry_Success(t *testing.T) {
|
func TestProcessCheckRetry_Success(t *testing.T) {
|
||||||
@ -263,7 +263,7 @@ func TestProcessCheckRetry_Success(t *testing.T) {
|
|||||||
checks.RetryAnnotation: "item",
|
checks.RetryAnnotation: "item",
|
||||||
checks.StatusAnnotation: checks.StatusAnnotationProcessed,
|
checks.StatusAnnotation: checks.StatusAnnotationProcessed,
|
||||||
})
|
})
|
||||||
obj.CheckStatus.Report.Failures = []advisorv0alpha1.CheckReportFailure{
|
obj.Status.Report.Failures = []advisorv0alpha1.CheckReportFailure{
|
||||||
{
|
{
|
||||||
ItemID: "item",
|
ItemID: "item",
|
||||||
StepID: "step",
|
StepID: "step",
|
||||||
@ -286,16 +286,16 @@ func TestProcessCheckRetry_Success(t *testing.T) {
|
|||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, checks.StatusAnnotationProcessed, obj.GetAnnotations()[checks.StatusAnnotation])
|
assert.Equal(t, checks.StatusAnnotationProcessed, obj.GetAnnotations()[checks.StatusAnnotation])
|
||||||
assert.Empty(t, obj.GetAnnotations()[checks.RetryAnnotation])
|
assert.Empty(t, obj.GetAnnotations()[checks.RetryAnnotation])
|
||||||
assert.Empty(t, obj.CheckStatus.Report.Failures)
|
assert.Empty(t, obj.Status.Report.Failures)
|
||||||
}
|
}
|
||||||
|
|
||||||
type mockClient struct {
|
type mockClient struct {
|
||||||
resource.Client
|
resource.Client
|
||||||
lastValue any
|
values []any
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockClient) PatchInto(ctx context.Context, id resource.Identifier, req resource.PatchRequest, opts resource.PatchOptions, obj resource.Object) error {
|
func (m *mockClient) PatchInto(ctx context.Context, id resource.Identifier, req resource.PatchRequest, opts resource.PatchOptions, obj resource.Object) error {
|
||||||
m.lastValue = req.Operations[0].Value
|
m.values = append(m.values, req.Operations[0].Value)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ func (s *Service) ReportSummary(ctx context.Context) (*ReportInfo, error) {
|
|||||||
latestDatasourceCheck := findLatestCheck(checkList.GetItems(), datasourcecheck.CheckID)
|
latestDatasourceCheck := findLatestCheck(checkList.GetItems(), datasourcecheck.CheckID)
|
||||||
reportInfo := &ReportInfo{}
|
reportInfo := &ReportInfo{}
|
||||||
if latestPluginCheck != nil {
|
if latestPluginCheck != nil {
|
||||||
for _, failure := range latestPluginCheck.CheckStatus.Report.Failures {
|
for _, failure := range latestPluginCheck.Status.Report.Failures {
|
||||||
switch failure.StepID {
|
switch failure.StepID {
|
||||||
case plugincheck.UpdateStepID:
|
case plugincheck.UpdateStepID:
|
||||||
reportInfo.PluginsOutdated++
|
reportInfo.PluginsOutdated++
|
||||||
@ -96,7 +96,7 @@ func (s *Service) ReportSummary(ctx context.Context) (*ReportInfo, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if latestDatasourceCheck != nil {
|
if latestDatasourceCheck != nil {
|
||||||
for _, failure := range latestDatasourceCheck.CheckStatus.Report.Failures {
|
for _, failure := range latestDatasourceCheck.Status.Report.Failures {
|
||||||
if failure.StepID == datasourcecheck.HealthCheckStepID {
|
if failure.StepID == datasourcecheck.HealthCheckStepID {
|
||||||
reportInfo.DatasourcesUnhealthy++
|
reportInfo.DatasourcesUnhealthy++
|
||||||
}
|
}
|
||||||
|
@ -41,8 +41,8 @@ func TestService_ReportSummary(t *testing.T) {
|
|||||||
checks.TypeLabel: plugincheck.CheckID,
|
checks.TypeLabel: plugincheck.CheckID,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
CheckStatus: advisorv0alpha1.CheckStatus{
|
Status: advisorv0alpha1.CheckStatus{
|
||||||
Report: advisorv0alpha1.CheckV0alpha1StatusReport{
|
Report: advisorv0alpha1.CheckReport{
|
||||||
Failures: []advisorv0alpha1.CheckReportFailure{
|
Failures: []advisorv0alpha1.CheckReportFailure{
|
||||||
{StepID: plugincheck.UpdateStepID},
|
{StepID: plugincheck.UpdateStepID},
|
||||||
},
|
},
|
||||||
@ -56,8 +56,8 @@ func TestService_ReportSummary(t *testing.T) {
|
|||||||
checks.TypeLabel: plugincheck.CheckID,
|
checks.TypeLabel: plugincheck.CheckID,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
CheckStatus: advisorv0alpha1.CheckStatus{
|
Status: advisorv0alpha1.CheckStatus{
|
||||||
Report: advisorv0alpha1.CheckV0alpha1StatusReport{
|
Report: advisorv0alpha1.CheckReport{
|
||||||
Failures: []advisorv0alpha1.CheckReportFailure{
|
Failures: []advisorv0alpha1.CheckReportFailure{
|
||||||
{StepID: plugincheck.UpdateStepID},
|
{StepID: plugincheck.UpdateStepID},
|
||||||
{StepID: plugincheck.DeprecationStepID},
|
{StepID: plugincheck.DeprecationStepID},
|
||||||
@ -72,8 +72,8 @@ func TestService_ReportSummary(t *testing.T) {
|
|||||||
checks.TypeLabel: datasourcecheck.CheckID,
|
checks.TypeLabel: datasourcecheck.CheckID,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
CheckStatus: advisorv0alpha1.CheckStatus{
|
Status: advisorv0alpha1.CheckStatus{
|
||||||
Report: advisorv0alpha1.CheckV0alpha1StatusReport{
|
Report: advisorv0alpha1.CheckReport{
|
||||||
Failures: []advisorv0alpha1.CheckReportFailure{
|
Failures: []advisorv0alpha1.CheckReportFailure{
|
||||||
{StepID: datasourcecheck.HealthCheckStepID},
|
{StepID: datasourcecheck.HealthCheckStepID},
|
||||||
{StepID: datasourcecheck.HealthCheckStepID},
|
{StepID: datasourcecheck.HealthCheckStepID},
|
||||||
|
@ -2303,6 +2303,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"spec": {
|
"spec": {
|
||||||
|
"description": "Spec is the spec of the Check",
|
||||||
"default": {},
|
"default": {},
|
||||||
"allOf": [
|
"allOf": [
|
||||||
{
|
{
|
||||||
@ -2389,6 +2390,33 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"com.github.grafana.grafana.apps.advisor.pkg.apis.advisor.v0alpha1.CheckReport": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"count",
|
||||||
|
"failures"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"count": {
|
||||||
|
"description": "Number of elements analyzed",
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int64",
|
||||||
|
"default": 0
|
||||||
|
},
|
||||||
|
"failures": {
|
||||||
|
"description": "List of failures",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"default": {},
|
||||||
|
"allOf": [
|
||||||
|
{
|
||||||
|
"$ref": "#/components/schemas/com.github.grafana.grafana.apps.advisor.pkg.apis.advisor.v0alpha1.CheckReportFailure"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"com.github.grafana.grafana.apps.advisor.pkg.apis.advisor.v0alpha1.CheckReportFailure": {
|
"com.github.grafana.grafana.apps.advisor.pkg.apis.advisor.v0alpha1.CheckReportFailure": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
@ -2479,7 +2507,7 @@
|
|||||||
"default": {},
|
"default": {},
|
||||||
"allOf": [
|
"allOf": [
|
||||||
{
|
{
|
||||||
"$ref": "#/components/schemas/com.github.grafana.grafana.apps.advisor.pkg.apis.advisor.v0alpha1.CheckV0alpha1StatusReport"
|
"$ref": "#/components/schemas/com.github.grafana.grafana.apps.advisor.pkg.apis.advisor.v0alpha1.CheckReport"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -2510,6 +2538,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"spec": {
|
"spec": {
|
||||||
|
"description": "Spec is the spec of the CheckType",
|
||||||
"default": {},
|
"default": {},
|
||||||
"allOf": [
|
"allOf": [
|
||||||
{
|
{
|
||||||
@ -2682,33 +2711,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"com.github.grafana.grafana.apps.advisor.pkg.apis.advisor.v0alpha1.CheckV0alpha1StatusReport": {
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"count",
|
|
||||||
"failures"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"count": {
|
|
||||||
"description": "Number of elements analyzed",
|
|
||||||
"type": "integer",
|
|
||||||
"format": "int64",
|
|
||||||
"default": 0
|
|
||||||
},
|
|
||||||
"failures": {
|
|
||||||
"description": "List of failures",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"default": {},
|
|
||||||
"allOf": [
|
|
||||||
{
|
|
||||||
"$ref": "#/components/schemas/com.github.grafana.grafana.apps.advisor.pkg.apis.advisor.v0alpha1.CheckReportFailure"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"com.github.grafana.grafana.apps.advisor.pkg.apis.advisor.v0alpha1.CheckstatusOperatorState": {
|
"com.github.grafana.grafana.apps.advisor.pkg.apis.advisor.v0alpha1.CheckstatusOperatorState": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
|
Reference in New Issue
Block a user