feat: add ListNetworks and GetConfig to ControlPlane interface
- commit
- 590fa2ec9b906276a7316fe1aed4285841bc2a7b
- author
- brice · · 2026-03-14 03:16 UTC
- parent
- c016c64
- signature
- unsigned
4 files · +43 -0
M internal/adapters/in/cli/controlplane.go +2 -0
| @@ -35,6 +35,8 @@ type ControlPlane interface { | |||
| 35 | 35 | ||
| 36 | 36 | GetStatus(ctx context.Context) (*remote.Status, error) | |
| 37 | 37 | Reload(ctx context.Context) error | |
| 38 | + | ListNetworks(ctx context.Context) ([]*domain.NetworkInfo, error) | |
| 39 | + | GetConfig(ctx context.Context) (*remote.Config, error) | |
| 38 | 40 | DeployIntent(ctx context.Context, imageName string) error | |
| 39 | 41 | Deploy(ctx context.Context, deployDomain string) (*remote.DeployResult, error) | |
| 40 | 42 | Restart(ctx context.Context, restartDomain string, withAttachments bool) (*remote.RestartResult, error) | |
| @@ -35,6 +35,8 @@ type ControlPlane interface { | |||||
| 35 | 35 | ||||
| 36 | GetStatus(ctx context.Context) (*remote.Status, error) | 36 | GetStatus(ctx context.Context) (*remote.Status, error) | ||
| 37 | Reload(ctx context.Context) error | 37 | Reload(ctx context.Context) error | ||
| 38 | + | ListNetworks(ctx context.Context) ([]*domain.NetworkInfo, error) | |||
| 39 | + | GetConfig(ctx context.Context) (*remote.Config, error) | |||
| 38 | DeployIntent(ctx context.Context, imageName string) error | 40 | DeployIntent(ctx context.Context, imageName string) error | ||
| 39 | Deploy(ctx context.Context, deployDomain string) (*remote.DeployResult, error) | 41 | Deploy(ctx context.Context, deployDomain string) (*remote.DeployResult, error) | ||
| 40 | Restart(ctx context.Context, restartDomain string, withAttachments bool) (*remote.RestartResult, error) | 42 | Restart(ctx context.Context, restartDomain string, withAttachments bool) (*remote.RestartResult, error) | ||
M internal/adapters/in/cli/controlplane_local.go +25 -0
| @@ -321,6 +321,31 @@ func (l *localControlPlane) Reload(_ context.Context) error { | |||
| 321 | 321 | return app.SendReloadSignal() | |
| 322 | 322 | } | |
| 323 | 323 | ||
| 324 | + | func (l *localControlPlane) ListNetworks(ctx context.Context) ([]*domain.NetworkInfo, error) { | |
| 325 | + | if l.containerSvc == nil { | |
| 326 | + | return nil, fmt.Errorf("container service unavailable") | |
| 327 | + | } | |
| 328 | + | return l.containerSvc.ListNetworks(ctx) | |
| 329 | + | } | |
| 330 | + | ||
| 331 | + | func (l *localControlPlane) GetConfig(ctx context.Context) (*remote.Config, error) { | |
| 332 | + | if l.configSvc == nil { | |
| 333 | + | return nil, fmt.Errorf("config service unavailable") | |
| 334 | + | } | |
| 335 | + | cfg := &remote.Config{ | |
| 336 | + | Routes: l.configSvc.GetRoutes(ctx), | |
| 337 | + | ExternalRoutes: l.configSvc.GetExternalRoutes(), | |
| 338 | + | } | |
| 339 | + | cfg.Server.Port = l.configSvc.GetServerPort() | |
| 340 | + | cfg.Server.RegistryPort = l.configSvc.GetRegistryPort() | |
| 341 | + | cfg.Server.RegistryDomain = l.configSvc.GetRegistryDomain() | |
| 342 | + | cfg.Server.DataDir = l.configSvc.GetDataDir() | |
| 343 | + | cfg.AutoRoute.Enabled = l.configSvc.IsAutoRouteEnabled() | |
| 344 | + | cfg.NetworkIsolation.Enabled = l.configSvc.IsNetworkIsolationEnabled() | |
| 345 | + | cfg.NetworkIsolation.Prefix = l.configSvc.GetNetworkPrefix() | |
| 346 | + | return cfg, nil | |
| 347 | + | } | |
| 348 | + | ||
| 324 | 349 | func (l *localControlPlane) DeployIntent(_ context.Context, imageName string) error { | |
| 325 | 350 | if l.deployCoord != nil { | |
| 326 | 351 | l.deployCoord.SuppressDeployEvent(imageName) | |
| @@ -321,6 +321,31 @@ func (l *localControlPlane) Reload(_ context.Context) error { | |||||
| 321 | return app.SendReloadSignal() | 321 | return app.SendReloadSignal() | ||
| 322 | } | 322 | } | ||
| 323 | 323 | ||||
| 324 | + | func (l *localControlPlane) ListNetworks(ctx context.Context) ([]*domain.NetworkInfo, error) { | |||
| 325 | + | if l.containerSvc == nil { | |||
| 326 | + | return nil, fmt.Errorf("container service unavailable") | |||
| 327 | + | } | |||
| 328 | + | return l.containerSvc.ListNetworks(ctx) | |||
| 329 | + | } | |||
| 330 | + | ||||
| 331 | + | func (l *localControlPlane) GetConfig(ctx context.Context) (*remote.Config, error) { | |||
| 332 | + | if l.configSvc == nil { | |||
| 333 | + | return nil, fmt.Errorf("config service unavailable") | |||
| 334 | + | } | |||
| 335 | + | cfg := &remote.Config{ | |||
| 336 | + | Routes: l.configSvc.GetRoutes(ctx), | |||
| 337 | + | ExternalRoutes: l.configSvc.GetExternalRoutes(), | |||
| 338 | + | } | |||
| 339 | + | cfg.Server.Port = l.configSvc.GetServerPort() | |||
| 340 | + | cfg.Server.RegistryPort = l.configSvc.GetRegistryPort() | |||
| 341 | + | cfg.Server.RegistryDomain = l.configSvc.GetRegistryDomain() | |||
| 342 | + | cfg.Server.DataDir = l.configSvc.GetDataDir() | |||
| 343 | + | cfg.AutoRoute.Enabled = l.configSvc.IsAutoRouteEnabled() | |||
| 344 | + | cfg.NetworkIsolation.Enabled = l.configSvc.IsNetworkIsolationEnabled() | |||
| 345 | + | cfg.NetworkIsolation.Prefix = l.configSvc.GetNetworkPrefix() | |||
| 346 | + | return cfg, nil | |||
| 347 | + | } | |||
| 348 | + | ||||
| 324 | func (l *localControlPlane) DeployIntent(_ context.Context, imageName string) error { | 349 | func (l *localControlPlane) DeployIntent(_ context.Context, imageName string) error { | ||
| 325 | if l.deployCoord != nil { | 350 | if l.deployCoord != nil { | ||
| 326 | l.deployCoord.SuppressDeployEvent(imageName) | 351 | l.deployCoord.SuppressDeployEvent(imageName) | ||
M internal/adapters/in/cli/controlplane_remote.go +8 -0
| @@ -92,6 +92,14 @@ func (r *remoteControlPlane) Reload(ctx context.Context) error { | |||
| 92 | 92 | return r.client.Reload(ctx) | |
| 93 | 93 | } | |
| 94 | 94 | ||
| 95 | + | func (r *remoteControlPlane) ListNetworks(ctx context.Context) ([]*domain.NetworkInfo, error) { | |
| 96 | + | return r.client.ListNetworks(ctx) | |
| 97 | + | } | |
| 98 | + | ||
| 99 | + | func (r *remoteControlPlane) GetConfig(ctx context.Context) (*remote.Config, error) { | |
| 100 | + | return r.client.GetConfig(ctx) | |
| 101 | + | } | |
| 102 | + | ||
| 95 | 103 | func (r *remoteControlPlane) DeployIntent(ctx context.Context, imageName string) error { | |
| 96 | 104 | return r.client.DeployIntent(ctx, imageName) | |
| 97 | 105 | } | |
| @@ -92,6 +92,14 @@ func (r *remoteControlPlane) Reload(ctx context.Context) error { | |||||
| 92 | return r.client.Reload(ctx) | 92 | return r.client.Reload(ctx) | ||
| 93 | } | 93 | } | ||
| 94 | 94 | ||||
| 95 | + | func (r *remoteControlPlane) ListNetworks(ctx context.Context) ([]*domain.NetworkInfo, error) { | |||
| 96 | + | return r.client.ListNetworks(ctx) | |||
| 97 | + | } | |||
| 98 | + | ||||
| 99 | + | func (r *remoteControlPlane) GetConfig(ctx context.Context) (*remote.Config, error) { | |||
| 100 | + | return r.client.GetConfig(ctx) | |||
| 101 | + | } | |||
| 102 | + | ||||
| 95 | func (r *remoteControlPlane) DeployIntent(ctx context.Context, imageName string) error { | 103 | func (r *remoteControlPlane) DeployIntent(ctx context.Context, imageName string) error { | ||
| 96 | return r.client.DeployIntent(ctx, imageName) | 104 | return r.client.DeployIntent(ctx, imageName) | ||
| 97 | } | 105 | } | ||
M internal/adapters/in/cli/push_test.go +8 -0
| @@ -100,6 +100,14 @@ func (c *resolveFromImageTestControlPlane) Reload(context.Context) error { | |||
| 100 | 100 | panic("unexpected call") | |
| 101 | 101 | } | |
| 102 | 102 | ||
| 103 | + | func (c *resolveFromImageTestControlPlane) ListNetworks(context.Context) ([]*domain.NetworkInfo, error) { | |
| 104 | + | panic("unexpected call") | |
| 105 | + | } | |
| 106 | + | ||
| 107 | + | func (c *resolveFromImageTestControlPlane) GetConfig(context.Context) (*remote.Config, error) { | |
| 108 | + | panic("unexpected call") | |
| 109 | + | } | |
| 110 | + | ||
| 103 | 111 | func (c *resolveFromImageTestControlPlane) DeployIntent(context.Context, string) error { | |
| 104 | 112 | panic("unexpected call") | |
| 105 | 113 | } | |
| @@ -100,6 +100,14 @@ func (c *resolveFromImageTestControlPlane) Reload(context.Context) error { | |||||
| 100 | panic("unexpected call") | 100 | panic("unexpected call") | ||
| 101 | } | 101 | } | ||
| 102 | 102 | ||||
| 103 | + | func (c *resolveFromImageTestControlPlane) ListNetworks(context.Context) ([]*domain.NetworkInfo, error) { | |||
| 104 | + | panic("unexpected call") | |||
| 105 | + | } | |||
| 106 | + | ||||
| 107 | + | func (c *resolveFromImageTestControlPlane) GetConfig(context.Context) (*remote.Config, error) { | |||
| 108 | + | panic("unexpected call") | |||
| 109 | + | } | |||
| 110 | + | ||||
| 103 | func (c *resolveFromImageTestControlPlane) DeployIntent(context.Context, string) error { | 111 | func (c *resolveFromImageTestControlPlane) DeployIntent(context.Context, string) error { | ||
| 104 | panic("unexpected call") | 112 | panic("unexpected call") | ||
| 105 | } | 113 | } | ||