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

Function hookName

pkg/devspace/hook/hook.go:212–296  ·  view source on GitHub ↗
(hook *latest.HookConfig)

Source from the content-addressed store, hash-verified

210}
211
212func hookName(hook *latest.HookConfig) string {
213 if hook.Name != "" {
214 return hook.Name
215 }
216 if hook.Command != "" {
217 commandString := strings.TrimSpace(hook.Command + " " + strings.Join(hook.Args, " "))
218 splitted := strings.Split(commandString, "\n")
219 if len(splitted) > 1 {
220 return splitted[0] + "..."
221 }
222
223 return commandString
224 }
225 if hook.Upload != nil && hook.Container != nil {
226 localPath := "."
227 if hook.Upload.LocalPath != "" {
228 localPath = hook.Upload.LocalPath
229 }
230 containerPath := "."
231 if hook.Upload.ContainerPath != "" {
232 containerPath = hook.Upload.ContainerPath
233 }
234
235 if hook.Container.Pod != "" {
236 return fmt.Sprintf("copy %s to pod %s", localPath, hook.Container.Pod)
237 }
238 if len(hook.Container.LabelSelector) > 0 {
239 return fmt.Sprintf("copy %s to selector %s", localPath, labels.Set(hook.Container.LabelSelector).String())
240 }
241 if hook.Container.ImageSelector != "" {
242 return fmt.Sprintf("copy %s to image %s", localPath, hook.Container.ImageSelector)
243 }
244
245 return fmt.Sprintf("copy %s to %s", localPath, containerPath)
246 }
247 if hook.Download != nil && hook.Container != nil {
248 localPath := "."
249 if hook.Download.LocalPath != "" {
250 localPath = hook.Download.LocalPath
251 }
252 containerPath := "."
253 if hook.Download.ContainerPath != "" {
254 containerPath = hook.Download.ContainerPath
255 }
256
257 if hook.Container.Pod != "" {
258 return fmt.Sprintf("download from pod %s to %s", hook.Container.Pod, localPath)
259 }
260 if len(hook.Container.LabelSelector) > 0 {
261 return fmt.Sprintf("download from selector %s to %s", labels.Set(hook.Container.LabelSelector).String(), localPath)
262 }
263 if hook.Container.ImageSelector != "" {
264 return fmt.Sprintf("download from image %s to %s", hook.Container.ImageSelector, localPath)
265 }
266
267 return fmt.Sprintf("download from container:%s to local:%s", containerPath, localPath)
268 }
269 if hook.Logs != nil && hook.Container != nil {

Callers 8

ExecuteRemotelyMethod · 0.85
ExecuteRemotelyMethod · 0.85
ExecuteMethod · 0.85
executeMethod · 0.85
ExecuteRemotelyMethod · 0.85
ExecuteRemotelyMethod · 0.85
executeHookFunction · 0.85
ExecuteMethod · 0.85

Calls 2

StringMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected