Move internal/core => internal/cli

This commit is contained in:
Tom Wiesing 2022-10-17 16:45:43 +02:00
parent 8d2855fdcb
commit 10df1c3243
No known key found for this signature in database
45 changed files with 113 additions and 143 deletions

View file

@ -2,8 +2,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/internal/component/exporter"
"github.com/FAU-CDI/wisski-distillery/internal/core"
"github.com/FAU-CDI/wisski-distillery/pkg/logging"
"github.com/tkw1536/goprogram/exit"
)
@ -22,7 +22,7 @@ type backup struct {
func (backup) Description() wisski_distillery.Description {
return wisski_distillery.Description{
Requirements: core.Requirements{
Requirements: cli.Requirements{
NeedsDistillery: true,
},
Command: "backup",

View file

@ -4,7 +4,7 @@ import (
"fmt"
wisski_distillery "github.com/FAU-CDI/wisski-distillery"
"github.com/FAU-CDI/wisski-distillery/internal/core"
"github.com/FAU-CDI/wisski-distillery/internal/cli"
"github.com/FAU-CDI/wisski-distillery/internal/wisski"
"github.com/tkw1536/goprogram/exit"
"github.com/tkw1536/goprogram/lib/collection"
@ -25,7 +25,7 @@ type blindUpdate struct {
func (blindUpdate) Description() wisski_distillery.Description {
return wisski_distillery.Description{
Requirements: core.Requirements{
Requirements: cli.Requirements{
NeedsDistillery: true,
},
Command: "blind_update",

View file

@ -5,8 +5,10 @@ import (
"path/filepath"
wisski_distillery "github.com/FAU-CDI/wisski-distillery"
"github.com/FAU-CDI/wisski-distillery/internal/bootstrap"
"github.com/FAU-CDI/wisski-distillery/internal/cli"
"github.com/FAU-CDI/wisski-distillery/internal/config"
"github.com/FAU-CDI/wisski-distillery/internal/core"
"github.com/FAU-CDI/wisski-distillery/pkg/environment"
"github.com/FAU-CDI/wisski-distillery/pkg/fsx"
"github.com/FAU-CDI/wisski-distillery/pkg/logging"
@ -14,16 +16,16 @@ import (
)
// Bootstrap is the 'bootstrap' command
var Bootstrap wisski_distillery.Command = bootstrap{}
var Bootstrap wisski_distillery.Command = cBootstrap{}
type bootstrap struct {
type cBootstrap struct {
Directory string `short:"r" long:"root-directory" description:"path to the root deployment directory" default:"/var/www/deploy"`
Hostname string `short:"h" long:"hostname" description:"default hostname of the distillery (default: system hostname)"`
}
func (bootstrap) Description() wisski_distillery.Description {
func (cBootstrap) Description() wisski_distillery.Description {
return wisski_distillery.Description{
Requirements: core.Requirements{
Requirements: cli.Requirements{
NeedsDistillery: false,
},
Command: "bootstrap",
@ -66,7 +68,7 @@ var errBootstrapCreateFile = exit.Error{
ExitCode: exit.ExitGeneric,
}
func (bs bootstrap) Run(context wisski_distillery.Context) error {
func (bs cBootstrap) Run(context wisski_distillery.Context) error {
// installation environment is the native environment!
// TODO: Should this be configurable?
var env environment.Native
@ -75,7 +77,7 @@ func (bs bootstrap) Run(context wisski_distillery.Context) error {
// check that we didn't get a different base directory
{
got, err := core.ReadBaseDirectory(env)
got, err := cli.ReadBaseDirectory(env)
if err == nil && got != "" && got != root {
return errBootstrapDifferent.WithMessageF(got)
}
@ -86,15 +88,15 @@ func (bs bootstrap) Run(context wisski_distillery.Context) error {
if err := env.MkdirAll(root, environment.DefaultDirPerm); err != nil {
return errBootstrapFailedToCreateDirectory.WithMessageF(root)
}
if err := core.WriteBaseDirectory(env, root); err != nil {
if err := cli.WriteBaseDirectory(env, root); err != nil {
return errBootstrapFailedToSaveDirectory.WithMessageF(root)
}
context.Println(root)
}
// TODO: Should we read an existing configuration file?
wdcliPath := filepath.Join(root, core.Executable)
envPath := filepath.Join(root, core.ConfigFile)
wdcliPath := filepath.Join(root, bootstrap.Executable)
envPath := filepath.Join(root, bootstrap.ConfigFile)
// setup a new template for the configuration file!
var tpl config.Template
@ -140,7 +142,7 @@ func (bs bootstrap) Run(context wisski_distillery.Context) error {
if err := environment.WriteFile(
env,
tpl.SelfOverridesFile,
core.DefaultOverridesJSON,
bootstrap.DefaultOverridesJSON,
fs.ModePerm,
); err != nil {
return err
@ -150,7 +152,7 @@ func (bs bootstrap) Run(context wisski_distillery.Context) error {
if err := environment.WriteFile(
env,
tpl.AuthorizedKeys,
core.DefaultAuthorizedKeys,
bootstrap.DefaultAuthorizedKeys,
fs.ModePerm,
); err != nil {
return err
@ -160,7 +162,7 @@ func (bs bootstrap) Run(context wisski_distillery.Context) error {
if err := environment.WriteFile(
env,
tpl.SelfResolverBlockFile,
core.DefaultResolverBlockedTXT,
bootstrap.DefaultResolverBlockedTXT,
fs.ModePerm,
); err != nil {
return err

View file

@ -2,7 +2,7 @@ package cmd
import (
wisski_distillery "github.com/FAU-CDI/wisski-distillery"
"github.com/FAU-CDI/wisski-distillery/internal/core"
"github.com/FAU-CDI/wisski-distillery/internal/cli"
)
// Config is the configuration command
@ -12,7 +12,7 @@ type cfg struct{}
func (c cfg) Description() wisski_distillery.Description {
return wisski_distillery.Description{
Requirements: core.Requirements{
Requirements: cli.Requirements{
NeedsDistillery: true,
},
Command: "config",

View file

@ -4,7 +4,7 @@ import (
"fmt"
wisski_distillery "github.com/FAU-CDI/wisski-distillery"
"github.com/FAU-CDI/wisski-distillery/internal/core"
"github.com/FAU-CDI/wisski-distillery/internal/cli"
"github.com/FAU-CDI/wisski-distillery/internal/wisski"
"github.com/tkw1536/goprogram/status"
"github.com/tkw1536/goprogram/stream"
@ -23,7 +23,7 @@ type cron struct {
func (cron) Description() wisski_distillery.Description {
return wisski_distillery.Description{
Requirements: core.Requirements{
Requirements: cli.Requirements{
NeedsDistillery: true,
},
Command: "cron",

View file

@ -4,7 +4,7 @@ import (
"encoding/json"
wisski_distillery "github.com/FAU-CDI/wisski-distillery"
"github.com/FAU-CDI/wisski-distillery/internal/core"
"github.com/FAU-CDI/wisski-distillery/internal/cli"
"github.com/tkw1536/goprogram/exit"
)
@ -21,7 +21,7 @@ type setting struct {
func (setting) Description() wisski_distillery.Description {
return wisski_distillery.Description{
Requirements: core.Requirements{
Requirements: cli.Requirements{
NeedsDistillery: true,
},
Command: "drupal_setting",

View file

@ -4,7 +4,7 @@ import (
"encoding/json"
wisski_distillery "github.com/FAU-CDI/wisski-distillery"
"github.com/FAU-CDI/wisski-distillery/internal/core"
"github.com/FAU-CDI/wisski-distillery/internal/cli"
"github.com/tkw1536/goprogram/lib/collection"
)
@ -20,7 +20,7 @@ type info struct {
func (info) Description() wisski_distillery.Description {
return wisski_distillery.Description{
Requirements: core.Requirements{
Requirements: cli.Requirements{
NeedsDistillery: true,
},
Command: "info",

View file

@ -2,7 +2,7 @@ package cmd
import (
wisski_distillery "github.com/FAU-CDI/wisski-distillery"
"github.com/FAU-CDI/wisski-distillery/internal/core"
"github.com/FAU-CDI/wisski-distillery/internal/cli"
"github.com/tkw1536/goprogram/exit"
)
@ -19,7 +19,7 @@ type instanceLock struct {
func (instanceLock) Description() wisski_distillery.Description {
return wisski_distillery.Description{
Requirements: core.Requirements{
Requirements: cli.Requirements{
NeedsDistillery: true,
},
Command: "instance_lock",

View file

@ -2,8 +2,7 @@ package cmd
import (
wisski_distillery "github.com/FAU-CDI/wisski-distillery"
"github.com/FAU-CDI/wisski-distillery/internal/core"
"github.com/FAU-CDI/wisski-distillery/internal/legal"
"github.com/FAU-CDI/wisski-distillery/internal/cli"
)
// License is the 'wdcli license' command.
@ -15,7 +14,7 @@ type license struct{}
func (license) Description() wisski_distillery.Description {
return wisski_distillery.Description{
Requirements: core.Requirements{
Requirements: cli.Requirements{
NeedsDistillery: false,
},
Command: "license",
@ -28,7 +27,7 @@ func (license) AfterParse() error {
}
func (license) Run(context wisski_distillery.Context) error {
context.Printf(stringLicenseInfo, wisski_distillery.License, legal.Notices)
context.Printf(stringLicenseInfo, wisski_distillery.License, cli.LegalNotices)
return nil
}

View file

@ -2,7 +2,7 @@ package cmd
import (
wisski_distillery "github.com/FAU-CDI/wisski-distillery"
"github.com/FAU-CDI/wisski-distillery/internal/core"
"github.com/FAU-CDI/wisski-distillery/internal/cli"
)
// Ls is the 'ls' command
@ -16,7 +16,7 @@ type ls struct {
func (ls) Description() wisski_distillery.Description {
return wisski_distillery.Description{
Requirements: core.Requirements{
Requirements: cli.Requirements{
NeedsDistillery: true,
},
Command: "ls",

View file

@ -2,7 +2,7 @@ package cmd
import (
wisski_distillery "github.com/FAU-CDI/wisski-distillery"
"github.com/FAU-CDI/wisski-distillery/internal/core"
"github.com/FAU-CDI/wisski-distillery/internal/cli"
"github.com/tkw1536/goprogram/exit"
"github.com/tkw1536/goprogram/parser"
)
@ -14,7 +14,7 @@ type makeMysqlAccount struct{}
func (makeMysqlAccount) Description() wisski_distillery.Description {
return wisski_distillery.Description{
Requirements: core.Requirements{
Requirements: cli.Requirements{
NeedsDistillery: true,
},
ParserConfig: parser.Config{

View file

@ -2,7 +2,7 @@ package cmd
import (
wisski_distillery "github.com/FAU-CDI/wisski-distillery"
"github.com/FAU-CDI/wisski-distillery/internal/core"
"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"
@ -20,7 +20,7 @@ type monday struct {
func (monday) Description() wisski_distillery.Description {
return wisski_distillery.Description{
Requirements: core.Requirements{
Requirements: cli.Requirements{
NeedsDistillery: true,
},
Command: "monday",

View file

@ -4,7 +4,7 @@ import (
"fmt"
wisski_distillery "github.com/FAU-CDI/wisski-distillery"
"github.com/FAU-CDI/wisski-distillery/internal/core"
"github.com/FAU-CDI/wisski-distillery/internal/cli"
"github.com/tkw1536/goprogram/exit"
"github.com/tkw1536/goprogram/parser"
)
@ -20,7 +20,7 @@ type mysql struct {
func (mysql) Description() wisski_distillery.Description {
return wisski_distillery.Description{
Requirements: core.Requirements{
Requirements: cli.Requirements{
NeedsDistillery: true,
},
ParserConfig: parser.Config{

View file

@ -2,7 +2,7 @@ package cmd
import (
wisski_distillery "github.com/FAU-CDI/wisski-distillery"
"github.com/FAU-CDI/wisski-distillery/internal/core"
"github.com/FAU-CDI/wisski-distillery/internal/cli"
"github.com/tkw1536/goprogram/exit"
)
@ -18,7 +18,7 @@ type pathbuilders struct {
func (pathbuilders) Description() wisski_distillery.Description {
return wisski_distillery.Description{
Requirements: core.Requirements{
Requirements: cli.Requirements{
NeedsDistillery: true,
},
Command: "pathbuilder",

View file

@ -2,7 +2,7 @@ package cmd
import (
wisski_distillery "github.com/FAU-CDI/wisski-distillery"
"github.com/FAU-CDI/wisski-distillery/internal/core"
"github.com/FAU-CDI/wisski-distillery/internal/cli"
"github.com/tkw1536/goprogram/exit"
)
@ -17,7 +17,7 @@ type prefixes struct {
func (prefixes) Description() wisski_distillery.Description {
return wisski_distillery.Description{
Requirements: core.Requirements{
Requirements: cli.Requirements{
NeedsDistillery: true,
},
Command: "prefixes",

View file

@ -2,7 +2,7 @@ package cmd
import (
wisski_distillery "github.com/FAU-CDI/wisski-distillery"
"github.com/FAU-CDI/wisski-distillery/internal/core"
"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/goprogram/exit"
@ -19,7 +19,7 @@ type provision struct {
func (provision) Description() wisski_distillery.Description {
return wisski_distillery.Description{
Requirements: core.Requirements{
Requirements: cli.Requirements{
NeedsDistillery: true,
},
Command: "provision",

View file

@ -2,8 +2,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/internal/component/instances"
"github.com/FAU-CDI/wisski-distillery/internal/core"
"github.com/FAU-CDI/wisski-distillery/pkg/logging"
"github.com/tkw1536/goprogram/exit"
)
@ -20,7 +20,7 @@ type purge struct {
func (purge) Description() wisski_distillery.Description {
return wisski_distillery.Description{
Requirements: core.Requirements{
Requirements: cli.Requirements{
NeedsDistillery: true,
},
Command: "purge",

View file

@ -4,7 +4,7 @@ import (
"fmt"
wisski_distillery "github.com/FAU-CDI/wisski-distillery"
"github.com/FAU-CDI/wisski-distillery/internal/core"
"github.com/FAU-CDI/wisski-distillery/internal/cli"
"github.com/FAU-CDI/wisski-distillery/internal/wisski"
"github.com/tkw1536/goprogram/exit"
"github.com/tkw1536/goprogram/status"
@ -23,7 +23,7 @@ type rebuild struct {
func (rebuild) Description() wisski_distillery.Description {
return wisski_distillery.Description{
Requirements: core.Requirements{
Requirements: cli.Requirements{
NeedsDistillery: true,
},
Command: "rebuild",

View file

@ -2,8 +2,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/internal/component"
"github.com/FAU-CDI/wisski-distillery/internal/core"
"github.com/FAU-CDI/wisski-distillery/pkg/fsx"
"github.com/FAU-CDI/wisski-distillery/pkg/logging"
"github.com/tkw1536/goprogram/exit"
@ -20,7 +20,7 @@ type reserve struct {
func (reserve) Description() wisski_distillery.Description {
return wisski_distillery.Description{
Requirements: core.Requirements{
Requirements: cli.Requirements{
NeedsDistillery: true,
},
Command: "reserve",

View file

@ -4,7 +4,7 @@ import (
"net/http"
wisski_distillery "github.com/FAU-CDI/wisski-distillery"
"github.com/FAU-CDI/wisski-distillery/internal/core"
"github.com/FAU-CDI/wisski-distillery/internal/cli"
"github.com/tkw1536/goprogram/exit"
)
@ -18,7 +18,7 @@ type server struct {
func (s server) Description() wisski_distillery.Description {
return wisski_distillery.Description{
Requirements: core.Requirements{
Requirements: cli.Requirements{
NeedsDistillery: true,
},
Command: "server",

View file

@ -4,7 +4,7 @@ import (
"fmt"
wisski_distillery "github.com/FAU-CDI/wisski-distillery"
"github.com/FAU-CDI/wisski-distillery/internal/core"
"github.com/FAU-CDI/wisski-distillery/internal/cli"
"github.com/tkw1536/goprogram/exit"
"github.com/tkw1536/goprogram/parser"
)
@ -21,7 +21,7 @@ type shell struct {
func (shell) Description() wisski_distillery.Description {
return wisski_distillery.Description{
Requirements: core.Requirements{
Requirements: cli.Requirements{
NeedsDistillery: true,
},
ParserConfig: parser.Config{

View file

@ -2,8 +2,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/internal/component/exporter"
"github.com/FAU-CDI/wisski-distillery/internal/core"
"github.com/tkw1536/goprogram/exit"
)
@ -22,7 +22,7 @@ type snapshot struct {
func (snapshot) Description() wisski_distillery.Description {
return wisski_distillery.Description{
Requirements: core.Requirements{
Requirements: cli.Requirements{
NeedsDistillery: true,
},
Command: "snapshot",

View file

@ -5,8 +5,8 @@ import (
"io"
wisski_distillery "github.com/FAU-CDI/wisski-distillery"
"github.com/FAU-CDI/wisski-distillery/internal/cli"
"github.com/FAU-CDI/wisski-distillery/internal/component"
"github.com/FAU-CDI/wisski-distillery/internal/core"
"github.com/FAU-CDI/wisski-distillery/pkg/environment"
"github.com/FAU-CDI/wisski-distillery/pkg/fsx"
"github.com/FAU-CDI/wisski-distillery/pkg/logging"
@ -28,7 +28,7 @@ type systemupdate struct {
func (systemupdate) Description() wisski_distillery.Description {
return wisski_distillery.Description{
Requirements: core.Requirements{
Requirements: cli.Requirements{
NeedsDistillery: true,
},
ParserConfig: parser.Config{

View file

@ -4,7 +4,7 @@ import (
"fmt"
wisski_distillery "github.com/FAU-CDI/wisski-distillery"
"github.com/FAU-CDI/wisski-distillery/internal/core"
"github.com/FAU-CDI/wisski-distillery/internal/cli"
"github.com/FAU-CDI/wisski-distillery/internal/wisski"
"github.com/tkw1536/goprogram/exit"
@ -21,7 +21,7 @@ type updateprefixconfig struct {
func (updateprefixconfig) Description() wisski_distillery.Description {
return wisski_distillery.Description{
Requirements: core.Requirements{
Requirements: cli.Requirements{
NeedsDistillery: true,
},
Command: "update_prefix_config",

View file

@ -8,7 +8,7 @@ import (
wisski_distillery "github.com/FAU-CDI/wisski-distillery"
"github.com/FAU-CDI/wisski-distillery/cmd"
"github.com/FAU-CDI/wisski-distillery/internal/core"
"github.com/FAU-CDI/wisski-distillery/internal/cli"
"github.com/tkw1536/goprogram/exit"
"github.com/tkw1536/goprogram/stream"
)
@ -91,7 +91,7 @@ func main() {
// creat a new set of parameters
// and then use them to execute the main command
err := func() error {
params, err := core.ParamsFromEnv()
params, err := cli.ParamsFromEnv()
if err != nil {
return streams.Die(err)
}