-
Notifications
You must be signed in to change notification settings - Fork 359
/
install.go
65 lines (52 loc) · 1.52 KB
/
install.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
package cmd
import (
"os"
"path/filepath"
"github.com/covexo/devspace/pkg/util/envutil"
"github.com/covexo/devspace/pkg/util/log"
helmClient "github.com/covexo/devspace/pkg/devspace/helm"
"github.com/covexo/devspace/pkg/devspace/config/v1"
"github.com/spf13/cobra"
"k8s.io/client-go/kubernetes"
)
// InstallCmd is a struct that defines a command call for "install"
type InstallCmd struct {
flags *InstallCmdFlags
helm *helmClient.ClientWrapper
kubectl *kubernetes.Clientset
dsConfig *v1.DevSpaceConfig
}
// InstallCmdFlags are the flags available for the install-command
type InstallCmdFlags struct {
}
func init() {
cmd := &InstallCmd{
flags: &InstallCmdFlags{},
}
cobraCmd := &cobra.Command{
Use: "install",
Short: "Installs the DevSpace CLI",
Long: `
#######################################################
################## devspace install ###################
#######################################################
Registers the devspace executable in your PATH
variable.
#######################################################`,
Args: cobra.NoArgs,
Run: cmd.Run,
}
rootCmd.AddCommand(cobraCmd)
}
// Run executes the command logic
func (cmd *InstallCmd) Run(cobraCmd *cobra.Command, args []string) {
executablePath, err := os.Executable()
if err != nil {
log.Fatalf("Unable to get executable path: %s", err)
}
executableDir := filepath.Dir(executablePath)
err = envutil.AddToPath(executableDir)
if err != nil {
log.Fatalf("Unable to add devspace install dir to path: %s", err)
}
}