From a2d741c13adf56353e4b96b46cbd3fb7420179b0 Mon Sep 17 00:00:00 2001 From: Jakob Schrettenbrunner Date: Thu, 29 Jun 2017 12:24:18 +0200 Subject: [PATCH] add control package, reorganize some files and packages --- {environments => control/environments}/docker.go | 3 +++ .../environments}/environment.go | 7 +++++++ control/server.go | 12 ++++++++++++ control/service.go | 7 +++++++ services/service.go | 7 ------- 5 files changed, 29 insertions(+), 7 deletions(-) rename {environments => control/environments}/docker.go (74%) rename {environments => control/environments}/environment.go (84%) create mode 100644 control/server.go create mode 100644 control/service.go delete mode 100644 services/service.go diff --git a/environments/docker.go b/control/environments/docker.go similarity index 74% rename from environments/docker.go rename to control/environments/docker.go index fd2bfe2..25c4694 100644 --- a/environments/docker.go +++ b/control/environments/docker.go @@ -4,6 +4,9 @@ type DockerEnvironment struct { BaseEnvironment } +// Ensure DockerEnvironment implements Environment +var _ Environment = &DockerEnvironment{} + func NewDockerEnvironment() *DockerEnvironment { return &DockerEnvironment{} } diff --git a/environments/environment.go b/control/environments/environment.go similarity index 84% rename from environments/environment.go rename to control/environments/environment.go index 9c06212..3beff97 100644 --- a/environments/environment.go +++ b/control/environments/environment.go @@ -21,6 +21,9 @@ type Environment interface { type BaseEnvironment struct { } +// Ensure BaseEnvironment implements Environment +var _ Environment = &BaseEnvironment{} + func (env *BaseEnvironment) Create() error { return nil } @@ -41,3 +44,7 @@ func (env *BaseEnvironment) ReCreate() error { } return env.Create() } + +func (env *BaseEnvironment) Exec() error { + return nil +} diff --git a/control/server.go b/control/server.go new file mode 100644 index 0000000..bbb0f7c --- /dev/null +++ b/control/server.go @@ -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 +} diff --git a/control/service.go b/control/service.go new file mode 100644 index 0000000..127f097 --- /dev/null +++ b/control/service.go @@ -0,0 +1,7 @@ +package control + +import "github.com/schrej/wings/control/environments" + +type Service struct { + Environment environments.Environment +} diff --git a/services/service.go b/services/service.go deleted file mode 100644 index 02fa908..0000000 --- a/services/service.go +++ /dev/null @@ -1,7 +0,0 @@ -package services - -import "github.com/schrej/wings/environments" - -type Service struct { - Environment environments.Environment -}