clusters

package
v1.98.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LoadRetries    int           = 6
	LoadRetryDelay time.Duration = 10 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ClusterInfo

type ClusterInfo struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Profile     string `json:"profile"`
	Provider    string `json:"provider"`
	Account     string `json:"account"`
	Project     string `json:"project"`
	Region      string `json:"region"`
	Provisioner string `json:"provisioner"`
}

ClusterInfo holds attributes of Cluster from metrics pulled from Prometheus

func (*ClusterInfo) Clone

func (ci *ClusterInfo) Clone() *ClusterInfo

Clone creates a copy of ClusterInfo and returns it

type ClusterInfoProvider

type ClusterInfoProvider interface {
	// GetClusterInfo returns a string map containing the local/remote connected cluster info
	GetClusterInfo() map[string]string
}

ClusterInfoProvider is a contract which is capable of performing cluster info lookups.

type ClusterMap

type ClusterMap interface {
	// GetClusterIDs returns a slice containing all of the cluster identifiers.
	GetClusterIDs() []string

	// AsMap returns the cluster map as a standard go map
	AsMap() map[string]*ClusterInfo

	// InfoFor returns the ClusterInfo entry for the provided clusterID or nil if it
	// doesn't exist
	InfoFor(clusterID string) *ClusterInfo

	// NameFor returns the name of the cluster provided the clusterID.
	NameFor(clusterID string) string

	// NameIDFor returns an identifier in the format "<clusterName>/<clusterID>" if the cluster has an
	// assigned name. Otherwise, just the clusterID is returned.
	NameIDFor(clusterID string) string

	// SplitNameID splits the nameID back into a separate id and name field
	SplitNameID(nameID string) (id string, name string)

	// StopRefresh stops the automatic internal map refresh
	StopRefresh()
}

func NewClusterMap

func NewClusterMap(client prometheus.Client, cip ClusterInfoProvider, refresh time.Duration) ClusterMap

NewClusterMap creates a new ClusterMap implementation using a prometheus or thanos client

type PrometheusClusterMap

type PrometheusClusterMap struct {
	// contains filtered or unexported fields
}

ClusterMap keeps records of all known cost-model clusters.

func (*PrometheusClusterMap) AsMap

func (pcm *PrometheusClusterMap) AsMap() map[string]*ClusterInfo

AsMap returns the cluster map as a standard go map

func (*PrometheusClusterMap) GetClusterIDs

func (pcm *PrometheusClusterMap) GetClusterIDs() []string

GetClusterIDs returns a slice containing all of the cluster identifiers.

func (*PrometheusClusterMap) InfoFor

func (pcm *PrometheusClusterMap) InfoFor(clusterID string) *ClusterInfo

InfoFor returns the ClusterInfo entry for the provided clusterID or nil if it doesn't exist

func (*PrometheusClusterMap) NameFor

func (pcm *PrometheusClusterMap) NameFor(clusterID string) string

NameFor returns the name of the cluster provided the clusterID.

func (*PrometheusClusterMap) NameIDFor

func (pcm *PrometheusClusterMap) NameIDFor(clusterID string) string

NameIDFor returns an identifier in the format "<clusterName>/<clusterID>" if the cluster has an assigned name. Otherwise, just the clusterID is returned.

func (*PrometheusClusterMap) SplitNameID

func (pcm *PrometheusClusterMap) SplitNameID(nameID string) (id string, name string)

func (*PrometheusClusterMap) StopRefresh

func (pcm *PrometheusClusterMap) StopRefresh()

StopRefresh stops the automatic internal map refresh

Jump to

Keyboard shortcuts

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