rebuild: Add explicit flag for updating
This commit is contained in:
parent
df386e9f65
commit
63c5db734d
1 changed files with 26 additions and 5 deletions
|
|
@ -18,6 +18,7 @@ var Rebuild wisski_distillery.Command = rebuild{}
|
|||
type rebuild struct {
|
||||
Parallel int `short:"a" long:"parallel" description:"run on (at most) this many instances in parallel. 0 for no limit." default:"1"`
|
||||
|
||||
System bool `short:"s" long:"system-update" description:"Update the system configuration according to other flags"`
|
||||
PHPVersion string `short:"p" long:"php" description:"update to specific php version to use for instance. Should be one of '8.0', '8.1'."`
|
||||
OPCacheDevelopment bool `short:"o" long:"opcache-devel" description:"Include opcache development configuration"`
|
||||
ContentSecurityPolicy string `short:"c" long:"content-security-policy" description:"Setup ContentSecurityPolicy"`
|
||||
|
|
@ -27,6 +28,21 @@ type rebuild struct {
|
|||
} `positional-args:"true"`
|
||||
}
|
||||
|
||||
var errRebuildNoSystem = exit.Error{
|
||||
Message: "flags for system reconfiguration have been set, but `--system' was not provided",
|
||||
ExitCode: exit.ExitCommandArguments,
|
||||
}
|
||||
|
||||
func (rb rebuild) AfterParse() error {
|
||||
if rb.System {
|
||||
return nil
|
||||
}
|
||||
if rb.PHPVersion != "" || rb.OPCacheDevelopment || rb.ContentSecurityPolicy != "" {
|
||||
return errRebuildNoSystem
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (rebuild) Description() wisski_distillery.Description {
|
||||
return wisski_distillery.Description{
|
||||
Requirements: cli.Requirements{
|
||||
|
|
@ -55,11 +71,16 @@ func (rb rebuild) Run(context wisski_distillery.Context) (err error) {
|
|||
|
||||
// and do the actual rebuild
|
||||
return status.WriterGroup(context.Stderr, rb.Parallel, func(instance *wisski.WissKI, writer io.Writer) error {
|
||||
return instance.SystemManager().Apply(context.Context, writer, models.System{
|
||||
PHP: rb.PHPVersion,
|
||||
OpCacheDevelopment: rb.OPCacheDevelopment,
|
||||
ContentSecurityPolicy: rb.ContentSecurityPolicy,
|
||||
}, true)
|
||||
sys := instance.System
|
||||
if rb.System {
|
||||
sys = models.System{
|
||||
PHP: rb.PHPVersion,
|
||||
OpCacheDevelopment: rb.OPCacheDevelopment,
|
||||
ContentSecurityPolicy: rb.ContentSecurityPolicy,
|
||||
}
|
||||
}
|
||||
|
||||
return instance.SystemManager().Apply(context.Context, writer, sys, true)
|
||||
}, wissKIs, status.SmartMessage(func(item *wisski.WissKI) string {
|
||||
return fmt.Sprintf("rebuild %q", item.Slug)
|
||||
}))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue