utils

package
v11.1.4-modfix Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2024 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const AnnoKeyCreatedBy = "grafana.app/createdBy"
View Source
const AnnoKeyFolder = "grafana.app/folder"
View Source
const AnnoKeyOriginKey = "grafana.app/originKey"
View Source
const AnnoKeyOriginName = "grafana.app/originName"
View Source
const AnnoKeyOriginPath = "grafana.app/originPath"
View Source
const AnnoKeyOriginTimestamp = "grafana.app/originTimestamp"
View Source
const AnnoKeySlug = "grafana.app/slug"
View Source
const AnnoKeyUpdatedBy = "grafana.app/updatedBy"
View Source
const AnnoKeyUpdatedTimestamp = "grafana.app/updatedTimestamp"

Variables

This section is empty.

Functions

func CalculateClusterWideUID

func CalculateClusterWideUID(obj runtime.Object) types.UID

Create a stable UID that will be unique across a multi-tenant cluster This is useful while we migrate from SQL storage to something where the UID (GUID) is actually baked into the storage engine itself.

func FormatKubeConfig

func FormatKubeConfig(restConfig *clientrest.Config) clientcmdapi.Config

func NewDefaultTableConverter

func NewDefaultTableConverter(gr schema.GroupResource) rest.TableConvertor

func NewTableConverter

func NewTableConverter(gr schema.GroupResource, columns []metav1.TableColumnDefinition, reader func(obj any) ([]interface{}, error)) rest.TableConvertor

Types

type GrafanaResourceMetaAccessor

type GrafanaResourceMetaAccessor interface {
	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)
	GetSlug() string
	SetSlug(v string)

	GetOriginInfo() (*ResourceOriginInfo, error)
	SetOriginInfo(info *ResourceOriginInfo)
	GetOriginName() string
	GetOriginPath() string
	GetOriginKey() string
	GetOriginTimestamp() (*time.Time, 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
}

Accessor functions for k8s objects

func MetaAccessor

func MetaAccessor(raw interface{}) (GrafanaResourceMetaAccessor, 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 ResourceOriginInfo

type ResourceOriginInfo struct {
	// Name of the origin/provisioning source
	Name string `json:"name,omitempty"`

	// The path within the named origin above (external_id in the existing dashboard provisioing)
	Path string `json:"path,omitempty"`

	// Verification/identification key (check_sum in existing dashboard provisioning)
	Key string `json:"key,omitempty"`

	// Origin modification timestamp when the resource was saved
	// This will be before the resource updated time
	Timestamp *time.Time `json:"time,omitempty"`
	// contains filtered or unexported fields
}

ResourceOriginInfo is saved in annotations. This is used to identify where the resource came from This object can model the same data as our existing provisioning table or a more general git sync

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL