Commit 94d2582e authored by Lukas Burgey's avatar Lukas Burgey
Browse files

Upgrade stub-script to v2

parent bbc1bf09
...@@ -7,8 +7,9 @@ import ( ...@@ -7,8 +7,9 @@ import (
"log" "log"
"net/http" "net/http"
"os" "os"
"time"
s "git.scc.kit.edu/feudal/feudalScripts" "git.scc.kit.edu/feudal/feudalScripts/v2"
) )
const ( const (
...@@ -25,8 +26,9 @@ func check(err error) { ...@@ -25,8 +26,9 @@ func check(err error) {
} }
} }
func deploy(input s.Input) (output s.Output, err error) { func deploy(input scripts.Input) (output scripts.Output, err error) {
output.State = s.Deployed time.Sleep(time.Second)
output.State = scripts.Deployed
output.Msg = "deployed" output.Msg = "deployed"
output.Credentials = map[string]string{ output.Credentials = map[string]string{
"password": "stub password", "password": "stub password",
...@@ -35,19 +37,20 @@ func deploy(input s.Input) (output s.Output, err error) { ...@@ -35,19 +37,20 @@ func deploy(input s.Input) (output s.Output, err error) {
return return
} }
func withdraw(input s.Input) (output s.Output, err error) { func withdraw(input scripts.Input) (output scripts.Output, err error) {
output.State = s.NotDeployed time.Sleep(time.Second)
output.State = scripts.NotDeployed
output.Msg = "stub remove" output.Msg = "stub remove"
return return
} }
func handleInput() (output s.Output, err error) { func handleInput() (output scripts.Output, err error) {
inputBytes, err := ioutil.ReadAll(os.Stdin) inputBytes, err := ioutil.ReadAll(os.Stdin)
if err != nil { if err != nil {
return return
} }
input, err := s.UnmarshalInput(inputBytes) input, err := scripts.UnmarshalInput(inputBytes)
if err != nil { if err != nil {
return return
} }
...@@ -68,8 +71,8 @@ func main() { ...@@ -68,8 +71,8 @@ func main() {
output, err := handleInput() output, err := handleInput()
if err != nil { if err != nil {
output = s.Output{ output = scripts.Output{
State: s.Failed, State: scripts.Failed,
Msg: fmt.Sprintf("%s", err), Msg: fmt.Sprintf("%s", err),
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment