feat(setup): build start and verify ThothII

This commit is contained in:
2026-08-15 23:09:10 +02:00
parent 2856964654
commit 47e0b2a385
7 changed files with 719 additions and 31 deletions
+18 -26
View File
@@ -91,7 +91,7 @@ func run(ctx context.Context, args []string, stdout, stderr io.Writer) int {
return 0
}
if command == "setup" {
return setupCommand(installationPath, commandArgs, stdout, stderr)
return setupCommand(ctx, installationPath, commandArgs, stdout, stderr)
}
return commandUsageError(stderr, fmt.Sprintf("unknown command %q", command))
}
@@ -205,7 +205,21 @@ func isBootstrapCommand(command string) bool {
return command == "help" || command == "setup" || command == "version"
}
func setupCommand(installationPath string, args []string, stdout, stderr io.Writer) int {
type setupExecutor func(context.Context, compose.Runner, setup.Request, io.Reader, io.Writer) (setup.Result, error)
func setupCommand(ctx context.Context, installationPath string, args []string, stdout, stderr io.Writer) int {
return setupCommandWith(ctx, installationPath, args, os.Stdin, compose.NewRunner(""), setup.Run, stdout, stderr)
}
func setupCommandWith(
ctx context.Context,
installationPath string,
args []string,
input io.Reader,
runner compose.Runner,
execute setupExecutor,
stdout, stderr io.Writer,
) int {
request, err := parseSetupArgs(args)
if err != nil {
return commandUsageError(stderr, err.Error())
@@ -229,11 +243,10 @@ func setupCommand(installationPath string, args []string, stdout, stderr io.Writ
}
request.InstallationID = id
}
result, err := setup.EnsureFiles(request, os.Stdin, stdout)
_, err = execute(ctx, runner, request, input, stdout)
if err != nil {
return commandUsageError(stderr, err.Error())
}
fmt.Fprintf(stdout, "Configuration is ready: %s\n", result.DescriptorPath)
return 0
}
@@ -386,32 +399,11 @@ func serverOperationFailure(stderr io.Writer, err error, secretValues []string)
return 1
}
// installationRunner transforms only Compose invocations into the installation's validated,
// profile-specific argument list. Direct Docker image commands remain host-side and use arguments.
type installationRunner struct {
installation config.Installation
runner compose.Runner
}
func (r installationRunner) SessionInventoryScope() string {
if r.installation.Profile == "local" {
return "mine"
}
return "all"
}
func (r installationRunner) Run(ctx context.Context, args []string, stdin io.Reader) (compose.Result, error) {
if len(args) > 0 && args[0] == "compose" {
return r.runner.Run(ctx, r.installation.ComposeArgs(args[1:]...), stdin)
}
return r.runner.Run(ctx, args, stdin)
}
func piCommand(ctx context.Context, installation config.Installation, runner compose.Runner, args []string, secretValues []string, stdout, stderr io.Writer) int {
if len(args) == 0 {
return commandUsageError(stderr, "pi requires a subcommand")
}
controlled := installationRunner{installation: installation, runner: runner}
controlled := compose.InstallationRunner{Installation: installation, Runner: runner}
switch args[0] {
case "status":
if len(args) != 1 {