-
Notifications
You must be signed in to change notification settings - Fork 24
/
eks.go
44 lines (37 loc) · 1 KB
/
eks.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Package eks provides a datagatherer for EKS.
package eks
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/eks"
)
// EKSDataGatherer is a DataGatherer for EKS.
type EKSDataGatherer struct {
client *eks.EKS
clusterName string
}
// EKSInfo contains the data retrieved from EKS.
type EKSInfo struct {
// https://docs.aws.amazon.com/sdk-for-go/api/service/eks/#Cluster
Cluster *eks.Cluster
}
// NewEKSDataGatherer creates a new EKSDataGatherer for a cluster.
func NewEKSDataGatherer(clusterName string) *EKSDataGatherer {
return &EKSDataGatherer{
client: eks.New(session.New()),
clusterName: clusterName,
}
}
// Fetch retrieves cluster information from EKS.
func (g *EKSDataGatherer) Fetch() (interface{}, error) {
input := &eks.DescribeClusterInput{
Name: aws.String(g.clusterName),
}
result, err := g.client.DescribeCluster(input)
if err != nil {
return nil, err
}
return &EKSInfo{
Cluster: result.Cluster,
}, nil
}