Documentation ¶
Index ¶
Constants ¶
const ( // Running Instance state Running InstanceState = "Running" // Stopped Instance state Stopped = "Stopped" // Terminated Instance state Terminated = "Terminated" // Unknown Instance state Unknown = "Unknown" )
const ( // AWSProvider - Amazon Web Services Cloud Provider AWSProvider CloudProvider = "AWS" // AzureProvider - Microsoft Azure Cloud Provider AzureProvider = "Azure" // GCPProvider - Google Cloud Platform Cloud Provider GCPProvider = "GCP" // UnknownProvider - Google Cloud Platform Cloud Provider UnknownProvider = "UNKNOWN" )
const ( // ClusterTagKey string to identify to which cluster is the instance associated ClusterTagKey string = "kubernetes.io/cluster/" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct { // Account's name. It's considered as an uniq key. Two accounts with same // name can't belong to same Inventory Name string `db:"name" json:"name"` // Infrastructure provider identifier. Provider CloudProvider `db:"provider" json:"provider"` // List of clusters deployed on this account indexed by Cluster's name Clusters map[string]*Cluster // contains filtered or unexported fields }
Account defines an infrastructure provider account
func NewAccount ¶
func NewAccount(name string, provider CloudProvider, user string, password string) *Account
NewAccount create a new Could Provider account to store its instances
func (*Account) AddCluster ¶
AddCluster adds a cluster to the stock
func (Account) GetCluster ¶
GetCluster returns cluster on stock by name
func (Account) GetPassword ¶
GetPassword returns the password value
func (Account) IsClusterOnAccount ¶
IsClusterOnAccount checks if a cluster is already in the Stock
func (Account) PrintAccount ¶
func (a Account) PrintAccount()
PrintAccount prints account info and every cluster on it by stdout
type CloudProvider ¶
type CloudProvider string
CloudProvider defines the cloud provider of the instance
type Cluster ¶
type Cluster struct { // Cluster's Name. Must be unique per Account Name string `db:"name" json:"name"` // Infrastructure provider identifier. Provider CloudProvider `db:"provider" json:"provider"` // Defines the status of the cluster if its infrastructure is running or not Status InstanceState `db:"state" json:"status"` // The region of the infrastructure provider in which the cluster is deployed Region string `db:"region" json:"region"` // Account name which this cluster belongs to AccountName string `db:"account_name" json:"accountName"` // Openshift Console URL. Might not be accesible if its protected ConsoleLink string `db:"console_link" json:"consoleLink"` // Cluster's instance (nodes) lists Instances []Instance }
Cluster is the object to store Openshift Clusters and its properties
func NewCluster ¶
func NewCluster(name string, provider CloudProvider, region string, accountName string, consoleLink string) Cluster
NewCluster creates a new cluster instance
func (*Cluster) AddInstance ¶
AddInstance add a new instance to a cluster
func (*Cluster) UpdateStatus ¶
func (c *Cluster) UpdateStatus()
UpdateStatus evaluate the status of the cluster checking how many of the nodes are in Running or Stopped status. As Openshift needs at lease 3 nodes running to be considered correctly Running (3 master nodes), but we cant' figure out which Instance is a master node, if at least 3 of the Cluster instances are running, Cluster will be considered as Running also. If the instances count is less than minInstances, Cluster would be considered as Unknown status TODO: find out a more trustable approach to evaluate cluster status
type Instance ¶
type Instance struct { // Uniq Identifier of the instance ID string `db:"id" json:"id"` // Instance Name. In some Cloud Providers, the name is managed as a Tag Name string `db:"name" json:"name"` // Instance provider (public/private cloud provider) Provider CloudProvider `db:"provider" json:"provider"` // Instance type/size/flavour InstanceType string `db:"instance_type" json:"instanceType"` // Region/Availability Zone in which the instance is running on Region string `db:"region" json:"region"` // Instance Status State InstanceState `db:"state" json:"state"` // ClusterName ClusterName string `db:"cluster_name" json:"clusterName"` // Instance Tags as key-value array Tags []Tag `json:"tags"` }
Instance model a cloud provider instance TODO: doc variables
func NewInstance ¶
func NewInstance(id string, name string, provider CloudProvider, instanceType string, region string, state InstanceState, clusterName string, tags []Tag) *Instance
NewInstance returns a new Instance object
func (Instance) PrintInstance ¶
func (i Instance) PrintInstance()
PrintInstance prints Instance details
type InstanceState ¶
type InstanceState string
InstanceState defines the status of the instance
func AsInstanceState ¶
func AsInstanceState(status string) InstanceState
AsInstanceState converts the incoming argument into a InstanceState type
type Inventory ¶
type Inventory struct { // Accounts map indexed by Account's Name Accounts map[string]Account `redis:"accounts" json:"accounts"` // Date of Inventory creation/update CreationTimestamp time.Time `redis:"creationTimestamp" json:"creationTimestamp"` }
Inventory object to store inventored resources
func (*Inventory) AddAccount ¶
AddAccount adds a new account into the Inventory
func (Inventory) IsAccountOnInventory ¶
IsAccountOnInventory checks if a cluster is already in the Inventory
func (Inventory) PrintInventory ¶
func (s Inventory) PrintInventory()
PrintInventory prints the entire Inventory content