forked from pufferpanel/pufferpanel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.go
More file actions
93 lines (78 loc) · 3.39 KB
/
server.go
File metadata and controls
93 lines (78 loc) · 3.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package pufferpanel
import (
"github.com/pufferpanel/pufferpanel/v3/files"
)
type Server struct {
Type
Identifier string `json:"id,omitempty"`
Display string `json:"display,omitempty"`
Icon string `json:"icon,omitempty"`
Variables map[string]Variable `json:"data"`
Groups []Group `json:"groups,omitempty"`
Installation []ConditionalMetadataType `json:"install"`
Uninstallation []ConditionalMetadataType `json:"uninstall"`
Execution Execution `json:"run"`
Environment MetadataType `json:"environment"`
SupportedEnvironments []MetadataType `json:"supportedEnvironments,omitempty"`
Requirements Requirements `json:"requirements,omitempty"`
Stats MetadataType `json:"stats,omitempty"`
Query MetadataType `json:"query,omitempty"`
} //@name ServerDefinition
type Execution struct {
Command interface{} `json:"command"`
StopCommand string `json:"stop,omitempty"`
StopCode int `json:"stopCode,omitempty"`
PreExecution []ConditionalMetadataType `json:"pre,omitempty"`
PostExecution []ConditionalMetadataType `json:"post,omitempty"`
EnvironmentVariables map[string]string `json:"environmentVars,omitempty"`
WorkingDirectory string `json:"workingDirectory,omitempty"`
Stdin StdinConsoleConfiguration `json:"stdin,omitempty"`
AutoStart bool `json:"autostart"`
AutoRestartFromCrash bool `json:"autorecover"`
AutoRestartFromGraceful bool `json:"autorestart"`
ExpectedExitCode int `json:"expectedExitCode,omitempty"`
} //@name Execution
type Name struct {
Name string `json:"name"`
} //@name Name
type Command struct {
If string `json:"if,omitempty"`
Command string `json:"command"`
StdIn StdinConsoleConfiguration `json:"stdin"`
} //@name Command
type Type struct {
Type string `json:"type"`
} //@name Type
type Group struct {
If string `json:"if,omitempty"`
Display string `json:"display"`
Description string `json:"description"`
Variables []string `json:"variables"`
Order int `json:"order"`
} //@name Group
func (s *Server) CopyFrom(replacement *Server) {
s.Variables = replacement.Variables
s.Type = replacement.Type
s.Execution = replacement.Execution
s.Display = replacement.Display
s.Installation = replacement.Installation
s.Uninstallation = replacement.Uninstallation
s.Environment = replacement.Environment
s.Requirements = replacement.Requirements
s.SupportedEnvironments = replacement.SupportedEnvironments
s.Groups = replacement.Groups
s.Stats = replacement.Stats
}
func (s *Server) DataToMap() map[string]interface{} {
var result = make(map[string]interface{})
for k, v := range s.Variables {
result[k] = v.Value
}
return result
}
type DaemonServer interface {
GetFileServer() files.FileServer
Extract(source, destination string) error
ArchiveItems(files []string, destination string) error
DataToMap() map[string]interface{}
}