fix(certificates): add reliable issuance progress and DNS propagation handling
- replace raw ACME terminal logs with a scrollable TUI progress console - check authoritative DNS servers to avoid stale recursive cache delays - add per-order timeouts and actionable failure messages - support safe cancellation with DNS challenge cleanup - add background progress, summaries, and activity history - expand certificate workflow and TUI regression tests
This commit is contained in:
15 files changed
+719
-44
No files matched your search
@@ -4,6 +4,8 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
"time"
|
||||
@@ -16,6 +18,7 @@ import (
|
||||
cloudflareprovider "github.com/MeghdadFadaee/domainops/internal/providers/cloudflare"
|
||||
"github.com/MeghdadFadaee/domainops/internal/secrets"
|
||||
sqlitestore "github.com/MeghdadFadaee/domainops/internal/store/sqlite"
|
||||
legolog "github.com/go-acme/lego/v5/log"
|
||||
)
|
||||
|
||||
type Options struct {
|
||||
@@ -35,10 +38,25 @@ type Runtime struct {
|
||||
}
|
||||
|
||||
func Open(ctx context.Context, options Options) (*Runtime, error) {
|
||||
configureACMELogger()
|
||||
paths, err := config.Resolve(options.DataDir)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Continue with all local resource initialization only after logging is
|
||||
// isolated from stdout; JSON and alternate-screen output must stay clean.
|
||||
return openRuntime(ctx, options, paths)
|
||||
}
|
||||
|
||||
func configureACMELogger() {
|
||||
// lego's default logger writes directly to stdout, which corrupts both the
|
||||
// Bubble Tea alternate screen and JSON CLI envelopes. DomainOps exposes
|
||||
// bounded, structured certificate progress through its own job/event model.
|
||||
legolog.SetDefault(slog.New(slog.NewTextHandler(io.Discard, nil)))
|
||||
}
|
||||
|
||||
func openRuntime(ctx context.Context, options Options, paths config.Paths) (*Runtime, error) {
|
||||
if err := paths.Ensure(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
package bootstrap
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"log/slog"
|
||||
"testing"
|
||||
|
||||
legolog "github.com/go-acme/lego/v5/log"
|
||||
)
|
||||
|
||||
func TestReconcileJobsAfterRecoveryRunsOnlyAfterSuccessfulRecovery(t *testing.T) {
|
||||
@@ -26,3 +30,15 @@ func TestReconcileJobsAfterRecoveryRunsOnlyAfterSuccessfulRecovery(t *testing.T)
|
||||
t.Fatalf("successful recovery result = %v, reconcile called=%v", err, called)
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfigureACMELoggerDoesNotWriteToTerminal(t *testing.T) {
|
||||
original := legolog.Default()
|
||||
defer legolog.SetDefault(original)
|
||||
var output bytes.Buffer
|
||||
legolog.SetDefault(slog.New(slog.NewTextHandler(&output, nil)))
|
||||
configureACMELogger()
|
||||
legolog.Info("dns01: waiting for record propagation.", slog.String("domain", "*.example.com"))
|
||||
if output.Len() != 0 {
|
||||
t.Fatalf("ACME logger escaped to terminal: %q", output.String())
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user