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

View file

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

View file

@ -5,8 +5,10 @@ import (
"path/filepath" "path/filepath"
wisski_distillery "github.com/FAU-CDI/wisski-distillery" 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/config"
"github.com/FAU-CDI/wisski-distillery/internal/core"
"github.com/FAU-CDI/wisski-distillery/pkg/environment" "github.com/FAU-CDI/wisski-distillery/pkg/environment"
"github.com/FAU-CDI/wisski-distillery/pkg/fsx" "github.com/FAU-CDI/wisski-distillery/pkg/fsx"
"github.com/FAU-CDI/wisski-distillery/pkg/logging" "github.com/FAU-CDI/wisski-distillery/pkg/logging"
@ -14,16 +16,16 @@ import (
) )
// Bootstrap is the 'bootstrap' command // 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"` 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)"` 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{ return wisski_distillery.Description{
Requirements: core.Requirements{ Requirements: cli.Requirements{
NeedsDistillery: false, NeedsDistillery: false,
}, },
Command: "bootstrap", Command: "bootstrap",
@ -66,7 +68,7 @@ var errBootstrapCreateFile = exit.Error{
ExitCode: exit.ExitGeneric, 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! // installation environment is the native environment!
// TODO: Should this be configurable? // TODO: Should this be configurable?
var env environment.Native 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 // 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 { if err == nil && got != "" && got != root {
return errBootstrapDifferent.WithMessageF(got) 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 { if err := env.MkdirAll(root, environment.DefaultDirPerm); err != nil {
return errBootstrapFailedToCreateDirectory.WithMessageF(root) return errBootstrapFailedToCreateDirectory.WithMessageF(root)
} }
if err := core.WriteBaseDirectory(env, root); err != nil { if err := cli.WriteBaseDirectory(env, root); err != nil {
return errBootstrapFailedToSaveDirectory.WithMessageF(root) return errBootstrapFailedToSaveDirectory.WithMessageF(root)
} }
context.Println(root) context.Println(root)
} }
// TODO: Should we read an existing configuration file? // TODO: Should we read an existing configuration file?
wdcliPath := filepath.Join(root, core.Executable) wdcliPath := filepath.Join(root, bootstrap.Executable)
envPath := filepath.Join(root, core.ConfigFile) envPath := filepath.Join(root, bootstrap.ConfigFile)
// setup a new template for the configuration file! // setup a new template for the configuration file!
var tpl config.Template var tpl config.Template
@ -140,7 +142,7 @@ func (bs bootstrap) Run(context wisski_distillery.Context) error {
if err := environment.WriteFile( if err := environment.WriteFile(
env, env,
tpl.SelfOverridesFile, tpl.SelfOverridesFile,
core.DefaultOverridesJSON, bootstrap.DefaultOverridesJSON,
fs.ModePerm, fs.ModePerm,
); err != nil { ); err != nil {
return err return err
@ -150,7 +152,7 @@ func (bs bootstrap) Run(context wisski_distillery.Context) error {
if err := environment.WriteFile( if err := environment.WriteFile(
env, env,
tpl.AuthorizedKeys, tpl.AuthorizedKeys,
core.DefaultAuthorizedKeys, bootstrap.DefaultAuthorizedKeys,
fs.ModePerm, fs.ModePerm,
); err != nil { ); err != nil {
return err return err
@ -160,7 +162,7 @@ func (bs bootstrap) Run(context wisski_distillery.Context) error {
if err := environment.WriteFile( if err := environment.WriteFile(
env, env,
tpl.SelfResolverBlockFile, tpl.SelfResolverBlockFile,
core.DefaultResolverBlockedTXT, bootstrap.DefaultResolverBlockedTXT,
fs.ModePerm, fs.ModePerm,
); err != nil { ); err != nil {
return err return err

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,9 +1,11 @@
// Package core implements the core of the WissKI Distillery and the wdcli executable. // Package bootstrap implements the core of the WissKI Distillery and the wdcli executable.
// It does not depend on any other packages. // It does not depend on any other packages.
package core package bootstrap
import _ "embed" import _ "embed"
// TODO: This package should be split up into a true bootstrap component, and something else.
// BaseDirectoryDefault is the default deploy directory to load the distillery from. // BaseDirectoryDefault is the default deploy directory to load the distillery from.
const BaseDirectoryDefault = "/var/www/deploy" const BaseDirectoryDefault = "/var/www/deploy"
@ -21,7 +23,7 @@ const OverridesJSON = "overrides.json"
// DefaultOverridesJSON contains a template for a new 'overrides.json' file // DefaultOverridesJSON contains a template for a new 'overrides.json' file
// //
//go:embed bootstrap/overrides.json //go:embed overrides.json
var DefaultOverridesJSON []byte var DefaultOverridesJSON []byte
// ResolverBlockTXT is the name of the resolver blocked prefix file. // ResolverBlockTXT is the name of the resolver blocked prefix file.
@ -30,7 +32,7 @@ const ResolverBlockedTXT = "resolver-blocked.txt"
// ResolverBlockTXT contains a template for 'resolver-blocked' file // ResolverBlockTXT contains a template for 'resolver-blocked' file
// //
//go:embed bootstrap/resolver-blocked.txt //go:embed resolver-blocked.txt
var DefaultResolverBlockedTXT []byte var DefaultResolverBlockedTXT []byte
// AuthorizedKeys contains the default name for the 'global_authorized_keys' file // AuthorizedKeys contains the default name for the 'global_authorized_keys' file
@ -38,5 +40,5 @@ const AuthorizedKeys = "authorized_keys"
// DefaultAuthorizedKeys contains a template for a new 'global_authorized_keys' file // DefaultAuthorizedKeys contains a template for a new 'global_authorized_keys' file
// //
//go:embed bootstrap/global_authorized_keys //go:embed global_authorized_keys
var DefaultAuthorizedKeys []byte var DefaultAuthorizedKeys []byte

4
internal/cli/cli.go Normal file
View file

@ -0,0 +1,4 @@
// Package cli contains helper code for the command line executable
package cli
//go:generate gogenlicense -n LegalNotices -m

File diff suppressed because one or more lines are too long

View file

@ -1,4 +1,4 @@
package core package cli
// Flags are global flags for the wdcli executable // Flags are global flags for the wdcli executable
type Flags struct { type Flags struct {

View file

@ -1,4 +1,4 @@
package core package cli
import ( import (
"errors" "errors"
@ -7,16 +7,15 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
"github.com/FAU-CDI/wisski-distillery/internal/bootstrap"
"github.com/FAU-CDI/wisski-distillery/pkg/environment" "github.com/FAU-CDI/wisski-distillery/pkg/environment"
) )
// MetaConfigFile is the path to a configuration file that contains the path to the last used wdcli executable. // metaConfigFile is the path to a configuration file that contains the path to the last used wdcli executable.
// It is expected to be in the current user's home directory. // It is expected to be in the current user's home directory.
// //
// You probably want to use [MetaConfigPath] instead.
//
// It should contain the path to a deployment directory. // It should contain the path to a deployment directory.
const MetaConfigFile = "." + Executable const metaConfigFile = "." + bootstrap.Executable
// MetaConfigPath returns the full path to the MetaConfigPath() // MetaConfigPath returns the full path to the MetaConfigPath()
func MetaConfigPath() (string, error) { func MetaConfigPath() (string, error) {
@ -25,7 +24,7 @@ func MetaConfigPath() (string, error) {
if err != nil { if err != nil {
return "", err return "", err
} }
return filepath.Join(usr.HomeDir, MetaConfigFile), nil return filepath.Join(usr.HomeDir, metaConfigFile), nil
} }
var errReadBaseDirectoryEmpty = errors.New("ReadBaseDirectory: Directory is empty") var errReadBaseDirectoryEmpty = errors.New("ReadBaseDirectory: Directory is empty")

View file

@ -1,4 +1,4 @@
package core package cli
import ( import (
"context" "context"
@ -6,6 +6,7 @@ import (
"os/signal" "os/signal"
"path/filepath" "path/filepath"
"github.com/FAU-CDI/wisski-distillery/internal/bootstrap"
"github.com/FAU-CDI/wisski-distillery/pkg/environment" "github.com/FAU-CDI/wisski-distillery/pkg/environment"
) )
@ -23,7 +24,7 @@ func ParamsFromEnv() (params Params, err error) {
value, err := ReadBaseDirectory(environment.Native{}) // TODO: Are we sure about the native environment here? value, err := ReadBaseDirectory(environment.Native{}) // TODO: Are we sure about the native environment here?
switch { switch {
case environment.IsNotExist(err): case environment.IsNotExist(err):
params.ConfigPath = BaseDirectoryDefault params.ConfigPath = bootstrap.BaseDirectoryDefault
case err == nil: case err == nil:
params.ConfigPath = value params.ConfigPath = value
default: default:
@ -31,7 +32,7 @@ func ParamsFromEnv() (params Params, err error) {
} }
// and add the configuration file name to it! // and add the configuration file name to it!
params.ConfigPath = filepath.Join(params.ConfigPath, ConfigFile) params.ConfigPath = filepath.Join(params.ConfigPath, bootstrap.ConfigFile)
// generate a new context // generate a new context
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())

View file

@ -1,4 +1,4 @@
package core package cli
import ( import (
"github.com/tkw1536/goprogram" "github.com/tkw1536/goprogram"

View file

@ -20,7 +20,7 @@ type Component interface {
// ComponentBase should be embedded into every component // ComponentBase should be embedded into every component
type ComponentBase struct { type ComponentBase struct {
Core // the core of the associated distillery Core // the underlying stillage of the distillery
} }
//lint:ignore U1000 used to implement the private methods of [Component] //lint:ignore U1000 used to implement the private methods of [Component]

View file

@ -4,8 +4,8 @@ import (
"embed" "embed"
"path/filepath" "path/filepath"
"github.com/FAU-CDI/wisski-distillery/internal/bootstrap"
"github.com/FAU-CDI/wisski-distillery/internal/component" "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/environment"
) )
@ -46,13 +46,13 @@ func (control *Control) Stack(env environment.Environment) component.StackWithRe
"SELF_RESOLVER_BLOCK_FILE": control.Config.SelfResolverBlockFile, "SELF_RESOLVER_BLOCK_FILE": control.Config.SelfResolverBlockFile,
}, },
CopyContextFiles: []string{core.Executable}, CopyContextFiles: []string{bootstrap.Executable},
}) })
return stt return stt
} }
func (control Control) Context(parent component.InstallationContext) component.InstallationContext { func (control Control) Context(parent component.InstallationContext) component.InstallationContext {
return component.InstallationContext{ return component.InstallationContext{
core.Executable: control.Config.CurrentExecutable(control.Environment), // TODO: Does this make sense? bootstrap.Executable: control.Config.CurrentExecutable(control.Environment), // TODO: Does this make sense?
} }
} }

View file

@ -5,7 +5,6 @@ import (
"github.com/FAU-CDI/wisski-distillery/pkg/environment" "github.com/FAU-CDI/wisski-distillery/pkg/environment"
) )
// Core represents the Core of a WissKI Distillery.
type Core struct { type Core struct {
Environment environment.Environment // environment to use for reading / writing to and from the distillery Environment environment.Environment // environment to use for reading / writing to and from the distillery
Config *config.Config // the configuration of the distillery Config *config.Config // the configuration of the distillery

View file

@ -14,6 +14,7 @@ var errBootstrapFailedRuntime = exit.Error{
} }
// Runtime contains runtime resources to be installed into any instance // Runtime contains runtime resources to be installed into any instance
//
//go:embed all:runtime //go:embed all:runtime
var runtimeResources embed.FS var runtimeResources embed.FS

View file

@ -3,14 +3,14 @@ package config
import ( import (
"path/filepath" "path/filepath"
"github.com/FAU-CDI/wisski-distillery/internal/core" "github.com/FAU-CDI/wisski-distillery/internal/bootstrap"
"github.com/FAU-CDI/wisski-distillery/pkg/environment" "github.com/FAU-CDI/wisski-distillery/pkg/environment"
"github.com/FAU-CDI/wisski-distillery/pkg/fsx" "github.com/FAU-CDI/wisski-distillery/pkg/fsx"
) )
// ExecutablePath returns the path to the executable of this distillery. // ExecutablePath returns the path to the executable of this distillery.
func (cfg Config) ExecutablePath() string { func (cfg Config) ExecutablePath() string {
return filepath.Join(cfg.DeployRoot, core.Executable) return filepath.Join(cfg.DeployRoot, bootstrap.Executable)
} }
// UsingDistilleryExecutable checks if the current process is using the distillery executable // UsingDistilleryExecutable checks if the current process is using the distillery executable

View file

@ -6,7 +6,7 @@ import (
"path/filepath" "path/filepath"
"reflect" "reflect"
"github.com/FAU-CDI/wisski-distillery/internal/core" "github.com/FAU-CDI/wisski-distillery/internal/bootstrap"
"github.com/FAU-CDI/wisski-distillery/pkg/environment" "github.com/FAU-CDI/wisski-distillery/pkg/environment"
"github.com/FAU-CDI/wisski-distillery/pkg/hostname" "github.com/FAU-CDI/wisski-distillery/pkg/hostname"
"github.com/FAU-CDI/wisski-distillery/pkg/password" "github.com/FAU-CDI/wisski-distillery/pkg/password"
@ -34,7 +34,7 @@ type Template struct {
// SetDefaults sets defaults on the template // SetDefaults sets defaults on the template
func (tpl *Template) SetDefaults(env environment.Environment) (err error) { func (tpl *Template) SetDefaults(env environment.Environment) (err error) {
if tpl.DeployRoot == "" { if tpl.DeployRoot == "" {
tpl.DeployRoot = core.BaseDirectoryDefault tpl.DeployRoot = bootstrap.BaseDirectoryDefault
} }
if tpl.DefaultDomain == "" { if tpl.DefaultDomain == "" {
@ -42,15 +42,15 @@ func (tpl *Template) SetDefaults(env environment.Environment) (err error) {
} }
if tpl.SelfOverridesFile == "" { if tpl.SelfOverridesFile == "" {
tpl.SelfOverridesFile = filepath.Join(tpl.DeployRoot, core.OverridesJSON) tpl.SelfOverridesFile = filepath.Join(tpl.DeployRoot, bootstrap.OverridesJSON)
} }
if tpl.SelfResolverBlockFile == "" { if tpl.SelfResolverBlockFile == "" {
tpl.SelfResolverBlockFile = filepath.Join(tpl.DeployRoot, core.ResolverBlockedTXT) tpl.SelfResolverBlockFile = filepath.Join(tpl.DeployRoot, bootstrap.ResolverBlockedTXT)
} }
if tpl.AuthorizedKeys == "" { if tpl.AuthorizedKeys == "" {
tpl.AuthorizedKeys = filepath.Join(tpl.DeployRoot, core.AuthorizedKeys) tpl.AuthorizedKeys = filepath.Join(tpl.DeployRoot, bootstrap.AuthorizedKeys)
} }
if tpl.TriplestoreAdminUser == "" { if tpl.TriplestoreAdminUser == "" {

View file

@ -1,9 +1,9 @@
package dis package dis
import ( import (
"github.com/FAU-CDI/wisski-distillery/internal/cli"
"github.com/FAU-CDI/wisski-distillery/internal/component" "github.com/FAU-CDI/wisski-distillery/internal/component"
"github.com/FAU-CDI/wisski-distillery/internal/config" "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/environment"
"github.com/tkw1536/goprogram/exit" "github.com/tkw1536/goprogram/exit"
) )
@ -19,7 +19,7 @@ var errOpenConfig = exit.Error{
} }
// NewDistillery creates a new distillery from the provided flags // NewDistillery creates a new distillery from the provided flags
func NewDistillery(params core.Params, flags core.Flags, req core.Requirements) (dis *Distillery, err error) { func NewDistillery(params cli.Params, flags cli.Flags, req cli.Requirements) (dis *Distillery, err error) {
dis = &Distillery{ dis = &Distillery{
context: params.Context, context: params.Context,
Core: component.Core{ Core: component.Core{

View file

@ -1,4 +0,0 @@
// Package legal contains legal notices.
package legal
//go:generate gogenlicense -m

View file

@ -3,7 +3,7 @@ package models
// MetadataTable is the name of the table the 'Metadatum' model is stored in. // MetadataTable is the name of the table the 'Metadatum' model is stored in.
const MetadataTable = "metadatum" const MetadataTable = "metadatum"
// Metadatum represents // Metadatum represents a metadatum for a single model
type Metadatum struct { type Metadatum struct {
Pk uint `gorm:"column:pk;primaryKey"` Pk uint `gorm:"column:pk;primaryKey"`

View file

@ -3,7 +3,8 @@ package wisski_distillery
import ( import (
"os/user" "os/user"
"github.com/FAU-CDI/wisski-distillery/internal/core" "github.com/FAU-CDI/wisski-distillery/internal/bootstrap"
"github.com/FAU-CDI/wisski-distillery/internal/cli"
"github.com/FAU-CDI/wisski-distillery/internal/dis" "github.com/FAU-CDI/wisski-distillery/internal/dis"
"github.com/tkw1536/goprogram" "github.com/tkw1536/goprogram"
"github.com/tkw1536/goprogram/exit" "github.com/tkw1536/goprogram/exit"
@ -12,9 +13,9 @@ import (
// these define the ggman-specific program types // these define the ggman-specific program types
// none of these are strictly needed, they're just around for convenience // none of these are strictly needed, they're just around for convenience
type wdcliEnv = *dis.Distillery type wdcliEnv = *dis.Distillery
type wdcliParameters = core.Params type wdcliParameters = cli.Params
type wdcliRequirements = core.Requirements type wdcliRequirements = cli.Requirements
type wdCliFlags = core.Flags type wdCliFlags = cli.Flags
type Program = goprogram.Program[wdcliEnv, wdcliParameters, wdCliFlags, wdcliRequirements] type Program = goprogram.Program[wdcliEnv, wdcliParameters, wdCliFlags, wdcliRequirements]
type Command = goprogram.Command[wdcliEnv, wdcliParameters, wdCliFlags, wdcliRequirements] type Command = goprogram.Command[wdcliEnv, wdcliParameters, wdCliFlags, wdcliRequirements]
@ -42,7 +43,7 @@ func NewProgram() Program {
// when not running inside docker and we need a distillery // when not running inside docker and we need a distillery
// then we should warn if we are not using the distillery executable. // then we should warn if we are not using the distillery executable.
if dis := context.Environment; !context.Args.Flags.InternalInDocker && context.Description.Requirements.NeedsDistillery && !dis.Config.UsingDistilleryExecutable(dis.Environment) { if dis := context.Environment; !context.Args.Flags.InternalInDocker && context.Description.Requirements.NeedsDistillery && !dis.Config.UsingDistilleryExecutable(dis.Environment) {
context.EPrintf(warnNoDeployWdcli, core.Executable, dis.Config.ExecutablePath()) context.EPrintf(warnNoDeployWdcli, bootstrap.Executable, dis.Config.ExecutablePath())
} }
return nil return nil