Skip to content
Snippets Groups Projects
Commit 9dbb76f2 authored by Christian Pointner's avatar Christian Pointner
Browse files

added import state to file model

parent 5bae0210
No related branches found
No related tags found
No related merge requests found
......@@ -33,15 +33,15 @@ import (
)
var (
testBasePath = "run/aura-tank_testing"
testDBType = "mysql"
testDBConnection = "tank:aura@tcp(127.0.0.1:3306)/tank?charset=utf8&parseTime=True&loc=Local"
// testDBType = "postgres"
// testDBConnection = "host=127.0.0.1 port=5432 user=tank dbname=tank password=aura sslmode=disable"
testGroup1 = "test1"
testGroup2 = "test2"
testUser1 = "user1"
testUser2 = "user2"
testBasePath = "run/aura-tank_testing"
// testDBType = "mysql"
// testDBConnection = "tank:aura@tcp(127.0.0.1:3306)/tank?charset=utf8&parseTime=True&loc=Local"
testDBType = "postgres"
testDBConnection = "host=127.0.0.1 port=5432 user=tank dbname=tank password=aura sslmode=disable"
testGroup1 = "test1"
testGroup2 = "test2"
testUser1 = "user1"
testUser2 = "user2"
)
func stringInSlice(slice []string, search string) bool {
......
......@@ -56,58 +56,58 @@ func (g Group) String() string {
//******* Files
// type ImportState int
// const (
// ImportNew ImportState = iota
// ImportPending
// ImportRunning
// ImportDone
// ImportAborted
// )
// func (s ImportState) String() string {
// switch s {
// case ImportNew:
// return "new"
// case ImportPending:
// return "pending"
// case ImportRunning:
// return "running"
// case ImportDone:
// return "done"
// case ImportAborted:
// return "aborted"
// }
// return "unknown"
// }
type ImportState int
// func (s *ImportState) fromString(str string) error {
// switch str {
// case "new":
// *s = ImportNew
// case "pending":
// *s = ImportPending
// case "running":
// *s = ImportRunning
// case "done":
// *s = ImportDone
// case "aborted":
// *s = ImportAborted
// default:
// return errors.New("invalid import state: '" + str + "'")
// }
// return nil
// }
const (
ImportNew ImportState = iota
ImportPending
ImportRunning
ImportDone
ImportAborted
)
// func (s ImportState) MarshalText() (data []byte, err error) {
// data = []byte(s.String())
// return
// }
func (s ImportState) String() string {
switch s {
case ImportNew:
return "new"
case ImportPending:
return "pending"
case ImportRunning:
return "running"
case ImportDone:
return "done"
case ImportAborted:
return "aborted"
}
return "unknown"
}
// func (s *ImportState) UnmarshalText(data []byte) (err error) {
// return s.fromString(string(data))
// }
func (s *ImportState) fromString(str string) error {
switch str {
case "new":
*s = ImportNew
case "pending":
*s = ImportPending
case "running":
*s = ImportRunning
case "done":
*s = ImportDone
case "aborted":
*s = ImportAborted
default:
return errors.New("invalid import state: '" + str + "'")
}
return nil
}
func (s ImportState) MarshalText() (data []byte, err error) {
data = []byte(s.String())
return
}
func (s *ImportState) UnmarshalText(data []byte) (err error) {
return s.fromString(string(data))
}
// type ImportLogLine struct {
// Timestamp time.Time `json:"timestamp"`
......@@ -121,8 +121,8 @@ func (g Group) String() string {
// }
type Import struct {
// State ImportState `json:"state"`
Success bool `json:"success"`
State ImportState `json:"state"`
Success bool `json:"success"`
// Log ImportLog `json:"log"`
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment