fsx: Remove environment references

This commit removes the reference to the environment from the fsx
package.
This commit is contained in:
Tom Wiesing 2023-03-02 11:47:11 +01:00
parent 5a43ecfaeb
commit 3263920d6b
No known key found for this signature in database
25 changed files with 167 additions and 183 deletions

View file

@ -72,7 +72,7 @@ var errBootstrapCreateFile = exit.Error{
func (bs cBootstrap) Run(context wisski_distillery.Context) error {
// installation environment is the native environment!
// TODO: Should this be configurable?
env := new(environment.Native)
var env environment.Environment
root := bs.Directory
@ -86,7 +86,7 @@ func (bs cBootstrap) Run(context wisski_distillery.Context) error {
{
logging.LogMessage(context.Stderr, context.Context, "Creating root deployment directory")
if err := env.MkdirAll(root, environment.DefaultDirPerm); err != nil {
if err := fsx.MkdirAll(root, fsx.DefaultDirPerm); err != nil {
return errBootstrapFailedToCreateDirectory.WithMessageF(root)
}
if err := cli.WriteBaseDirectory(env, root); err != nil {
@ -116,7 +116,7 @@ func (bs cBootstrap) Run(context wisski_distillery.Context) error {
return errBoostrapFailedToCopyExe.WithMessageF(err)
}
err = fsx.CopyFile(context.Context, env, wdcliPath, exe)
err = fsx.CopyFile(context.Context, wdcliPath, exe)
if err != nil && err != fsx.ErrCopySameFile {
return errBoostrapFailedToCopyExe.WithMessageF(err)
}
@ -124,15 +124,14 @@ func (bs cBootstrap) Run(context wisski_distillery.Context) error {
}
{
if !fsx.IsFile(env, cfgPath) {
if !fsx.IsFile(cfgPath) {
// generate the configuration from the template
cfg := tpl.Generate()
// write out all the extra config files
if err := logging.LogOperation(func() error {
context.Println(cfg.Paths.OverridesJSON)
if err := environment.WriteFile(
env,
if err := fsx.WriteFile(
cfg.Paths.OverridesJSON,
bootstrap.DefaultOverridesJSON,
fs.ModePerm,
@ -141,8 +140,7 @@ func (bs cBootstrap) Run(context wisski_distillery.Context) error {
}
context.Println(cfg.Paths.ResolverBlocks)
if err := environment.WriteFile(
env,
if err := fsx.WriteFile(
cfg.Paths.ResolverBlocks,
bootstrap.DefaultResolverBlockedTXT,
fs.ModePerm,
@ -162,7 +160,7 @@ func (bs cBootstrap) Run(context wisski_distillery.Context) error {
// and marshal it out!
if err := logging.LogOperation(func() error {
configYML, err := env.Create(cfgPath, environment.DefaultFilePerm)
configYML, err := fsx.Create(cfgPath, fsx.DefaultFilePerm)
if err != nil {
return err
}

View file

@ -32,7 +32,7 @@ func (cfgMigrate) Description() wisski_distillery.Description {
func (c cfgMigrate) Run(context wisski_distillery.Context) error {
// migration environment is the native environment!
env := new(environment.Native)
var env environment.Environment
// open the legacy file
file, err := os.Open(c.Positionals.Input)

View file

@ -3,7 +3,6 @@ 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/pkg/environment"
"github.com/FAU-CDI/wisski-distillery/pkg/fsx"
"github.com/FAU-CDI/wisski-distillery/pkg/logging"
)
@ -29,8 +28,7 @@ func (monday) Description() wisski_distillery.Description {
}
func (monday monday) AfterParse() error {
// TODO: Use a generic environment here!
if !fsx.IsFile(new(environment.Native), monday.Positionals.GraphdbZip) {
if !fsx.IsFile(monday.Positionals.GraphdbZip) {
return errNoGraphDBZip.WithMessageF(monday.Positionals.GraphdbZip)
}
return nil

View file

@ -58,7 +58,7 @@ func (r reserve) Run(context wisski_distillery.Context) error {
// check that the base directory does not exist
logging.LogMessage(context.Stderr, context.Context, "Checking that base directory %s does not exist", instance.FilesystemBase)
if fsx.IsDirectory(dis.Environment, instance.FilesystemBase) {
if fsx.IsDirectory(instance.FilesystemBase) {
return errReserveAlreadyExists.WithMessageF(slug)
}

View file

@ -8,7 +8,6 @@ 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"
"github.com/FAU-CDI/wisski-distillery/pkg/environment"
"github.com/FAU-CDI/wisski-distillery/pkg/execx"
"github.com/FAU-CDI/wisski-distillery/pkg/fsx"
"github.com/FAU-CDI/wisski-distillery/pkg/logging"
@ -47,7 +46,7 @@ var errNoGraphDBZip = exit.Error{
func (s systemupdate) AfterParse() error {
// TODO: Use a generic environment here!
if !fsx.IsFile(new(environment.Native), s.Positionals.GraphdbZip) {
if !fsx.IsFile(s.Positionals.GraphdbZip) {
return errNoGraphDBZip.WithMessageF(s.Positionals.GraphdbZip)
}
return nil
@ -76,7 +75,7 @@ func (si systemupdate) Run(context wisski_distillery.Context) error {
dis.Templating().CustomAssetsPath(),
} {
context.Println(d)
if err := dis.Still.Environment.MkdirAll(d, environment.DefaultDirPerm); err != nil {
if err := fsx.MkdirAll(d, fsx.DefaultDirPerm); err != nil {
return errBoostrapFailedToCreateDirectory.WithMessageF(d, err)
}
}