Documentation
¶
Index ¶
- Constants
- type BlobInfo
- type GrafanaMetaAccessor
- type ManagerKind
- type ManagerProperties
- type ResourceInfo
- func (info *ResourceInfo) GetName() string
- func (info *ResourceInfo) GetShortNames() []string
- func (info *ResourceInfo) GetSingularName() string
- func (info *ResourceInfo) GroupResource() schema.GroupResource
- func (info *ResourceInfo) GroupVersion() schema.GroupVersion
- func (info *ResourceInfo) GroupVersionKind() schema.GroupVersionKind
- func (info *ResourceInfo) GroupVersionResource() schema.GroupVersionResource
- func (info *ResourceInfo) NewFunc() runtime.Object
- func (info *ResourceInfo) NewListFunc() runtime.Object
- func (info *ResourceInfo) NewNotFound(name string) *errors.StatusError
- func (info *ResourceInfo) SingularGroupResource() schema.GroupResource
- func (info *ResourceInfo) StoragePath(sub ...string) string
- func (info *ResourceInfo) TableConverter() TableConvertor
- func (info *ResourceInfo) TypeMeta() metav1.TypeMeta
- func (info *ResourceInfo) WithGroupAndShortName(group string, shortName string) ResourceInfo
- type SourceProperties
- type TableColumns
- type TableConvertor
Constants ¶
const ( // VerbGet is mapped from HTTP GET for individual resource VerbGet = "get" // VerbList is mapped from HTTP GET for collections VerbList = "list" // VerbWatch is mapped from HTTP GET for watching an individual resource or collection of resources VerbWatch = "watch" // VerbCreate is mapped from HTTP POST VerbCreate = "create" // VerbUpdate is mapped from HTTP PUT VerbUpdate = "update" // VerbPatch is mapped from HTTP PATCH VerbPatch = "patch" // VerbDelete is mapped from HTTP DELETE for individual resources VerbDelete = "delete" // VerbDelete is mapped from HTTP DELETE for collections VerbDeleteCollection = "deletecollection" // VerbGetPermissions is used when fetching resource specific permissions VerbGetPermissions = "get_permissions" // VerbSetPermissions is used when setting resource specific permissions VerbSetPermissions = "set_permissions" )
Kubernetes request verbs http://kubernetes.io/docs/reference/access-authn-authz/authorization/#request-verb-resource
const AnnoKeyBlob = "grafana.app/blob"
const AnnoKeyCreatedBy = "grafana.app/createdBy"
const AnnoKeyFolder = "grafana.app/folder"
const AnnoKeyKubectlLastAppliedConfig = "kubectl.kubernetes.io/last-applied-configuration"
AnnoKeyKubectlLastAppliedConfig is the annotation kubectl writes with the entire previous config
const AnnoKeyManagerAllowsEdits = "grafana.app/managerAllowsEdits"
const AnnoKeyManagerIdentity = "grafana.app/managerId"
const AnnoKeyManagerKind = "grafana.app/managedBy"
const AnnoKeyManagerSuspended = "grafana.app/managerSuspended"
const AnnoKeyMessage = "grafana.app/message"
const AnnoKeySlug = "grafana.app/slug"
const AnnoKeySourceChecksum = "grafana.app/sourceChecksum"
const AnnoKeySourcePath = "grafana.app/sourcePath"
const AnnoKeySourceTimestamp = "grafana.app/sourceTimestamp"
const AnnoKeyUpdatedBy = "grafana.app/updatedBy"
const AnnoKeyUpdatedTimestamp = "grafana.app/updatedTimestamp"
const DeletedGeneration = int64(-999)
DeletedGeneration is set on Resources that have been (soft) deleted
const LabelKeyDeprecatedInternalID = "grafana.app/deprecatedInternalID"
LabelKeyDeprecatedInternalID gives the deprecated internal ID of a resource Deprecated: will be removed in grafana 13
const LabelKeyGetHistory = "grafana.app/get-history"
LabelKeyGetHistory is used to select object history for an given resource
const LabelKeyGetTrash = "grafana.app/get-trash"
LabelKeyGetTrash is used to list objects that have been (soft) deleted
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlobInfo ¶
type BlobInfo struct { UID string `json:"uid"` Size int64 `json:"size,omitempty"` Hash string `json:"hash,omitempty"` MimeType string `json:"mime,omitempty"` Charset string `json:"charset,omitempty"` // content type = mime+charset }
func ParseBlobInfo ¶
func (*BlobInfo) ContentType ¶
Content type is mime + charset
func (*BlobInfo) SetContentType ¶
Content type is mime + charset
type GrafanaMetaAccessor ¶
type GrafanaMetaAccessor interface { metav1.Object GetGroupVersionKind() schema.GroupVersionKind GetRuntimeObject() (runtime.Object, bool) // Helper to get resource versions as int64, however this is not required // See: https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions GetResourceVersionInt64() (int64, error) SetResourceVersionInt64(int64) GetUpdatedTimestamp() (*time.Time, error) SetUpdatedTimestamp(v *time.Time) SetUpdatedTimestampMillis(unix int64) GetCreatedBy() string SetCreatedBy(user string) GetUpdatedBy() string SetUpdatedBy(user string) GetFolder() string SetFolder(uid string) GetMessage() string SetMessage(msg string) SetAnnotation(key string, val string) GetSlug() string SetSlug(v string) SetBlob(v *BlobInfo) GetBlob() *BlobInfo // Deprecated: This will be removed in Grafana 13 GetDeprecatedInternalID() int64 // Deprecated: This will be removed in Grafana 13 SetDeprecatedInternalID(id int64) GetSpec() (any, error) SetSpec(any) error GetStatus() (any, error) // Used by the generic strategy to keep the status value unchanged on an update // NOTE the type must match the existing value, or an error will be thrown SetStatus(any) error // Find a title in the object // This will reflect the object and try to get: // * spec.title // * spec.name // * title // and return an empty string if nothing was found FindTitle(defaultTitle string) string // GetManagerProperties returns the identity of the tool, // which is responsible for managing the resource. // // If the identity is not known, the second return value will be false. GetManagerProperties() (ManagerProperties, bool) // SetManagerProperties sets the identity of the tool, // which is responsible for managing the resource. SetManagerProperties(ManagerProperties) // GetSourceProperties returns the source properties of the resource. GetSourceProperties() (SourceProperties, bool) // SetSourceProperties sets the source properties of the resource. SetSourceProperties(SourceProperties) }
Accessor functions for k8s objects
func MetaAccessor ¶
func MetaAccessor(raw interface{}) (GrafanaMetaAccessor, error)
Accessor takes an arbitrary object pointer and returns meta.Interface. obj must be a pointer to an API type. An error is returned if the minimum required fields are missing. Fields that are not required return the default value and are a no-op if set.
type ManagerKind ¶
type ManagerKind string
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
const ( ManagerKindUnknown ManagerKind = "" 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" )
Known values for ManagerKind.
func ParseManagerKindString ¶
func ParseManagerKindString(v string) ManagerKind
ParseManagerKindString parses a string into a ManagerKind. It returns the ManagerKind and a boolean indicating whether the string was a valid ManagerKind. For unknown values, it returns ManagerKindUnknown and false.
type ManagerProperties ¶
type ManagerProperties struct { // The kind of manager, which is responsible for managing the resource. // Examples include "git", "terraform", "kubectl", etc. 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 `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 `json:"allowEdits,omitempty"` // Suspended indicates whether the manager is suspended. // If set to true, then the manager skip updates to the resource. Suspended bool `json:"suspended,omitempty"` }
ManagerProperties is used to identify the manager of the resource.
type ResourceInfo ¶
type ResourceInfo struct {
// contains filtered or unexported fields
}
ResourceInfo helps define a k8s resource
func NewResourceInfo ¶
func NewResourceInfo(group, version, resourceName, singularName, kind string, newObj func() runtime.Object, newList func() runtime.Object, columns TableColumns) ResourceInfo
func (*ResourceInfo) GetName ¶
func (info *ResourceInfo) GetName() string
func (*ResourceInfo) GetShortNames ¶
func (info *ResourceInfo) GetShortNames() []string
func (*ResourceInfo) GetSingularName ¶
func (info *ResourceInfo) GetSingularName() string
func (*ResourceInfo) GroupResource ¶
func (info *ResourceInfo) GroupResource() schema.GroupResource
func (*ResourceInfo) GroupVersion ¶
func (info *ResourceInfo) GroupVersion() schema.GroupVersion
func (*ResourceInfo) GroupVersionKind ¶
func (info *ResourceInfo) GroupVersionKind() schema.GroupVersionKind
func (*ResourceInfo) GroupVersionResource ¶
func (info *ResourceInfo) GroupVersionResource() schema.GroupVersionResource
func (*ResourceInfo) NewFunc ¶
func (info *ResourceInfo) NewFunc() runtime.Object
func (*ResourceInfo) NewListFunc ¶
func (info *ResourceInfo) NewListFunc() runtime.Object
func (*ResourceInfo) NewNotFound ¶
func (info *ResourceInfo) NewNotFound(name string) *errors.StatusError
func (*ResourceInfo) SingularGroupResource ¶
func (info *ResourceInfo) SingularGroupResource() schema.GroupResource
func (*ResourceInfo) StoragePath ¶
func (info *ResourceInfo) StoragePath(sub ...string) string
func (*ResourceInfo) TableConverter ¶
func (info *ResourceInfo) TableConverter() TableConvertor
func (*ResourceInfo) TypeMeta ¶
func (info *ResourceInfo) TypeMeta() metav1.TypeMeta
TypeMeta returns k8s type
func (*ResourceInfo) WithGroupAndShortName ¶
func (info *ResourceInfo) WithGroupAndShortName(group string, shortName string) ResourceInfo
type SourceProperties ¶
type SourceProperties struct { // The path to the source of the resource. // Can be a file path, a URL, etc. Path string `json:"path,omitempty"` // The checksum of the source of the resource. // An example could be a git commit hash. Checksum string `json:"checksum,omitempty"` // The unix millis timestamp of the source of the resource. // An example could be the file modification time. TimestampMillis int64 `json:"timestampMillis,omitempty"` }
SourceProperties is used to identify the source of a provisioned resource. It is used by managers for reconciling data from a source to Grafana. Not all managers use these properties, some (like Terraform) don't have a concept of a source.
type TableColumns ¶
type TableColumns struct { Definition []metav1.TableColumnDefinition Reader func(obj any) ([]interface{}, error) }
type TableConvertor ¶
type TableConvertor interface {
ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1.Table, error)
}
func NewTableConverter ¶
func NewTableConverter(gr schema.GroupResource, columns TableColumns) TableConvertor