MCPcopy Index your code
hub / github.com/cortexlabs/cortex / init

Function init

cli/cmd/root.go:53–122  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

51)
52
53func init() {
54 cwd, err := os.Getwd()
55 if err != nil {
56 err := errors.Wrap(err, "unable to determine current working directory")
57 exit.Error(err)
58 }
59 _cwd = s.EnsureSuffix(cwd, "/")
60
61 homeDir, err := homedir.Dir()
62 if err != nil {
63 err := errors.Wrap(err, "unable to determine home directory")
64 exit.Error(err)
65 }
66 _homeDir = s.EnsureSuffix(homeDir, "/")
67
68 _localDir = os.Getenv("CORTEX_CLI_CONFIG_DIR")
69 if _localDir != "" {
70 _localDir = files.UserRelToAbsPath(_localDir)
71 } else {
72 _localDir = filepath.Join(homeDir, ".cortex")
73 }
74
75 err = os.MkdirAll(_localDir, os.ModePerm)
76 if err != nil {
77 err := errors.Wrap(err, "unable to write to home directory", _localDir)
78 exit.Error(err)
79 }
80
81 // ~/.cortex/credentials/
82 _credentialsCacheDir = filepath.Join(_localDir, "credentials")
83 err = os.MkdirAll(_credentialsCacheDir, os.ModePerm)
84 if err != nil {
85 err := errors.Wrap(err, "unable to write to home directory", _localDir)
86 exit.Error(err)
87 }
88
89 _cliConfigPath = filepath.Join(_localDir, "cli.yaml")
90 _clientIDPath = filepath.Join(_localDir, "client-id.txt")
91 _emailPath = filepath.Join(_localDir, "email.txt")
92 _debugPath = filepath.Join(_localDir, "cortex-debug.tgz")
93
94 cobra.EnablePrefixMatching = true
95
96 _cmdStr = "cortex"
97 for _, arg := range os.Args[1:] {
98 if arg == "-w" || arg == "--watch" {
99 continue
100 }
101 _cmdStr += " " + arg
102 }
103
104 enableTelemetry, err := readTelemetryConfig()
105 if err != nil {
106 exit.Error(err)
107 }
108 if enableTelemetry {
109 initTelemetry()
110 }

Callers

nothing calls this directly

Calls 15

WrapFunction · 0.92
ErrorFunction · 0.92
UserRelToAbsPathFunction · 0.92
readTelemetryConfigFunction · 0.85
initTelemetryFunction · 0.85
clusterInitFunction · 0.85
completionInitFunction · 0.85
deleteInitFunction · 0.85
describeInitFunction · 0.85
deployInitFunction · 0.85
envInitFunction · 0.85
getInitFunction · 0.85

Tested by

no test coverage detected