add control package, reorganize some files and packages
This commit is contained in:
21
control/environments/docker.go
Normal file
21
control/environments/docker.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package environments
|
||||
|
||||
type DockerEnvironment struct {
|
||||
BaseEnvironment
|
||||
}
|
||||
|
||||
// Ensure DockerEnvironment implements Environment
|
||||
var _ Environment = &DockerEnvironment{}
|
||||
|
||||
func NewDockerEnvironment() *DockerEnvironment {
|
||||
return &DockerEnvironment{}
|
||||
}
|
||||
|
||||
func (env *DockerEnvironment) Exec() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (env *DockerEnvironment) Create() error {
|
||||
|
||||
return nil
|
||||
}
|
||||
50
control/environments/environment.go
Normal file
50
control/environments/environment.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package environments
|
||||
|
||||
// Environment provides abstraction of different environments
|
||||
type Environment interface {
|
||||
// Execute a command in the environment
|
||||
Exec() error
|
||||
|
||||
// Create creates the environment
|
||||
Create() error
|
||||
|
||||
// Destroy destroys the environment
|
||||
Destroy() error
|
||||
|
||||
// Exists checks wether the Environment exists or not
|
||||
Exists() bool
|
||||
|
||||
// ReCreate recreates the environment by first Destroying and then Creating
|
||||
ReCreate() error
|
||||
}
|
||||
|
||||
type BaseEnvironment struct {
|
||||
}
|
||||
|
||||
// Ensure BaseEnvironment implements Environment
|
||||
var _ Environment = &BaseEnvironment{}
|
||||
|
||||
func (env *BaseEnvironment) Create() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (env *BaseEnvironment) Destroy() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (env *BaseEnvironment) Exists() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (env *BaseEnvironment) ReCreate() error {
|
||||
if env.Exists() {
|
||||
if err := env.Destroy(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return env.Create()
|
||||
}
|
||||
|
||||
func (env *BaseEnvironment) Exec() error {
|
||||
return nil
|
||||
}
|
||||
12
control/server.go
Normal file
12
control/server.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package control
|
||||
|
||||
// Server is a single instance of a Service managed by the panel
|
||||
type Server struct {
|
||||
Service *Service
|
||||
}
|
||||
|
||||
// HasPermission checks wether a provided token has a specific permission
|
||||
func (s *Server) HasPermission(token string, permission string) bool {
|
||||
// TODO: properly implement this
|
||||
return true
|
||||
}
|
||||
7
control/service.go
Normal file
7
control/service.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package control
|
||||
|
||||
import "github.com/schrej/wings/control/environments"
|
||||
|
||||
type Service struct {
|
||||
Environment environments.Environment
|
||||
}
|
||||
Reference in New Issue
Block a user