v2.31.0 e02f654

controlplane_remote.go RawHistoryFolder

1package cli
2
3import (
4	"context"
5	"fmt"
6
7	"github.com/bnema/gordon/internal/adapters/dto"
8	"github.com/bnema/gordon/internal/adapters/in/cli/remote"
9	"github.com/bnema/gordon/internal/domain"
10)
11
12type remoteControlPlane struct {
13	client *remote.Client
14}
15
16func NewRemoteControlPlane(client *remote.Client) ControlPlane {
17	return &remoteControlPlane{client: client}
18}
19
20func (r *remoteControlPlane) ListRoutesWithDetails(ctx context.Context) ([]remote.RouteInfo, error) {
21	return r.client.ListRoutesWithDetails(ctx)
22}
23
24func (r *remoteControlPlane) GetHealth(ctx context.Context) (map[string]*remote.RouteHealth, error) {
25	return r.client.GetHealth(ctx)
26}
27
28func (r *remoteControlPlane) GetRoute(ctx context.Context, routeDomain string) (*domain.Route, error) {
29	return r.client.GetRoute(ctx, routeDomain)
30}
31
32func (r *remoteControlPlane) FindRoutesByImage(ctx context.Context, imageName string) ([]domain.Route, error) {
33	return r.client.FindRoutesByImage(ctx, imageName)
34}
35
36func (r *remoteControlPlane) AddRoute(ctx context.Context, route domain.Route) error {
37	return r.client.AddRoute(ctx, route)
38}
39
40func (r *remoteControlPlane) UpdateRoute(ctx context.Context, route domain.Route) error {
41	return r.client.UpdateRoute(ctx, route)
42}
43
44func (r *remoteControlPlane) RemoveRoute(ctx context.Context, routeDomain string) error {
45	_, err := r.RemoveRouteWithCleanup(ctx, routeDomain)
46	return err
47}
48
49func (r *remoteControlPlane) RemoveRouteWithCleanup(ctx context.Context, routeDomain string) (*dto.RouteDeleteResponse, error) {
50	return r.client.RemoveRouteWithCleanup(ctx, routeDomain)
51}
52
53func (r *remoteControlPlane) GetRouteCleanupPreview(ctx context.Context, routeDomain string) (*domain.CleanupReport, error) {
54	return r.client.GetRouteCleanupPreview(ctx, routeDomain)
55}
56
57func (r *remoteControlPlane) Bootstrap(ctx context.Context, req dto.BootstrapRequest) (*dto.BootstrapResponse, error) {
58	return r.client.Bootstrap(ctx, req)
59}
60
61func (r *remoteControlPlane) ListSecretsWithAttachments(ctx context.Context, secretDomain string) (*remote.SecretsListResult, error) {
62	return r.client.ListSecretsWithAttachments(ctx, secretDomain)
63}
64
65func (r *remoteControlPlane) SetSecrets(ctx context.Context, secretDomain string, secrets map[string]string) error {
66	return r.client.SetSecrets(ctx, secretDomain, secrets)
67}
68
69func (r *remoteControlPlane) DeleteSecret(ctx context.Context, secretDomain, key string) error {
70	return r.client.DeleteSecret(ctx, secretDomain, key)
71}
72
73func (r *remoteControlPlane) SetAttachmentSecrets(ctx context.Context, domainName, service string, secrets map[string]string) error {
74	return r.client.SetAttachmentSecrets(ctx, domainName, service, secrets)
75}
76
77func (r *remoteControlPlane) DeleteAttachmentSecret(ctx context.Context, domainName, service, key string) error {
78	return r.client.DeleteAttachmentSecret(ctx, domainName, service, key)
79}
80
81func (r *remoteControlPlane) ListOrphanedAttachments(ctx context.Context) ([]domain.CleanupAttachment, error) {
82	return r.client.ListOrphanedAttachments(ctx)
83}
84
85func (r *remoteControlPlane) CleanupOrphanedAttachments(ctx context.Context, owner string, stop bool) (*domain.CleanupReport, error) {
86	return r.client.CleanupOrphanedAttachments(ctx, owner, stop)
87}
88
89func (r *remoteControlPlane) GetAllAttachmentsConfig(ctx context.Context) (map[string][]string, error) {
90	return r.client.GetAllAttachmentsConfig(ctx)
91}
92
93func (r *remoteControlPlane) GetAttachmentsConfig(ctx context.Context, domainOrGroup string) ([]string, error) {
94	return r.client.GetAttachmentsConfig(ctx, domainOrGroup)
95}
96
97func (r *remoteControlPlane) FindAttachmentTargetsByImage(ctx context.Context, imageName string) ([]string, error) {
98	return r.client.FindAttachmentTargetsByImage(ctx, imageName)
99}
100
101func (r *remoteControlPlane) AddAttachment(ctx context.Context, domainOrGroup, image string) error {
102	return r.client.AddAttachment(ctx, domainOrGroup, image)
103}
104
105func (r *remoteControlPlane) RemoveAttachment(ctx context.Context, domainOrGroup, image string) error {
106	return r.client.RemoveAttachment(ctx, domainOrGroup, image)
107}
108
109func (r *remoteControlPlane) GetAutoRouteAllowedDomains(ctx context.Context) ([]string, error) {
110	return r.client.GetAutoRouteAllowedDomains(ctx)
111}
112
113func (r *remoteControlPlane) AddAutoRouteAllowedDomain(ctx context.Context, pattern string) error {
114	return r.client.AddAutoRouteAllowedDomain(ctx, pattern)
115}
116
117func (r *remoteControlPlane) RemoveAutoRouteAllowedDomain(ctx context.Context, pattern string) error {
118	return r.client.RemoveAutoRouteAllowedDomain(ctx, pattern)
119}
120
121func (r *remoteControlPlane) GetStatus(ctx context.Context) (*remote.Status, error) {
122	return r.client.GetStatus(ctx)
123}
124
125func (r *remoteControlPlane) GetTLSStatus(ctx context.Context) (*dto.TLSStatusResponse, error) {
126	return r.client.GetTLSStatus(ctx)
127}
128
129func (r *remoteControlPlane) GetTrafficStatus(ctx context.Context) (*dto.TrafficStatusResponse, error) {
130	return r.client.GetTrafficStatus(ctx)
131}
132
133func (r *remoteControlPlane) Reload(ctx context.Context) error {
134	return r.client.Reload(ctx)
135}
136
137func (r *remoteControlPlane) ListNetworks(ctx context.Context) ([]*domain.NetworkInfo, error) {
138	return r.client.ListNetworks(ctx)
139}
140
141func (r *remoteControlPlane) GetConfig(ctx context.Context) (*remote.Config, error) {
142	return r.client.GetConfig(ctx)
143}
144
145func (r *remoteControlPlane) DeployIntent(ctx context.Context, imageName string) error {
146	return r.client.DeployIntent(ctx, imageName)
147}
148
149func (r *remoteControlPlane) Deploy(ctx context.Context, deployDomain string) (*remote.DeployResult, error) {
150	return r.client.Deploy(ctx, deployDomain)
151}
152
153func (r *remoteControlPlane) Restart(ctx context.Context, restartDomain string, withAttachments bool) (*remote.RestartResult, error) {
154	return r.client.Restart(ctx, restartDomain, withAttachments)
155}
156
157func (r *remoteControlPlane) ListTags(ctx context.Context, repository string) ([]string, error) {
158	return r.client.ListTags(ctx, repository)
159}
160
161func (r *remoteControlPlane) ListBackups(ctx context.Context, backupDomain string) ([]dto.BackupJob, error) {
162	return r.client.ListBackups(ctx, backupDomain)
163}
164
165func (r *remoteControlPlane) BackupStatus(ctx context.Context) ([]dto.BackupJob, error) {
166	return r.client.BackupStatus(ctx)
167}
168
169func (r *remoteControlPlane) RunBackup(ctx context.Context, backupDomain, dbName string) (*dto.BackupRunResponse, error) {
170	return r.client.RunBackup(ctx, backupDomain, dbName)
171}
172
173func (r *remoteControlPlane) DetectDatabases(ctx context.Context, backupDomain string) ([]dto.DatabaseInfo, error) {
174	return r.client.DetectDatabases(ctx, backupDomain)
175}
176
177func (r *remoteControlPlane) ListVolumeBackups(ctx context.Context, backupDomain string) ([]dto.VolumeBackupJob, error) {
178	jobs, err := r.client.ListVolumeBackups(ctx, backupDomain)
179	if err != nil {
180		return nil, fmt.Errorf("list volume backups: %w", err)
181	}
182	return jobs, nil
183}
184
185func (r *remoteControlPlane) VolumeBackupStatus(ctx context.Context) ([]dto.VolumeBackupJob, error) {
186	jobs, err := r.client.VolumeBackupStatus(ctx)
187	if err != nil {
188		return nil, fmt.Errorf("get volume backup status: %w", err)
189	}
190	return jobs, nil
191}
192
193func (r *remoteControlPlane) RunVolumeBackups(ctx context.Context, backupDomain, volumeName string) (*dto.VolumeBackupRunResponse, error) {
194	result, err := r.client.RunVolumeBackups(ctx, backupDomain, volumeName)
195	if err != nil {
196		return result, fmt.Errorf("run volume backups: %w", err)
197	}
198	return result, nil
199}
200
201func (r *remoteControlPlane) GetProcessLogs(ctx context.Context, lines int) ([]string, error) {
202	return r.client.GetProcessLogs(ctx, lines)
203}
204
205func (r *remoteControlPlane) GetContainerLogs(ctx context.Context, logDomain string, lines int) ([]string, error) {
206	return r.client.GetContainerLogs(ctx, logDomain, lines)
207}
208
209func (r *remoteControlPlane) StreamProcessLogs(ctx context.Context, lines int) (<-chan string, error) {
210	return r.client.StreamProcessLogs(ctx, lines)
211}
212
213func (r *remoteControlPlane) StreamContainerLogs(ctx context.Context, logDomain string, lines int) (<-chan string, error) {
214	return r.client.StreamContainerLogs(ctx, logDomain, lines)
215}
216
217func (r *remoteControlPlane) ListVolumes(ctx context.Context) ([]dto.Volume, error) {
218	return r.client.ListVolumes(ctx)
219}
220
221func (r *remoteControlPlane) PruneVolumes(ctx context.Context, req dto.VolumePruneRequest) (*dto.VolumePruneResponse, error) {
222	return r.client.PruneVolumes(ctx, req)
223}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 7

Tags 106

↑↓ moveenter openesc close