Move internal/core => internal/cli
This commit is contained in:
parent
8d2855fdcb
commit
10df1c3243
45 changed files with 113 additions and 143 deletions
|
|
@ -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
4
internal/cli/cli.go
Normal 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
|
|
@ -1,4 +1,4 @@
|
|||
package core
|
||||
package cli
|
||||
|
||||
// Flags are global flags for the wdcli executable
|
||||
type Flags struct {
|
||||
|
|
@ -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")
|
||||
|
|
@ -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())
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package core
|
||||
package cli
|
||||
|
||||
import (
|
||||
"github.com/tkw1536/goprogram"
|
||||
|
|
@ -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]
|
||||
|
|
|
|||
|
|
@ -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?
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 == "" {
|
||||
|
|
|
|||
|
|
@ -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{
|
||||
|
|
|
|||
|
|
@ -1,4 +0,0 @@
|
|||
// Package legal contains legal notices.
|
||||
package legal
|
||||
|
||||
//go:generate gogenlicense -m
|
||||
|
|
@ -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"`
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue