Allow changing of php versions
This commit is contained in:
parent
e207496229
commit
8f8d448836
3 changed files with 35 additions and 7 deletions
|
|
@ -15,7 +15,8 @@ import (
|
||||||
var Rebuild wisski_distillery.Command = rebuild{}
|
var Rebuild wisski_distillery.Command = rebuild{}
|
||||||
|
|
||||||
type rebuild struct {
|
type rebuild struct {
|
||||||
Parallel int `short:"p" long:"parallel" description:"run on (at most) this many instances in parallel. 0 for no limit." default:"1"`
|
Parallel int `short:"p" long:"parallel" description:"run on (at most) this many instances in parallel. 0 for no limit." default:"1"`
|
||||||
|
PHPVersion string `short:"u" long:"php" description:"update to specific php version to use for instance. Should be one of '8.0', '8.1'."`
|
||||||
Positionals struct {
|
Positionals struct {
|
||||||
Slug []string `positional-arg-name:"SLUG" required:"0" description:"slug of instance or instances to run rebuild"`
|
Slug []string `positional-arg-name:"SLUG" required:"0" description:"slug of instance or instances to run rebuild"`
|
||||||
} `positional-args:"true"`
|
} `positional-args:"true"`
|
||||||
|
|
@ -49,6 +50,12 @@ func (rb rebuild) Run(context wisski_distillery.Context) (err error) {
|
||||||
|
|
||||||
// and do the actual rebuild
|
// and do the actual rebuild
|
||||||
return status.WriterGroup(context.Stderr, rb.Parallel, func(instance *wisski.WissKI, writer io.Writer) error {
|
return status.WriterGroup(context.Stderr, rb.Parallel, func(instance *wisski.WissKI, writer io.Writer) error {
|
||||||
|
if rb.PHPVersion != "" {
|
||||||
|
if err := instance.Provisioner().ApplyFlags(context.Context, writer, rb.PHPVersion); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return instance.Barrel().Build(context.Context, writer, true)
|
return instance.Barrel().Build(context.Context, writer, true)
|
||||||
}, wissKIs, status.SmartMessage(func(item *wisski.WissKI) string {
|
}, wissKIs, status.SmartMessage(func(item *wisski.WissKI) string {
|
||||||
return fmt.Sprintf("rebuild %q", item.Slug)
|
return fmt.Sprintf("rebuild %q", item.Slug)
|
||||||
|
|
|
||||||
|
|
@ -48,11 +48,13 @@ type Instance struct {
|
||||||
GraphDBPassword string `gorm:"column:graphdb_password;not null"`
|
GraphDBPassword string `gorm:"column:graphdb_password;not null"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Cleanup this stuff
|
||||||
const (
|
const (
|
||||||
PHP8 = "8.0"
|
PHP_DEFAULT_IMAGE = PHP8_1
|
||||||
PHP8_IMAGE = "docker.io/library/php:8.0-apache-bullseye"
|
PHP8 = "8.0"
|
||||||
PHP8_1 = "8.1"
|
PHP8_IMAGE = "docker.io/library/php:8.0-apache-bullseye"
|
||||||
PHP8_1_IMAGE = "docker.io/library/php:8.1-apache-bullseye"
|
PHP8_1 = "8.1"
|
||||||
|
PHP8_1_IMAGE = "docker.io/library/php:8.1-apache-bullseye"
|
||||||
)
|
)
|
||||||
|
|
||||||
var errUnknownPHPVersion = errors.New("unknown php version")
|
var errUnknownPHPVersion = errors.New("unknown php version")
|
||||||
|
|
@ -61,7 +63,7 @@ var errUnknownPHPVersion = errors.New("unknown php version")
|
||||||
func GetBaseImage(php string) (string, error) {
|
func GetBaseImage(php string) (string, error) {
|
||||||
switch php {
|
switch php {
|
||||||
case "":
|
case "":
|
||||||
return PHP8_IMAGE, nil
|
return PHP_DEFAULT_IMAGE, nil
|
||||||
case PHP8:
|
case PHP8:
|
||||||
return PHP8_IMAGE, nil
|
return PHP8_IMAGE, nil
|
||||||
case PHP8_1:
|
case PHP8_1:
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,10 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/FAU-CDI/wisski-distillery/internal/models"
|
||||||
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient"
|
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient"
|
||||||
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient/barrel"
|
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient/barrel"
|
||||||
|
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient/bookkeeping"
|
||||||
"github.com/alessio/shellescape"
|
"github.com/alessio/shellescape"
|
||||||
"github.com/tkw1536/pkglib/stream"
|
"github.com/tkw1536/pkglib/stream"
|
||||||
)
|
)
|
||||||
|
|
@ -18,10 +20,27 @@ import (
|
||||||
type Provisioner struct {
|
type Provisioner struct {
|
||||||
ingredient.Base
|
ingredient.Base
|
||||||
Dependencies struct {
|
Dependencies struct {
|
||||||
Barrel *barrel.Barrel
|
Barrel *barrel.Barrel
|
||||||
|
Bookkeeping *bookkeeping.Bookkeeping
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ApplyFlags applies flags to an already provisioned instance.
|
||||||
|
func (provision *Provisioner) ApplyFlags(ctx context.Context, progress io.Writer, phpversion string) (err error) {
|
||||||
|
// setup the new docker image
|
||||||
|
provision.Instance.DockerBaseImage, err = models.GetBaseImage(phpversion)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// save in bookkeeping
|
||||||
|
if err := provision.Dependencies.Bookkeeping.Save(ctx); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return provision.Dependencies.Barrel.Build(ctx, progress, true)
|
||||||
|
}
|
||||||
|
|
||||||
// Provision provisions an instance, assuming that the required databases already exist.
|
// Provision provisions an instance, assuming that the required databases already exist.
|
||||||
func (provision *Provisioner) Provision(ctx context.Context, progress io.Writer) error {
|
func (provision *Provisioner) Provision(ctx context.Context, progress io.Writer) error {
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue