Use fsx package and friends from pkglib
This commit is contained in:
parent
1f8c55da7c
commit
0f6803f890
35 changed files with 91 additions and 493 deletions
|
|
@ -10,9 +10,10 @@ import (
|
|||
"github.com/FAU-CDI/wisski-distillery/internal/cli"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/config"
|
||||
|
||||
"github.com/FAU-CDI/wisski-distillery/pkg/fsx"
|
||||
"github.com/FAU-CDI/wisski-distillery/pkg/logging"
|
||||
"github.com/tkw1536/goprogram/exit"
|
||||
"github.com/tkw1536/pkglib/fsx"
|
||||
"github.com/tkw1536/pkglib/fsx/umaskfree"
|
||||
)
|
||||
|
||||
// Bootstrap is the 'bootstrap' command
|
||||
|
|
@ -81,7 +82,7 @@ func (bs cBootstrap) Run(context wisski_distillery.Context) error {
|
|||
|
||||
{
|
||||
logging.LogMessage(context.Stderr, "Creating root deployment directory")
|
||||
if err := fsx.MkdirAll(root, fsx.DefaultDirPerm); err != nil {
|
||||
if err := umaskfree.MkdirAll(root, umaskfree.DefaultDirPerm); err != nil {
|
||||
return errBootstrapFailedToCreateDirectory.WithMessageF(root).Wrap(err)
|
||||
}
|
||||
if err := cli.WriteBaseDirectory(root); err != nil {
|
||||
|
|
@ -111,22 +112,22 @@ func (bs cBootstrap) Run(context wisski_distillery.Context) error {
|
|||
return errBoostrapFailedToCopyExe.WithMessageF(err)
|
||||
}
|
||||
|
||||
err = fsx.CopyFile(context.Context, wdcliPath, exe)
|
||||
if err != nil && err != fsx.ErrCopySameFile {
|
||||
err = umaskfree.CopyFile(context.Context, wdcliPath, exe)
|
||||
if err != nil && err != umaskfree.ErrCopySameFile {
|
||||
return errBoostrapFailedToCopyExe.WithMessageF(err)
|
||||
}
|
||||
context.Println(wdcliPath)
|
||||
}
|
||||
|
||||
{
|
||||
if !fsx.IsFile(cfgPath) {
|
||||
if !fsx.IsRegular(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 := fsx.WriteFile(
|
||||
if err := umaskfree.WriteFile(
|
||||
cfg.Paths.OverridesJSON,
|
||||
bootstrap.DefaultOverridesJSON,
|
||||
fs.ModePerm,
|
||||
|
|
@ -135,7 +136,7 @@ func (bs cBootstrap) Run(context wisski_distillery.Context) error {
|
|||
}
|
||||
|
||||
context.Println(cfg.Paths.ResolverBlocks)
|
||||
if err := fsx.WriteFile(
|
||||
if err := umaskfree.WriteFile(
|
||||
cfg.Paths.ResolverBlocks,
|
||||
bootstrap.DefaultResolverBlockedTXT,
|
||||
fs.ModePerm,
|
||||
|
|
@ -155,7 +156,7 @@ func (bs cBootstrap) Run(context wisski_distillery.Context) error {
|
|||
|
||||
// and marshal it out!
|
||||
if err := logging.LogOperation(func() error {
|
||||
configYML, err := fsx.Create(cfgPath, fsx.DefaultFilePerm)
|
||||
configYML, err := umaskfree.Create(cfgPath, umaskfree.DefaultFilePerm)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ 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/fsx"
|
||||
"github.com/FAU-CDI/wisski-distillery/pkg/logging"
|
||||
"github.com/tkw1536/pkglib/fsx"
|
||||
)
|
||||
|
||||
// Monday is the 'monday' command
|
||||
|
|
@ -28,7 +28,7 @@ func (monday) Description() wisski_distillery.Description {
|
|||
}
|
||||
|
||||
func (monday monday) AfterParse() error {
|
||||
if !fsx.IsFile(monday.Positionals.GraphdbZip) {
|
||||
if !fsx.IsRegular(monday.Positionals.GraphdbZip) {
|
||||
return errNoGraphDBZip.WithMessageF(monday.Positionals.GraphdbZip)
|
||||
}
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ 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/fsx"
|
||||
"github.com/FAU-CDI/wisski-distillery/pkg/logging"
|
||||
"github.com/tkw1536/goprogram/exit"
|
||||
"github.com/tkw1536/pkglib/fsx"
|
||||
)
|
||||
|
||||
// Reserve is the 'reserve' command
|
||||
|
|
|
|||
|
|
@ -9,10 +9,11 @@ import (
|
|||
"github.com/FAU-CDI/wisski-distillery/internal/cli"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/dis/component"
|
||||
"github.com/FAU-CDI/wisski-distillery/pkg/execx"
|
||||
"github.com/FAU-CDI/wisski-distillery/pkg/fsx"
|
||||
"github.com/FAU-CDI/wisski-distillery/pkg/logging"
|
||||
"github.com/tkw1536/goprogram/exit"
|
||||
"github.com/tkw1536/goprogram/parser"
|
||||
"github.com/tkw1536/pkglib/fsx"
|
||||
"github.com/tkw1536/pkglib/fsx/umaskfree"
|
||||
"github.com/tkw1536/pkglib/status"
|
||||
)
|
||||
|
||||
|
|
@ -46,7 +47,7 @@ var errNoGraphDBZip = exit.Error{
|
|||
|
||||
func (s systemupdate) AfterParse() error {
|
||||
// TODO: Use a generic environment here!
|
||||
if !fsx.IsFile(s.Positionals.GraphdbZip) {
|
||||
if !fsx.IsRegular(s.Positionals.GraphdbZip) {
|
||||
return errNoGraphDBZip.WithMessageF(s.Positionals.GraphdbZip)
|
||||
}
|
||||
return nil
|
||||
|
|
@ -92,7 +93,7 @@ func (si systemupdate) Run(context wisski_distillery.Context) (err error) {
|
|||
dis.Templating().CustomAssetsPath(),
|
||||
} {
|
||||
context.Println(d)
|
||||
if err := fsx.MkdirAll(d, fsx.DefaultDirPerm); err != nil {
|
||||
if err := umaskfree.MkdirAll(d, umaskfree.DefaultDirPerm); err != nil {
|
||||
return errBoostrapFailedToCreateDirectory.WithMessageF(d).Wrap(err)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue