(hook *latest.HookConfig)
| 210 | } |
| 211 | |
| 212 | func 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 { |
no test coverage detected