-
Notifications
You must be signed in to change notification settings - Fork 11
/
repeat.go
50 lines (38 loc) · 878 Bytes
/
repeat.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
/*
* Copyright (c) 2023-present Sigma-Soft, Ltd.
* @author Dmitry Molchanovsky
*/
package main
import (
"github.com/spf13/cobra"
)
func newRepeatCmd() *cobra.Command {
repeatCmd := &cobra.Command{
Use: "repeat",
Short: "executing the last incomplete command",
RunE: repeat,
}
if newCluster().Edition != clusterEditionCE && !addSshKeyFlag(repeatCmd) {
return nil
}
return repeatCmd
}
func repeat(cmd *cobra.Command, arg []string) error {
cluster := newCluster()
var err error
if !cluster.existsNodeError() && (cluster.Cmd == nil || cluster.Cmd.isEmpty()) {
return ErrNoIncompleteCommandWasFoundToRepeat
}
err = cluster.checkVersion()
if err != nil {
return err
}
// nolint
defer cluster.saveToJSON()
// nolint
mkCommandDirAndLogFile(cmd, cluster)
if err = cluster.Cmd.apply(cluster); err != nil {
loggerError(err)
}
return err
}