-
Notifications
You must be signed in to change notification settings - Fork 1
/
platform.go
41 lines (34 loc) · 1.07 KB
/
platform.go
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
package platform
import (
"context"
"errors"
"github.com/ScoreTrak/ScoreTrak/pkg/platform/none"
"github.com/ScoreTrak/ScoreTrak/pkg/config"
"github.com/ScoreTrak/ScoreTrak/pkg/platform/docker"
"github.com/ScoreTrak/ScoreTrak/pkg/platform/kubernetes"
"github.com/ScoreTrak/ScoreTrak/pkg/platform/worker"
)
// Platform is an interface that allows ScoreTrak to deploy/remove the worker containers on a given environment like docker, docker swarm, or kubernetes.
type Platform interface {
DeployWorkers(ctx context.Context, info worker.Info) error
RemoveWorkers(ctx context.Context, info worker.Info) error
}
var ErrInvalidPlatform = errors.New("invalid platform specified")
const (
Docker = "docker"
Swarm = "swarm"
Kubernetes = "kubernetes"
None = "none"
)
func NewPlatform(config config.StaticConfig) (Platform, error) {
switch config.Platform.Use {
case Docker, Swarm:
return docker.NewDocker(config)
case Kubernetes:
return kubernetes.NewKubernetes(config)
case None:
return none.NewNonePlatform()
default:
return nil, ErrInvalidPlatform
}
}