feat(httpapi): return replica docker install commands on speaker create
quality / commitlint (push) Skipped
quality / changes (push) Successful in 8s
quality / docker-check (push) Skipped
quality / openapi (push) Failing after 21s
quality / web (push) Successful in 55s
quality / go (push) Successful in 1m2s
quality / bird2 (push) Successful in 16s
CD / quality (push) Failing after 2m49s
CD / publish (push) Skipped
quality / commitlint (push) Skipped
quality / changes (push) Successful in 8s
quality / docker-check (push) Skipped
quality / openapi (push) Failing after 21s
quality / web (push) Successful in 55s
quality / go (push) Successful in 1m2s
quality / bird2 (push) Successful in 16s
CD / quality (push) Failing after 2m49s
CD / publish (push) Skipped
После создания реплики 201 отдаёт agent_secret, node_token и install.docker_commands (bird2 + agent + Traefik DNS-01). UI показывает шаг установки вместо закрытия диалога, чтобы секрет больше не терялся. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
package speakerinstall
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestBuild_includesTraefikDNS01(t *testing.T) {
|
||||
res, err := Build(Params{
|
||||
SpeakerID: "11111111-1111-1111-1111-111111111111",
|
||||
AgentSecret: "secret-abc",
|
||||
NodeToken: "node-tok",
|
||||
BundlePubkey: "pubkey==",
|
||||
ControlPlaneURL: "https://cp.example.com",
|
||||
AgentDomain: "bgp-dc2.example.com",
|
||||
LetsEncryptEmail: "[email protected]",
|
||||
CFDNSAPIToken: "cf-token-xyz",
|
||||
PanelIPWhitelist: "203.0.113.1/32",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cmd := res.DockerCommands
|
||||
for _, want := range []string{
|
||||
"traefik",
|
||||
"dnschallenge=true",
|
||||
"dnschallenge.provider=cloudflare",
|
||||
"CF_DNS_API_TOKEN",
|
||||
"cf-token-xyz",
|
||||
"Host(`bgp-dc2.example.com`)",
|
||||
"secret-abc",
|
||||
"node-tok",
|
||||
"https://cp.example.com",
|
||||
"docker compose up -d",
|
||||
"sysctl -w net.ipv4.ip_forward=1",
|
||||
"evobgp_speaker_traefik_letsencrypt",
|
||||
} {
|
||||
if !strings.Contains(cmd, want) {
|
||||
t.Errorf("docker_commands missing %q", want)
|
||||
}
|
||||
}
|
||||
if strings.Contains(cmd, "?set ") {
|
||||
t.Error("compose must bake values, not ${VAR:?set VAR}")
|
||||
}
|
||||
if res.ComposeYAML == "" {
|
||||
t.Fatal("compose_yaml empty")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuild_placeholdersWhenEmpty(t *testing.T) {
|
||||
res, err := Build(Params{SpeakerID: "id", AgentSecret: "s", NodeToken: "t", BundlePubkey: "p"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, ph := range []string{
|
||||
placeholderAgentDomain,
|
||||
placeholderLetsEncryptEmail,
|
||||
placeholderCFDNSToken,
|
||||
placeholderPanelIP,
|
||||
placeholderControlPlaneURL,
|
||||
} {
|
||||
if !strings.Contains(res.DockerCommands, ph) {
|
||||
t.Errorf("expected placeholder %s", ph)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user