This repository has been archived by the owner on Feb 9, 2024. It is now read-only.
/
installer.go
87 lines (77 loc) · 2.65 KB
/
installer.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
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
// Copyright 2021 Gravitational Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package install
import (
"github.com/gravitational/gravity/lib/fsm"
ossinstall "github.com/gravitational/gravity/lib/install"
"github.com/gravitational/gravity/lib/install/engine"
"github.com/gravitational/gravity/lib/ops"
)
// Config defines the installer configuration
type Config struct {
// Config is the base installer configuration
ossinstall.Config
// License is optional license string
License string
// RemoteOpsURL is the URL of the remote Ops Center
RemoteOpsURL string
// RemoteOpsToken is the remote Ops Center auth token
RemoteOpsToken string
// OperationID is the ID of the operation when installing via Ops Center
OperationID string
// OpsTunnelToken is the token used when creating a trusted cluster
OpsTunnelToken string
// OpsSNIHost is the Ops Center SNI host
OpsSNIHost string
// OpsAdvertiseAddr is the Ops Center advertise address
OpsAdvertiseAddr string
}
// CheckAndSetDefaults checks the parameters and sets some defaults
func (c *Config) CheckAndSetDefaults() error {
return nil
}
// NewFSMFactory returns a new state machine factory
func NewFSMFactory(config Config) engine.FSMFactory {
return &fsmFactory{
Config: config,
}
}
// NewStateMachine creates a new state machine for the specified operator and operation.
// Implements engine.FSMFactory
func (r *fsmFactory) NewFSM(operator ops.Operator, operationKey ops.SiteOperationKey) (fsm *fsm.FSM, err error) {
config := ossinstall.NewFSMConfig(operator, operationKey, r.Config.Config)
config.Spec = FSMSpec(config)
return ossinstall.NewFSM(config)
}
type fsmFactory struct {
Config
}
// NewClusterFactory returns a factory for creating cluster requests
func NewClusterFactory(config Config, base engine.ClusterFactory) engine.ClusterFactory {
return &clusterFactory{
Config: config,
base: base,
}
}
// NewCluster creates the cluster with the specified operator
// Implements engine.ClusterFactory
func (r *clusterFactory) NewCluster() ops.NewSiteRequest {
req := r.base.NewCluster()
req.License = r.License
return req
}
type clusterFactory struct {
Config
base engine.ClusterFactory
}