-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathup.go
More file actions
65 lines (56 loc) · 1.49 KB
/
Copy pathup.go
File metadata and controls
65 lines (56 loc) · 1.49 KB
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
package cmd
import (
"fmt"
"github.com/jakolehm/trieres/pkg/cluster"
"github.com/jakolehm/trieres/pkg/phases"
"github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
)
func UpCommand() *cli.Command {
upFlags := []cli.Flag{
&cli.StringFlag{
Name: "config",
Usage: "Specify an alternate cluster YAML file",
Value: "cluster.yml",
EnvVars: []string{"TRIERES_CONFIG"},
},
}
return &cli.Command{
Name: "up",
Usage: "Install or upgrade the cluster",
Action: clusterUp,
Flags: upFlags,
}
}
func clusterUp(ctx *cli.Context) error {
fmt.Printf("~~ Trieres (version %s) ~~\n\n", ctx.App.Version)
cluster := cluster.Config{}
configBuffer, configFile, err := resolveClusterFile(ctx)
if err != nil {
return err
}
logrus.Infof("Loading config file: %s", configFile)
cluster.FromYaml(configBuffer)
if err := cluster.Validate(); err != nil {
return fmt.Errorf("cluster.yml validation failed: %s", err)
}
if cluster.Token == "" {
random, err := GenerateRandomString(16)
if err != nil {
return err
}
cluster.Token = random
}
phaseManager := phases.NewManager(&cluster)
phaseManager.AddPhase(&phases.ConnectPhase{})
phaseManager.AddPhase(&phases.GatherHostFactsPhase{})
phaseManager.AddPhase(&phases.SetupMastersPhase{})
phaseManager.AddPhase(&phases.CopyManifestsPhase{})
phaseManager.AddPhase(&phases.SetupWorkersPhase{})
phaseManager.AddPhase(&phases.DisconnectPhase{})
phaseErr := phaseManager.Run()
if phaseErr != nil {
return phaseErr
}
return nil
}