-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.go
More file actions
105 lines (93 loc) · 2.73 KB
/
main.go
File metadata and controls
105 lines (93 loc) · 2.73 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package main
import (
"context"
"fmt"
"os"
"github.com/BerryBytes/awsctl/cmd/root"
"github.com/BerryBytes/awsctl/internal/bastion"
connection "github.com/BerryBytes/awsctl/internal/common"
"github.com/BerryBytes/awsctl/internal/ecr"
"github.com/BerryBytes/awsctl/internal/eks"
"github.com/BerryBytes/awsctl/internal/rds"
"github.com/BerryBytes/awsctl/internal/sso"
"github.com/BerryBytes/awsctl/utils/common"
generalutils "github.com/BerryBytes/awsctl/utils/general"
promptUtils "github.com/BerryBytes/awsctl/utils/prompt"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/service/ec2"
"github.com/aws/aws-sdk-go-v2/service/ec2instanceconnect"
"github.com/aws/aws-sdk-go-v2/service/ssm"
)
var Version = "0.2.0"
func main() {
ssoSetupClient, err := sso.NewSSOClient(sso.NewPrompter(), &common.RealCommandExecutor{})
if err != nil {
fmt.Printf("Error initializing SSO setup client: %v\n", err)
os.Exit(1)
}
generalManager := generalutils.NewGeneralUtilsManager()
fileSystem := &common.RealFileSystem{}
gPrompter := promptUtils.NewPrompt()
ctx := context.TODO()
awsConfig, _ := config.LoadDefaultConfig(ctx)
ec2Client := connection.NewEC2Client(ec2.NewFromConfig(awsConfig))
ssmClient := ssm.NewFromConfig(awsConfig)
configLoader := &connection.DefaultAWSConfigLoader{}
instanceConn := connection.NewEC2InstanceConnectAdapter(ec2instanceconnect.NewFromConfig(awsConfig))
prompter := connection.NewConnectionPrompter()
provider := connection.NewConnectionProvider(
prompter,
fileSystem,
awsConfig,
ec2Client,
ssmClient,
instanceConn,
configLoader,
)
services := connection.NewServices(provider)
bastionSvc := bastion.NewBastionService(services, prompter)
sshExecutor := &common.RealSSHExecutor{}
rdsSvc := rds.NewRDSService(
services,
func(s *rds.RDSService) {
s.ConnProvider = provider
s.SSHExecutor = sshExecutor
s.Fs = fileSystem
s.CPrompter = prompter
s.GPrompter = gPrompter
},
)
eksSvc := eks.NewEKSService(
services,
func(s *eks.EKSService) {
s.ConnProvider = provider
s.CPrompter = prompter
},
)
eksSvc.EKSClient = eks.NewEKSClient(awsConfig, fileSystem)
awsConfigClient := &sso.RealSSOClient{
Executor: &common.RealCommandExecutor{},
}
ecrSvc := ecr.NewECRService(
services,
awsConfigClient,
func(s *ecr.ECRService) {
s.ConnProvider = provider
s.CPrompter = prompter
s.Prompt = gPrompter
},
)
rootCmd := root.NewRootCmd(root.RootDependencies{
SSOSetupClient: ssoSetupClient,
BastionService: bastionSvc,
GeneralManager: generalManager,
FileSystem: fileSystem,
RDSService: rdsSvc,
EKSService: eksSvc,
ECRService: ecrSvc,
Version: Version,
})
if err := rootCmd.Execute(); err != nil {
os.Exit(1)
}
}