MCPcopy Index your code
hub / github.com/devspace-sh/devspace / RunAnalyze

Method RunAnalyze

cmd/analyze.go:60–117  ·  view source on GitHub ↗

RunAnalyze executes the functionality "devspace analyze"

(f factory.Factory, cobraCmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

58
59// RunAnalyze executes the functionality "devspace analyze"
60func (cmd *AnalyzeCmd) RunAnalyze(f factory.Factory, cobraCmd *cobra.Command, args []string) error {
61 // Set config root
62 log := f.GetLog()
63 configLoader, err := f.NewConfigLoader(cmd.ConfigPath)
64 if err != nil {
65 return err
66 }
67 configExists, err := configLoader.SetDevSpaceRoot(log)
68 if err != nil {
69 return err
70 }
71
72 // Create kubectl client
73 client, err := f.NewKubeClientFromContext(cmd.KubeContext, cmd.Namespace)
74 if err != nil {
75 return err
76 }
77
78 // Load generated config if possible
79 var localCache localcache.Cache
80 if configExists {
81 localCache, err = configLoader.LoadLocalCache()
82 if err != nil {
83 return err
84 }
85 }
86
87 // If the current kube context or namespace is different from old,
88 // show warnings and reset kube client if necessary
89 client, err = kubectl.CheckKubeContext(client, localCache, cmd.NoWarn, cmd.SwitchContext, false, log)
90 if err != nil {
91 return err
92 }
93
94 // Execute plugin hook
95 err = hook.ExecuteHooks(nil, nil, "analyze")
96 if err != nil {
97 return err
98 }
99
100 // Override namespace
101 namespace := client.Namespace()
102 if cmd.Namespace != "" {
103 namespace = cmd.Namespace
104 }
105
106 err = analyze.NewAnalyzer(client, log).Analyze(namespace, analyze.Options{
107 Wait: cmd.Wait,
108 Timeout: cmd.Timeout,
109 Patient: cmd.Patient,
110 IgnorePodRestarts: cmd.IgnorePodRestarts,
111 })
112 if err != nil {
113 return errors.Wrap(err, "analyze")
114 }
115
116 return nil
117}

Callers 1

NewAnalyzeCmdFunction · 0.95

Calls 10

SetDevSpaceRootMethod · 0.95
LoadLocalCacheMethod · 0.95
CheckKubeContextFunction · 0.92
ExecuteHooksFunction · 0.92
NewAnalyzerFunction · 0.92
GetLogMethod · 0.65
NewConfigLoaderMethod · 0.65
NamespaceMethod · 0.65
AnalyzeMethod · 0.65

Tested by

no test coverage detected