feat: generic wizard framework, websites wizard with validation retry#45
Merged
Merged
Conversation
This comment has been minimized.
This comment has been minimized.
…etry - Extract reusable wizard framework into pkg/cli/wizard/ using Go generics (Step[S any], StepFunc[S], Run[S any]) - Step interface: Name, ShouldSkip, Execute, ShouldRetry — retry is a first-class concept, the framework owns the loop - Add wizard.UI with ShowStepProgress/ShowStepSkipped/ShowStepRetrying/ ShowCompletion; PTermUI and MockUI as embeddable building blocks - Migrate SetupWizard to wizard.Step[*SetupWizard] and wizard.Run - Add 'pinner websites wizard' with 7-step guided flow: Auth Check, Content Source, Domain, DNS Mode, Create Website, DNS Setup (skipped if self-managed), Validation (retries via ShouldRetry until valid or user skips) - Add 'website' as alias for 'websites' command - Validation step: shows required DNS records, prompts user, signals retry via wizard state — framework re-executes automatically. Service errors and invalid results are retryable, not fatal - Fix pinner websites validate: show DNS record instructions when validation fails instead of raw error; proper single-object JSON output with required_records field - Extract doWebsitesValidate() to DRY test helper (no duplicate logic) - Guard nil ExecuteFunc in StepFunc.Execute() with descriptive error - Fix MockUI ReturnError consistency with errorIfSet() helper - All tests pass, golangci-lint clean
d064707 to
f3bebac
Compare
Code Coverage ReportTotal Coverage: 34.3% Generated from commit: 8ed0fb6 |
…ntext - executeDNSSetup and setupDNSHosting were generating a local validation token instead of using the server-assigned website.ValidationToken, causing validation to always fail after DNS setup — the DNS TXT record contained a token the server didn't recognize - Change setupDNSHosting signature to accept *WebsiteItem instead of domain/targetHash strings, using website.ValidationToken directly - Remove now-unused generateValidationToken() function - Fix ExecuteValidateStep to propagate the incoming context to executeValidate() instead of using context.Background(), preserving cancellation and deadline propagation
Kody Review CompleteGreat news! 🎉 Keep up the excellent work! 🚀 Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
pkg/cli/wizard/using Go generics (Step[S any],StepFunc[S],Run[S any])ShouldRetryas a first-class concept in theStepinterface — the framework owns the retry loop, steps signal retry via statepinner websites wizardwith 7-step guided flow: Auth Check → Content Source → Domain → DNS Mode → Create Website → DNS Setup → Validationwebsiteas alias forwebsitescommandpinner websites validate: show DNS record instructions on failure instead of raw error; proper single-object JSON output withrequired_recordsIntroduce a reusable generic wizard framework and add an interactive website creation wizard built on top of it.
Wizard Framework (
pkg/cli/wizard/):Run[S any]function with aStep[S]interface,StepFuncadapter,UIinterface, andResultstruct.UIinterface.ShouldRetry, enabling steps like validation to be re-executed until they succeed or the user opts out.Setup Wizard Refactor:
SetupStepinterface and concrete step types withwizard.StepFunc[*SetupWizard]closures, delegating orchestration towizard.Run.SetupUInow embedswizard.UI, andPTermSetupUI/MockSetupUIembed the shared PTerm/Mock implementations, eliminating duplicated display and call-tracking code.SetupWizard.Runnow returns(wizard.Result, error)with completion metrics.Websites Wizard (
pinner websites wizard):Websites Command Improvements:
websiteas an alias for thewebsitescommand.showDNSRecordInstructionsandbuildRequiredRecordshelpers for consistent DNS record display acrosscreate,validate, and the wizard.websites validateto show required DNS records on validation failure and includerequired_recordsin JSON output.