wisski-cloud-distillery/cmd/provision.go
Tom Wiesing d114c8fafe Add support for php 8.1
This commit adds optional support for basing images on php 8.1 as
opposed to php 8.0.
2023-06-29 14:52:12 +02:00

54 lines
1.7 KiB
Go

package cmd
import (
wisski_distillery "github.com/FAU-CDI/wisski-distillery"
"github.com/FAU-CDI/wisski-distillery/internal/cli"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/provision"
"github.com/FAU-CDI/wisski-distillery/pkg/logging"
"github.com/tkw1536/goprogram/exit"
)
// Provision is the 'provision' command
var Provision wisski_distillery.Command = pv{}
type pv struct {
PHPVersion string `short:"p" long:"php" description:"specific php version to use for instance. Should be one of '8.0', '8.1'."`
Positionals struct {
Slug string `positional-arg-name:"slug" required:"1-1" description:"slug of instance to create"`
} `positional-args:"true"`
}
func (pv) Description() wisski_distillery.Description {
return wisski_distillery.Description{
Requirements: cli.Requirements{
NeedsDistillery: true,
},
Command: "provision",
Description: "creates a new instance",
}
}
var errProvisionGeneric = exit.Error{
Message: "unable to provision instance %s",
ExitCode: exit.ExitGeneric,
}
// TODO: AfterParse to check instance!
func (p pv) Run(context wisski_distillery.Context) error {
instance, err := context.Environment.Provision().Provision(context.Stderr, context.Context, provision.ProvisionFlags{
Slug: p.Positionals.Slug,
PHPVersion: p.PHPVersion,
})
if err != nil {
return errProvisionGeneric.WithMessageF(p.Positionals.Slug).Wrap(err)
}
// and we're done!
logging.LogMessage(context.Stderr, "Instance has been provisioned")
context.Printf("URL: %s\n", instance.URL().String())
context.Printf("Username: %s\n", instance.DrupalUsername)
context.Printf("Password: %s\n", instance.DrupalPassword)
return nil
}