Provisioning: Mark repository as unhealthy if hooks fail (#109788)

This commit is contained in:
Roberto Jiménez Sánchez
2025-08-21 08:32:23 +00:00
committed by GitHub
parent 03d9ec4ea3
commit 61d137992b
22 changed files with 1578 additions and 490 deletions
@@ -242,10 +242,22 @@ type RepositoryStatus struct {
Webhook *WebhookStatus `json:"webhook"`
}
// HealthFailureType represents different types of repository failures
// +enum
type HealthFailureType string
const (
HealthFailureHook HealthFailureType = "hook"
HealthFailureHealth HealthFailureType = "health"
)
type HealthStatus struct {
// When not healthy, requests will not be executed
Healthy bool `json:"healthy"`
// The type of the error
Error HealthFailureType `json:"error,omitempty"`
// When the health was checked last time
Checked int64 `json:"checked,omitempty"`
@@ -571,6 +571,14 @@ func schema_pkg_apis_provisioning_v0alpha1_HealthStatus(ref common.ReferenceCall
Format: "",
},
},
"error": {
SchemaProps: spec.SchemaProps{
Description: "The type of the error\n\nPossible enum values:\n - `\"health\"`\n - `\"hook\"`",
Type: []string{"string"},
Format: "",
Enum: []interface{}{"health", "hook"},
},
},
"checked": {
SchemaProps: spec.SchemaProps{
Description: "When the health was checked last time",
@@ -4,12 +4,17 @@
package v0alpha1
import (
provisioningv0alpha1 "github.com/grafana/grafana/apps/provisioning/pkg/apis/provisioning/v0alpha1"
)
// HealthStatusApplyConfiguration represents a declarative configuration of the HealthStatus type for use
// with apply.
type HealthStatusApplyConfiguration struct {
Healthy *bool `json:"healthy,omitempty"`
Checked *int64 `json:"checked,omitempty"`
Message []string `json:"message,omitempty"`
Healthy *bool `json:"healthy,omitempty"`
Error *provisioningv0alpha1.HealthFailureType `json:"error,omitempty"`
Checked *int64 `json:"checked,omitempty"`
Message []string `json:"message,omitempty"`
}
// HealthStatusApplyConfiguration constructs a declarative configuration of the HealthStatus type for use with
@@ -26,6 +31,14 @@ func (b *HealthStatusApplyConfiguration) WithHealthy(value bool) *HealthStatusAp
return b
}
// WithError sets the Error field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Error field is set to the value of the last call.
func (b *HealthStatusApplyConfiguration) WithError(value provisioningv0alpha1.HealthFailureType) *HealthStatusApplyConfiguration {
b.Error = &value
return b
}
// WithChecked sets the Checked field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Checked field is set to the value of the last call.