Adding changes! Working docker wrapper!

Signed-off-by: Kris Nóva <kris@nivenly.com>
This commit is contained in:
Kris Nóva 2021-02-03 14:00:31 -08:00
parent b107d98a37
commit 3ccaa2ec9b
7 changed files with 63 additions and 28 deletions

View file

@ -1,6 +1,9 @@
package sampleapp
import (
"path/filepath"
"runtime"
"github.com/kris-nova/logger"
photoprism "github.com/kris-nova/client-go"
@ -17,25 +20,45 @@ func New() *SampleApplication {
// These are the bash scripts that can be used
// to start/stop the Photoprism test application
var (
CreateCommand = `./pcreate`
DestroyCommand = `./pdestroy`
LogsCommand = `./plogs`
StartCommand = `./pstart`
StopCommand = `./pstop`
CreateCommand = `pcreate`
DestroyCommand = `pdestroy`
LogsCommand = `plogs`
StartCommand = `pstart`
StopCommand = `pstop`
)
func (a *SampleApplication) Start() error {
logger.Info("Starting Application...")
script := NewScript(StartCommand)
script, err := NewScriptFromPath(filepath.Join(PrintWorkingDirectory(), StartCommand))
if err != nil {
return err
}
return script.Interpret()
}
func (a *SampleApplication) Stop() error {
logger.Info("Stopping Application...")
script := NewScript(StopCommand)
script, err := NewScriptFromPath(filepath.Join(PrintWorkingDirectory(), StopCommand))
if err != nil {
return err
}
return script.Interpret()
}
func (a *SampleApplication) GetAuth() photoprism.ClientAuthenticator {
return nil
}
func PrintWorkingDirectory() string {
_, filename, _, ok := runtime.Caller(1)
if !ok {
logger.Info("Unable to PWD")
return ""
}
dir, err := filepath.Abs(filepath.Dir(filename))
if err != nil {
logger.Info("Unable to PWD: %v", err)
return ""
}
return dir
}