K8s/Annotations: Use manager/source annotations rather than repo (#101313)

Co-authored-by: Stephanie Hingtgen <stephanie.hingtgen@grafana.com>
This commit is contained in:
Ryan McKinley
2025-03-05 08:54:20 +02:00
committed by GitHub
co-authored by Stephanie Hingtgen
parent e7baf9804e
commit dc2defd84f
37 changed files with 589 additions and 573 deletions
+18 -10
View File
@@ -1,28 +1,27 @@
package utils
import "time"
// ManagerProperties is used to identify the manager of the resource.
type ManagerProperties struct {
// The kind of manager, which is responsible for managing the resource.
// Examples include "git", "terraform", "kubectl", etc.
Kind ManagerKind
Kind ManagerKind `json:"kind,omitempty"`
// The identity of the manager, which refers to a specific instance of the manager.
// The format & the value depends on the manager kind.
Identity string
Identity string `json:"id,omitempty"`
// AllowsEdits indicates whether the manager allows edits to the resource.
// If set to true, it means that other requesters can edit the resource.
AllowsEdits bool
AllowsEdits bool `json:"allowEdits,omitempty"`
// Suspended indicates whether the manager is suspended.
// If set to true, then the manager skip updates to the resource.
Suspended bool
Suspended bool `json:"suspended,omitempty"`
}
// ManagerKind is the type of manager, which is responsible for managing the resource.
// It can be a user or a tool or a generic API client.
// +enum
type ManagerKind string
// Known values for ManagerKind.
@@ -31,6 +30,11 @@ const (
ManagerKindRepo ManagerKind = "repo"
ManagerKindTerraform ManagerKind = "terraform"
ManagerKindKubectl ManagerKind = "kubectl"
ManagerKindPlugin ManagerKind = "plugin"
// Deprecated: this is used as a shim/migration path for legacy file provisioning
// Previously this was a "file:" prefix
ManagerKindClassicFP ManagerKind = "classic-file-provisioning"
)
// ParseManagerKindString parses a string into a ManagerKind.
@@ -44,6 +48,10 @@ func ParseManagerKindString(v string) ManagerKind {
return ManagerKindTerraform
case string(ManagerKindKubectl):
return ManagerKindKubectl
case string(ManagerKindPlugin):
return ManagerKindPlugin
case string(ManagerKindClassicFP): // nolint:staticcheck
return ManagerKindClassicFP // nolint:staticcheck
default:
return ManagerKindUnknown
}
@@ -55,13 +63,13 @@ func ParseManagerKindString(v string) ManagerKind {
type SourceProperties struct {
// The path to the source of the resource.
// Can be a file path, a URL, etc.
Path string
Path string `json:"path,omitempty"`
// The checksum of the source of the resource.
// An example could be a git commit hash.
Checksum string
Checksum string `json:"checksum,omitempty"`
// The timestamp of the source of the resource.
// The unix millis timestamp of the source of the resource.
// An example could be the file modification time.
Timestamp time.Time
TimestampMillis int64 `json:"timestampMillis,omitempty"`
}