-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.go
48 lines (39 loc) · 834 Bytes
/
util.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
45
46
47
48
package util
import (
"fmt"
"github.com/aws/aws-sdk-go-v2/service/ec2"
elbv2 "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2"
"github.com/aws/aws-sdk-go-v2/service/rds"
)
type AWSObject interface {
Create() (string, error)
Delete() error
}
func CheckEC2Session(e2 *ec2.Client) error {
if e2 == nil {
return fmt.Errorf("No ec2 session found")
}
return nil
}
func CheckELBV2Session(elb *elbv2.Client) error {
if elb == nil {
return fmt.Errorf("No elbv2 session found")
}
return nil
}
func CheckRDSSession(db *rds.Client) error {
if db == nil {
return fmt.Errorf("No rds session found")
}
return nil
}
type CreateError struct {
Text string
Err error
}
func (e CreateError) Error() string {
return fmt.Sprintf("%s: %v", e.Text, e.Err)
}
func (e CreateError) Unwrap() error {
return e.Err
}