mirror of
https://github.com/psviderski/uncloud.git
synced 2026-10-06 13:18:58 +00:00
feat(caddy): add ListCertificates method, refactor Caddy client layout (#31)
This commit is contained in:
1 parent
e50c5fbe57
commit
930e7ea637
23 files changed
+1112
-149
No files matched your search
+11
-12
@@ -17,7 +17,6 @@ import (
|
||||
"github.com/docker/docker/api/types/mount"
|
||||
"github.com/docker/docker/api/types/volume"
|
||||
"github.com/docker/go-units"
|
||||
"github.com/psviderski/uncloud/api/pb"
|
||||
"github.com/psviderski/uncloud/internal/machine/metrics"
|
||||
"github.com/psviderski/uncloud/internal/machine/network"
|
||||
"github.com/psviderski/uncloud/internal/secret"
|
||||
@@ -316,7 +315,7 @@ func TestDeployment(t *testing.T) {
|
||||
}
|
||||
})
|
||||
|
||||
deployment, err := cli.NewCaddyDeployment("", "", api.Placement{})
|
||||
deployment, err := cli.Caddy.NewDeployment(ctx, client.CaddyDeploymentOptions{})
|
||||
require.NoError(t, err)
|
||||
deployment.Spec.UpdateConfig.MonitorPeriod = &caddyMonitorPeriod
|
||||
|
||||
@@ -331,7 +330,7 @@ func TestDeployment(t *testing.T) {
|
||||
ctr := svc.Containers[0].Container
|
||||
assert.Regexp(t, `^caddy:2\.\d+\.\d+$`, ctr.Config.Image)
|
||||
|
||||
config, err := cli.Caddy.GetConfig(ctx, nil)
|
||||
config, err := cli.Caddy.Config(ctx, client.CaddyConfigOptions{})
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Contains(t, config.Caddyfile, "# Caddyfile autogenerated by Uncloud")
|
||||
@@ -347,8 +346,8 @@ func TestDeployment(t *testing.T) {
|
||||
})
|
||||
|
||||
// Deploy to machine #0.
|
||||
deployment, err := cli.NewCaddyDeployment("", "", api.Placement{
|
||||
Machines: []string{c.Machines[0].Name},
|
||||
deployment, err := cli.Caddy.NewDeployment(ctx, client.CaddyDeploymentOptions{
|
||||
Placement: api.Placement{Machines: []string{c.Machines[0].Name}},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
deployment.Spec.UpdateConfig.MonitorPeriod = &caddyMonitorPeriod
|
||||
@@ -366,7 +365,7 @@ func TestDeployment(t *testing.T) {
|
||||
// initialContainerID := svc.Containers[0].Container.ID
|
||||
|
||||
// Deploy to all machines without a placement constraint.
|
||||
deployment, err = cli.NewCaddyDeployment(image, "", api.Placement{})
|
||||
deployment, err = cli.Caddy.NewDeployment(ctx, client.CaddyDeploymentOptions{Image: image})
|
||||
require.NoError(t, err)
|
||||
deployment.Spec.UpdateConfig.MonitorPeriod = &caddyMonitorPeriod
|
||||
|
||||
@@ -401,7 +400,7 @@ func TestDeployment(t *testing.T) {
|
||||
|
||||
// Without a Caddy container, the controller has no global config to pair with application configs. Keep any
|
||||
// previously saved Caddyfile unchanged rather than publishing a new one without Caddy's global settings.
|
||||
savedBefore, savedBeforeErr := cli.Caddy.GetConfig(ctx, nil)
|
||||
savedBefore, savedBeforeErr := cli.Caddy.Config(ctx, client.CaddyConfigOptions{})
|
||||
if savedBeforeErr != nil {
|
||||
require.Equal(t, codes.NotFound, status.Code(savedBeforeErr))
|
||||
}
|
||||
@@ -432,7 +431,7 @@ func TestDeployment(t *testing.T) {
|
||||
assertServiceMatchesSpec(t, svc, spec)
|
||||
|
||||
require.Never(t, func() bool {
|
||||
current, currentErr := cli.Caddy.GetConfig(ctx, nil)
|
||||
current, currentErr := cli.Caddy.Config(ctx, client.CaddyConfigOptions{})
|
||||
if savedBeforeErr != nil {
|
||||
return currentErr == nil
|
||||
}
|
||||
@@ -447,7 +446,7 @@ func TestDeployment(t *testing.T) {
|
||||
myapp.example.com {
|
||||
reverse_proxy 1.2.3.4:8000
|
||||
}`
|
||||
caddyDeployment, err := cli.NewCaddyDeployment("", caddyCaddyfile, api.Placement{})
|
||||
caddyDeployment, err := cli.Caddy.NewDeployment(ctx, client.CaddyDeploymentOptions{Config: caddyCaddyfile})
|
||||
require.NoError(t, err)
|
||||
caddyDeployment.Spec.UpdateConfig.MonitorPeriod = &caddyMonitorPeriod
|
||||
|
||||
@@ -459,9 +458,9 @@ myapp.example.com {
|
||||
assertServiceMatchesSpec(t, caddySvc, caddyDeployment.Spec)
|
||||
|
||||
// Wait for the Caddyfile to be regenerated with both custom configs.
|
||||
var config *pb.GetCaddyConfigResponse
|
||||
var config api.CaddyConfig
|
||||
require.Eventually(t, func() bool {
|
||||
config, err = cli.Caddy.GetConfig(ctx, nil)
|
||||
config, err = cli.Caddy.Config(ctx, client.CaddyConfigOptions{})
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
@@ -526,7 +525,7 @@ myapp.example.com {
|
||||
time.Sleep(2 * time.Second)
|
||||
|
||||
// Check that the Caddy config hasn't changed.
|
||||
newConfig, err := cli.Caddy.GetConfig(ctx, nil)
|
||||
newConfig, err := cli.Caddy.Config(ctx, client.CaddyConfigOptions{})
|
||||
require.NoError(t, err)
|
||||
|
||||
// Compare stable parts of the Caddyfile only (skip autogenerated comment with timestamp).
|
||||
|
||||
Reference in new issue
Block a user