Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Check PBS shell examples without rejecting TLS safety warnings

pulse-triage[bot]0955ddf9e0b4
diff --git a/internal/repoctl/setup_bootstrap_docs_test.go b/internal/repoctl/setup_bootstrap_docs_test.go
index 78e458f941..0f7ba066f5 100644
--- a/internal/repoctl/setup_bootstrap_docs_test.go
+++ b/internal/repoctl/setup_bootstrap_docs_test.go
@@ -1,6 +1,31 @@
package repoctl
-import "testing"
+import (
+ "strings"
+ "testing"
+)
+
+func pbsShellExamples(document string) string {
+ var examples []string
+ blocks := strings.Split(document, "```")
+ for i := 1; i < len(blocks); i += 2 {
+ language, body, _ := strings.Cut(blocks[i], "\n")
+ switch strings.TrimSpace(language) {
+ case "bash", "sh", "shell":
+ examples = append(examples, body)
+ }
+ }
+ return strings.Join(examples, "\n")
+}
+
+func TestPBSShellExamplesKeepWarningsSeparateFromCommands(t *testing.T) {
+ document := "Do not use `--insecure` or `-k`.\n```bash\ncurl --fail https://pbs.example.com\n```\n" +
+ "```sh\ncurl --insecure https://pbs.example.com\n```\n"
+ examples := pbsShellExamples(document)
+ if examples != "curl --fail https://pbs.example.com\n\ncurl --insecure https://pbs.example.com\n" {
+ t.Fatalf("unexpected shell examples: %q", examples)
+ }
+}
func TestSetupBootstrapDocsStayOnCanonicalArtifactContract(t *testing.T) {
apiRel := "docs/API.md"
@@ -31,10 +56,15 @@ func TestSetupBootstrapDocsStayOnCanonicalArtifactContract(t *testing.T) {
`--enable-proxmox --proxmox-type pbs --enable-docker=false`,
"Do not bypass certificate checks",
})
- assertContainsNone(t, pbsRel, pbsDoc, []string{
+ shellExamples := pbsShellExamples(pbsDoc)
+ if shellExamples == "" {
+ t.Fatal("PBS guide must retain executable shell examples")
+ }
+ assertContainsNone(t, pbsRel, shellExamples, []string{
`curl -sSL "http://<pulse-ip>:7655/api/setup-script?type=pbs&host=https://<pbs-ip>:8007&pulse_url=http://<pulse-ip>:7655" | bash`,
`PULSE_SETUP_TOKEN=`,
`sudo env PULSE_SETUP_TOKEN=`,
`--insecure`,
+ ` -k`,
})
}