Show a warning when using wrong executable
This commit updates the 'wdcli' command to show a warning when using the wrong executable.
This commit is contained in:
parent
c4de1f2a06
commit
35bb95c5ca
29 changed files with 176 additions and 30 deletions
36
env/constants.go
vendored
Normal file
36
env/constants.go
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
package env
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/fsx"
|
||||
)
|
||||
|
||||
// Executable is the name of the 'wdcli' executable.
|
||||
// It should be located inside the deployment directory.
|
||||
const Executable = "wdcli"
|
||||
|
||||
// ExecutablePath returns the path to the executable of this distillery.
|
||||
func (dis *Distillery) ExecutablePath() string {
|
||||
return filepath.Join(dis.Config.DeployRoot, Executable)
|
||||
}
|
||||
|
||||
// UsingDistilleryExecutable checks if the current process
|
||||
func (dis *Distillery) UsingDistilleryExecutable() bool {
|
||||
exe, err := os.Executable()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return fsx.SameFile(exe, dis.ExecutablePath())
|
||||
}
|
||||
|
||||
// Config file is the name of the config file.
|
||||
// It should be located inside the deployment directory.
|
||||
const ConfigFile = ".env"
|
||||
|
||||
// ConfigFilePath returns the path to the configuration file of this distillery.
|
||||
// TODO: This should be moved to the Config struct.
|
||||
func (dis *Distillery) ConfigFilePath() string {
|
||||
return filepath.Join(dis.Config.DeployRoot, ConfigFile)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue