forked from fluxcd/flux
/
standalone.go
43 lines (39 loc) · 1.02 KB
/
standalone.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
42
43
package instance
import (
"errors"
"github.com/go-kit/kit/log"
"github.com/weaveworks/flux"
"github.com/weaveworks/flux/git"
"github.com/weaveworks/flux/history"
"github.com/weaveworks/flux/platform"
"github.com/weaveworks/flux/registry"
)
// StandaloneInstancer is the instancer for standalone mode
type StandaloneInstancer struct {
Instance flux.InstanceID
Connecter platform.Connecter
Registry registry.Registry
Config Configurer
GitRepo git.Repo
EventReader history.EventReader
EventWriter history.EventWriter
BaseLogger log.Logger
}
func (s StandaloneInstancer) Get(inst flux.InstanceID) (*Instance, error) {
if inst != s.Instance {
return nil, errors.New("cannot find instance with ID: " + string(inst))
}
platform, err := s.Connecter.Connect(inst)
if err != nil {
return nil, errors.New("cannot get platform for instance")
}
return New(
platform,
s.Registry,
s.Config,
s.GitRepo,
log.NewContext(s.BaseLogger).With("instanceID", s.Instance),
s.EventReader,
s.EventWriter,
), nil
}