1package cli
2
3import (
4 "context"
5
6 "github.com/bnema/gordon/internal/adapters/dto"
7 "github.com/bnema/gordon/internal/adapters/in/cli/remote"
8 "github.com/bnema/gordon/internal/domain"
9)
10
11type remoteControlPlane struct {
12 client *remote.Client
13}
14
15func NewRemoteControlPlane(client *remote.Client) ControlPlane {
16 return &remoteControlPlane{client: client}
17}
18
19func (r *remoteControlPlane) ListRoutesWithDetails(ctx context.Context) ([]remote.RouteInfo, error) {
20 return r.client.ListRoutesWithDetails(ctx)
21}
22
23func (r *remoteControlPlane) GetHealth(ctx context.Context) (map[string]*remote.RouteHealth, error) {
24 return r.client.GetHealth(ctx)
25}
26
27func (r *remoteControlPlane) GetRoute(ctx context.Context, routeDomain string) (*domain.Route, error) {
28 return r.client.GetRoute(ctx, routeDomain)
29}
30
31func (r *remoteControlPlane) FindRoutesByImage(ctx context.Context, imageName string) ([]domain.Route, error) {
32 return r.client.FindRoutesByImage(ctx, imageName)
33}
34
35func (r *remoteControlPlane) AddRoute(ctx context.Context, route domain.Route) error {
36 return r.client.AddRoute(ctx, route)
37}
38
39func (r *remoteControlPlane) UpdateRoute(ctx context.Context, route domain.Route) error {
40 return r.client.UpdateRoute(ctx, route)
41}
42
43func (r *remoteControlPlane) RemoveRoute(ctx context.Context, routeDomain string) error {
44 return r.client.RemoveRoute(ctx, routeDomain)
45}
46
47func (r *remoteControlPlane) Bootstrap(ctx context.Context, req dto.BootstrapRequest) (*dto.BootstrapResponse, error) {
48 return r.client.Bootstrap(ctx, req)
49}
50
51func (r *remoteControlPlane) ListSecretsWithAttachments(ctx context.Context, secretDomain string) (*remote.SecretsListResult, error) {
52 return r.client.ListSecretsWithAttachments(ctx, secretDomain)
53}
54
55func (r *remoteControlPlane) SetSecrets(ctx context.Context, secretDomain string, secrets map[string]string) error {
56 return r.client.SetSecrets(ctx, secretDomain, secrets)
57}
58
59func (r *remoteControlPlane) DeleteSecret(ctx context.Context, secretDomain, key string) error {
60 return r.client.DeleteSecret(ctx, secretDomain, key)
61}
62
63func (r *remoteControlPlane) SetAttachmentSecrets(ctx context.Context, domainName, service string, secrets map[string]string) error {
64 return r.client.SetAttachmentSecrets(ctx, domainName, service, secrets)
65}
66
67func (r *remoteControlPlane) DeleteAttachmentSecret(ctx context.Context, domainName, service, key string) error {
68 return r.client.DeleteAttachmentSecret(ctx, domainName, service, key)
69}
70
71func (r *remoteControlPlane) GetAllAttachmentsConfig(ctx context.Context) (map[string][]string, error) {
72 return r.client.GetAllAttachmentsConfig(ctx)
73}
74
75func (r *remoteControlPlane) GetAttachmentsConfig(ctx context.Context, domainOrGroup string) ([]string, error) {
76 return r.client.GetAttachmentsConfig(ctx, domainOrGroup)
77}
78
79func (r *remoteControlPlane) FindAttachmentTargetsByImage(ctx context.Context, imageName string) ([]string, error) {
80 return r.client.FindAttachmentTargetsByImage(ctx, imageName)
81}
82
83func (r *remoteControlPlane) AddAttachment(ctx context.Context, domainOrGroup, image string) error {
84 return r.client.AddAttachment(ctx, domainOrGroup, image)
85}
86
87func (r *remoteControlPlane) RemoveAttachment(ctx context.Context, domainOrGroup, image string) error {
88 return r.client.RemoveAttachment(ctx, domainOrGroup, image)
89}
90
91func (r *remoteControlPlane) GetAutoRouteAllowedDomains(ctx context.Context) ([]string, error) {
92 return r.client.GetAutoRouteAllowedDomains(ctx)
93}
94
95func (r *remoteControlPlane) AddAutoRouteAllowedDomain(ctx context.Context, pattern string) error {
96 return r.client.AddAutoRouteAllowedDomain(ctx, pattern)
97}
98
99func (r *remoteControlPlane) RemoveAutoRouteAllowedDomain(ctx context.Context, pattern string) error {
100 return r.client.RemoveAutoRouteAllowedDomain(ctx, pattern)
101}
102
103func (r *remoteControlPlane) GetStatus(ctx context.Context) (*remote.Status, error) {
104 return r.client.GetStatus(ctx)
105}
106
107func (r *remoteControlPlane) GetTLSStatus(ctx context.Context) (*dto.TLSStatusResponse, error) {
108 return r.client.GetTLSStatus(ctx)
109}
110
111func (r *remoteControlPlane) Reload(ctx context.Context) error {
112 return r.client.Reload(ctx)
113}
114
115func (r *remoteControlPlane) ListNetworks(ctx context.Context) ([]*domain.NetworkInfo, error) {
116 return r.client.ListNetworks(ctx)
117}
118
119func (r *remoteControlPlane) GetConfig(ctx context.Context) (*remote.Config, error) {
120 return r.client.GetConfig(ctx)
121}
122
123func (r *remoteControlPlane) DeployIntent(ctx context.Context, imageName string) error {
124 return r.client.DeployIntent(ctx, imageName)
125}
126
127func (r *remoteControlPlane) Deploy(ctx context.Context, deployDomain string) (*remote.DeployResult, error) {
128 return r.client.Deploy(ctx, deployDomain)
129}
130
131func (r *remoteControlPlane) Restart(ctx context.Context, restartDomain string, withAttachments bool) (*remote.RestartResult, error) {
132 return r.client.Restart(ctx, restartDomain, withAttachments)
133}
134
135func (r *remoteControlPlane) ListTags(ctx context.Context, repository string) ([]string, error) {
136 return r.client.ListTags(ctx, repository)
137}
138
139func (r *remoteControlPlane) ListBackups(ctx context.Context, backupDomain string) ([]dto.BackupJob, error) {
140 return r.client.ListBackups(ctx, backupDomain)
141}
142
143func (r *remoteControlPlane) BackupStatus(ctx context.Context) ([]dto.BackupJob, error) {
144 return r.client.BackupStatus(ctx)
145}
146
147func (r *remoteControlPlane) RunBackup(ctx context.Context, backupDomain, dbName string) (*dto.BackupRunResponse, error) {
148 return r.client.RunBackup(ctx, backupDomain, dbName)
149}
150
151func (r *remoteControlPlane) DetectDatabases(ctx context.Context, backupDomain string) ([]dto.DatabaseInfo, error) {
152 return r.client.DetectDatabases(ctx, backupDomain)
153}
154
155func (r *remoteControlPlane) GetProcessLogs(ctx context.Context, lines int) ([]string, error) {
156 return r.client.GetProcessLogs(ctx, lines)
157}
158
159func (r *remoteControlPlane) GetContainerLogs(ctx context.Context, logDomain string, lines int) ([]string, error) {
160 return r.client.GetContainerLogs(ctx, logDomain, lines)
161}
162
163func (r *remoteControlPlane) StreamProcessLogs(ctx context.Context, lines int) (<-chan string, error) {
164 return r.client.StreamProcessLogs(ctx, lines)
165}
166
167func (r *remoteControlPlane) StreamContainerLogs(ctx context.Context, logDomain string, lines int) (<-chan string, error) {
168 return r.client.StreamContainerLogs(ctx, logDomain, lines)
169}
170
171func (r *remoteControlPlane) ListVolumes(ctx context.Context) ([]dto.Volume, error) {
172 return r.client.ListVolumes(ctx)
173}
174
175func (r *remoteControlPlane) PruneVolumes(ctx context.Context, req dto.VolumePruneRequest) (*dto.VolumePruneResponse, error) {
176 return r.client.PruneVolumes(ctx, req)
177}