Add support for php 8.1
This commit adds optional support for basing images on php 8.1 as opposed to php 8.0.
This commit is contained in:
parent
3ef9c23a0c
commit
d114c8fafe
12 changed files with 91 additions and 9 deletions
|
|
@ -14,11 +14,34 @@ var (
|
|||
errRestrictedSlug = errors.New("restricted slug")
|
||||
)
|
||||
|
||||
const (
|
||||
PHP8 = "8.0"
|
||||
PHP8_IMAGE = "docker.io/library/php:8.0-apache-bullseye"
|
||||
PHP8_1 = "8.1"
|
||||
PHP8_1_IMAGE = "docker.io/library/php:8.1-apache-bullseye"
|
||||
)
|
||||
|
||||
var errUnknownPHPVersion = errors.New("unknown php version")
|
||||
|
||||
// GetBaseImage returns the php base image to use
|
||||
func GetBaseImage(php string) (string, error) {
|
||||
switch php {
|
||||
case "":
|
||||
return PHP8_IMAGE, nil
|
||||
case PHP8:
|
||||
return PHP8_IMAGE, nil
|
||||
case PHP8_1:
|
||||
return PHP8_1_IMAGE, nil
|
||||
default:
|
||||
return "", errUnknownPHPVersion
|
||||
}
|
||||
}
|
||||
|
||||
// Create fills the struct for a new WissKI instance.
|
||||
// It validates that slug is a valid name for an instance.
|
||||
//
|
||||
// It does not perform any checks if the instance already exists, or does the creation in the database.
|
||||
func (instances *Instances) Create(slug string) (wissKI *wisski.WissKI, err error) {
|
||||
func (instances *Instances) Create(slug string, phpversion string) (wissKI *wisski.WissKI, err error) {
|
||||
|
||||
// make sure that the slug is valid!
|
||||
slug, err = instances.IsValidSlug(slug)
|
||||
|
|
@ -64,6 +87,12 @@ func (instances *Instances) Create(slug string) (wissKI *wisski.WissKI, err erro
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// docker image
|
||||
wissKI.Liquid.Instance.DockerBaseImage, err = GetBaseImage(phpversion)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// store the instance in the object and return it!
|
||||
return wissKI, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ func (purger *Purger) Purge(ctx context.Context, out io.Writer, slug string) err
|
|||
instance, err := purger.Dependencies.Instances.WissKI(ctx, slug)
|
||||
if err == instances.ErrWissKINotFound {
|
||||
fmt.Fprintln(out, "Not found in bookkeeping table, assuming defaults")
|
||||
instance, err = purger.Dependencies.Instances.Create(slug)
|
||||
instance, err = purger.Dependencies.Instances.Create(slug, "")
|
||||
}
|
||||
if err != nil {
|
||||
return errPurgeNoDetails.WithMessageF(err)
|
||||
|
|
|
|||
|
|
@ -22,11 +22,27 @@ type Provision struct {
|
|||
|
||||
// ProvisionFlags are flags for a new instance
|
||||
type ProvisionFlags struct {
|
||||
// Slug is the slug of the wisski instance
|
||||
Slug string
|
||||
|
||||
// PHP Version to use
|
||||
PHPVersion string
|
||||
}
|
||||
|
||||
var ErrInstanceAlreadyExists = errors.New("instance with provided slug already exists")
|
||||
|
||||
func (pv *Provision) ValidateFlags(flags ProvisionFlags) error {
|
||||
// check the slug
|
||||
if _, err := pv.Dependencies.Instances.IsValidSlug(flags.Slug); err != nil {
|
||||
return err
|
||||
}
|
||||
// check for known php versions
|
||||
if _, err := instances.GetBaseImage(flags.PHPVersion); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Provision provisions a new docker compose instance.
|
||||
func (pv *Provision) Provision(progress io.Writer, ctx context.Context, flags ProvisionFlags) (*wisski.WissKI, error) {
|
||||
// check that it doesn't already exist
|
||||
|
|
@ -36,7 +52,7 @@ func (pv *Provision) Provision(progress io.Writer, ctx context.Context, flags Pr
|
|||
}
|
||||
|
||||
// make it in-memory
|
||||
instance, err := pv.Dependencies.Instances.Create(flags.Slug)
|
||||
instance, err := pv.Dependencies.Instances.Create(flags.Slug, flags.PHPVersion)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,18 @@
|
|||
<a href="{{ .Info.URL }}" target="_blank" rel="noopener noreferrer">{{ .Info.URL }}</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
Docker Base Image
|
||||
</td>
|
||||
<td>
|
||||
{{ if .Instance.DockerBaseImage }}
|
||||
<code>{{ .Instance.DockerBaseImage }}</code>
|
||||
{{ else }}
|
||||
(none)
|
||||
{{ end }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
Running
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue