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)
}

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.
package core
package bootstrap
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.
const BaseDirectoryDefault = "/var/www/deploy"
@ -21,7 +23,7 @@ const OverridesJSON = "overrides.json"
// DefaultOverridesJSON contains a template for a new 'overrides.json' file
//
//go:embed bootstrap/overrides.json
//go:embed overrides.json
var DefaultOverridesJSON []byte
// 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
//
//go:embed bootstrap/resolver-blocked.txt
//go:embed resolver-blocked.txt
var DefaultResolverBlockedTXT []byte
// 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
//
//go:embed bootstrap/global_authorized_keys
//go:embed global_authorized_keys
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
type Flags struct {

View file

@ -1,4 +1,4 @@
package core
package cli
import (
"errors"
@ -7,16 +7,15 @@ import (
"path/filepath"
"strings"
"github.com/FAU-CDI/wisski-distillery/internal/bootstrap"
"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.
//
// You probably want to use [MetaConfigPath] instead.
//
// It should contain the path to a deployment directory.
const MetaConfigFile = "." + Executable
const metaConfigFile = "." + bootstrap.Executable
// MetaConfigPath returns the full path to the MetaConfigPath()
func MetaConfigPath() (string, error) {
@ -25,7 +24,7 @@ func MetaConfigPath() (string, error) {
if err != nil {
return "", err
}
return filepath.Join(usr.HomeDir, MetaConfigFile), nil
return filepath.Join(usr.HomeDir, metaConfigFile), nil
}
var errReadBaseDirectoryEmpty = errors.New("ReadBaseDirectory: Directory is empty")

View file

@ -1,4 +1,4 @@
package core
package cli
import (
"context"
@ -6,6 +6,7 @@ import (
"os/signal"
"path/filepath"
"github.com/FAU-CDI/wisski-distillery/internal/bootstrap"
"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?
switch {
case environment.IsNotExist(err):
params.ConfigPath = BaseDirectoryDefault
params.ConfigPath = bootstrap.BaseDirectoryDefault
case err == nil:
params.ConfigPath = value
default:
@ -31,7 +32,7 @@ func ParamsFromEnv() (params Params, err error) {
}
// 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
ctx, cancel := context.WithCancel(context.Background())

View file

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

View file

@ -20,7 +20,7 @@ type Component interface {
// ComponentBase should be embedded into every component
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]

View file

@ -4,8 +4,8 @@ import (
"embed"
"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/core"
"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,
},
CopyContextFiles: []string{core.Executable},
CopyContextFiles: []string{bootstrap.Executable},
})
return stt
}
func (control Control) Context(parent component.InstallationContext) 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"
)
// Core represents the Core of a WissKI Distillery.
type Core struct {
Environment environment.Environment // environment to use for reading / writing to and from 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
//
//go:embed all:runtime
var runtimeResources embed.FS

View file

@ -3,14 +3,14 @@ package config
import (
"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/fsx"
)
// ExecutablePath returns the path to the executable of this distillery.
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

View file

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

View file

@ -1,9 +1,9 @@
package dis
import (
"github.com/FAU-CDI/wisski-distillery/internal/cli"
"github.com/FAU-CDI/wisski-distillery/internal/component"
"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/tkw1536/goprogram/exit"
)
@ -19,7 +19,7 @@ var errOpenConfig = exit.Error{
}
// 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{
context: params.Context,
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.
const MetadataTable = "metadatum"
// Metadatum represents
// Metadatum represents a metadatum for a single model
type Metadatum struct {
Pk uint `gorm:"column:pk;primaryKey"`

View file

@ -3,7 +3,8 @@ package wisski_distillery
import (
"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/tkw1536/goprogram"
"github.com/tkw1536/goprogram/exit"
@ -12,9 +13,9 @@ import (
// these define the ggman-specific program types
// none of these are strictly needed, they're just around for convenience
type wdcliEnv = *dis.Distillery
type wdcliParameters = core.Params
type wdcliRequirements = core.Requirements
type wdCliFlags = core.Flags
type wdcliParameters = cli.Params
type wdcliRequirements = cli.Requirements
type wdCliFlags = cli.Flags
type Program = goprogram.Program[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
// 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) {
context.EPrintf(warnNoDeployWdcli, core.Executable, dis.Config.ExecutablePath())
context.EPrintf(warnNoDeployWdcli, bootstrap.Executable, dis.Config.ExecutablePath())
}
return nil