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) ListSecretsWithAttachments(ctx context.Context, secretDomain string) (*remote.SecretsListResult, error) {
48 return r.client.ListSecretsWithAttachments(ctx, secretDomain)
49}
50
51func (r *remoteControlPlane) SetSecrets(ctx context.Context, secretDomain string, secrets map[string]string) error {
52 return r.client.SetSecrets(ctx, secretDomain, secrets)
53}
54
55func (r *remoteControlPlane) DeleteSecret(ctx context.Context, secretDomain, key string) error {
56 return r.client.DeleteSecret(ctx, secretDomain, key)
57}
58
59func (r *remoteControlPlane) SetAttachmentSecrets(ctx context.Context, domainName, service string, secrets map[string]string) error {
60 return r.client.SetAttachmentSecrets(ctx, domainName, service, secrets)
61}
62
63func (r *remoteControlPlane) DeleteAttachmentSecret(ctx context.Context, domainName, service, key string) error {
64 return r.client.DeleteAttachmentSecret(ctx, domainName, service, key)
65}
66
67func (r *remoteControlPlane) GetAllAttachmentsConfig(ctx context.Context) (map[string][]string, error) {
68 return r.client.GetAllAttachmentsConfig(ctx)
69}
70
71func (r *remoteControlPlane) GetAttachmentsConfig(ctx context.Context, domainOrGroup string) ([]string, error) {
72 return r.client.GetAttachmentsConfig(ctx, domainOrGroup)
73}
74
75func (r *remoteControlPlane) AddAttachment(ctx context.Context, domainOrGroup, image string) error {
76 return r.client.AddAttachment(ctx, domainOrGroup, image)
77}
78
79func (r *remoteControlPlane) RemoveAttachment(ctx context.Context, domainOrGroup, image string) error {
80 return r.client.RemoveAttachment(ctx, domainOrGroup, image)
81}
82
83func (r *remoteControlPlane) GetStatus(ctx context.Context) (*remote.Status, error) {
84 return r.client.GetStatus(ctx)
85}
86
87func (r *remoteControlPlane) Reload(ctx context.Context) error {
88 return r.client.Reload(ctx)
89}
90
91func (r *remoteControlPlane) Deploy(ctx context.Context, deployDomain string) (*remote.DeployResult, error) {
92 return r.client.Deploy(ctx, deployDomain)
93}
94
95func (r *remoteControlPlane) Restart(ctx context.Context, restartDomain string, withAttachments bool) (*remote.RestartResult, error) {
96 return r.client.Restart(ctx, restartDomain, withAttachments)
97}
98
99func (r *remoteControlPlane) ListTags(ctx context.Context, repository string) ([]string, error) {
100 return r.client.ListTags(ctx, repository)
101}
102
103func (r *remoteControlPlane) ListBackups(ctx context.Context, backupDomain string) ([]dto.BackupJob, error) {
104 return r.client.ListBackups(ctx, backupDomain)
105}
106
107func (r *remoteControlPlane) BackupStatus(ctx context.Context) ([]dto.BackupJob, error) {
108 return r.client.BackupStatus(ctx)
109}
110
111func (r *remoteControlPlane) RunBackup(ctx context.Context, backupDomain, dbName string) (*dto.BackupRunResponse, error) {
112 return r.client.RunBackup(ctx, backupDomain, dbName)
113}
114
115func (r *remoteControlPlane) DetectDatabases(ctx context.Context, backupDomain string) ([]dto.DatabaseInfo, error) {
116 return r.client.DetectDatabases(ctx, backupDomain)
117}
118
119func (r *remoteControlPlane) GetProcessLogs(ctx context.Context, lines int) ([]string, error) {
120 return r.client.GetProcessLogs(ctx, lines)
121}
122
123func (r *remoteControlPlane) GetContainerLogs(ctx context.Context, logDomain string, lines int) ([]string, error) {
124 return r.client.GetContainerLogs(ctx, logDomain, lines)
125}
126
127func (r *remoteControlPlane) StreamProcessLogs(ctx context.Context, lines int) (<-chan string, error) {
128 return r.client.StreamProcessLogs(ctx, lines)
129}
130
131func (r *remoteControlPlane) StreamContainerLogs(ctx context.Context, logDomain string, lines int) (<-chan string, error) {
132 return r.client.StreamContainerLogs(ctx, logDomain, lines)
133}