Remove embed package

This commit finally removes the embed package in favor of more specific
resource packages
This commit is contained in:
Tom Wiesing 2022-09-11 17:00:34 +02:00
parent 91a088a56a
commit 86a4334796
No known key found for this signature in database
51 changed files with 220 additions and 191 deletions

View file

@ -45,7 +45,7 @@ func (bu blindUpdate) Run(context wisski_distillery.Context) error {
}
context.EPrintf("Updating instance %s\n", instance.Slug)
code, err := instance.Shell(context.IOStream, "/utils/blind_update.sh")
code, err := instance.Shell(context.IOStream, "/runtime/blind_update.sh")
if err != nil {
return errBlindUpdateFailed.WithMessageF(instance.Slug, execx.ExecCommandError)
}

View file

@ -1,13 +1,13 @@
package cmd
import (
"bytes"
"io/fs"
"os"
"path/filepath"
wisski_distillery "github.com/FAU-CDI/wisski-distillery"
"github.com/FAU-CDI/wisski-distillery/core"
"github.com/FAU-CDI/wisski-distillery/embed"
cfg "github.com/FAU-CDI/wisski-distillery/internal/config"
"github.com/FAU-CDI/wisski-distillery/internal/fsx"
"github.com/FAU-CDI/wisski-distillery/internal/hostname"
@ -124,8 +124,12 @@ func (bs bootstrap) Run(context wisski_distillery.Context) error {
return errBootstrapWriteConfig.WithMessageF(err)
}
if err := unpack.InstallTemplate(
envPath,
env, err := os.Create(envPath)
if err != nil {
return errBootstrapWriteConfig.WithMessageF(err)
}
if err := unpack.WriteTemplate(
env,
map[string]string{
"DEPLOY_ROOT": root,
"DEFAULT_DOMAIN": domain,
@ -138,8 +142,7 @@ func (bs bootstrap) Run(context wisski_distillery.Context) error {
"MYSQL_ADMIN_USER": "admin",
"MYSQL_ADMIN_PASSWORD": password[64:],
},
filepath.Join("resources", "templates", "bootstrap", "env"),
embed.ResourceEmbed,
bytes.NewReader(core.ConfigFileTemplate),
); err != nil {
return errBootstrapWriteConfig.WithMessageF(err)
}
@ -152,17 +155,19 @@ func (bs bootstrap) Run(context wisski_distillery.Context) error {
if err := logging.LogOperation(func() error {
context.Println(overridesPath)
if err := unpack.InstallFile(
if err := os.WriteFile(
overridesPath,
fsx.OpenFS(filepath.Join("resources", "templates", "bootstrap", "overrides.json"), embed.ResourceEmbed),
core.DefaultOverridesJSON,
fs.ModePerm,
); err != nil {
return errBootstrapCreateFile.WithMessageF(err)
}
context.Println(authorizedKeysFile)
if err := unpack.InstallFile(
if err := os.WriteFile(
authorizedKeysFile,
fsx.OpenFS(filepath.Join("resources", "templates", "bootstrap", "global_authorized_keys"), embed.ResourceEmbed),
core.DefaultAuthorizedKeys,
fs.ModePerm,
); err != nil {
return errBootstrapCreateFile.WithMessageF(err)
}

View file

@ -40,7 +40,7 @@ func (cr cron) Run(context wisski_distillery.Context) error {
// iterate over the instances and store the last value of error
for _, instance := range instances {
logging.LogOperation(func() error {
code, err := instance.Shell(context.IOStream, "/utils/cron.sh")
code, err := instance.Shell(context.IOStream, "/runtime/cron.sh")
if err != nil {
context.EPrintln(err)
}

View file

@ -2,12 +2,10 @@ package cmd
import (
"os"
"path/filepath"
wisski_distillery "github.com/FAU-CDI/wisski-distillery"
"github.com/FAU-CDI/wisski-distillery/component"
"github.com/FAU-CDI/wisski-distillery/core"
"github.com/FAU-CDI/wisski-distillery/embed"
"github.com/FAU-CDI/wisski-distillery/internal/execx"
"github.com/FAU-CDI/wisski-distillery/internal/logging"
"github.com/FAU-CDI/wisski-distillery/internal/unpack"
@ -144,7 +142,7 @@ func (si systemupdate) Run(context wisski_distillery.Context) error {
}
if err := logging.LogOperation(func() error {
return unpack.InstallResource(dis.RuntimeDir(), filepath.Join("resources", "runtime"), embed.ResourceEmbed, func(dst, src string) {
return unpack.InstallResource(dis.RuntimeDir(), "runtime", core.Runtime, func(dst, src string) {
context.Printf("[copy] %s\n", dst)
})
}, context.IOStream, "Unpacking Runtime Components"); err != nil {