(ctx devspacecontext.Context, hook *latest.HookConfig, extraEnv map[string]string)
| 39 | } |
| 40 | |
| 41 | func (r *remoteHook) Execute(ctx devspacecontext.Context, hook *latest.HookConfig, extraEnv map[string]string) error { |
| 42 | if ctx.KubeClient() == nil { |
| 43 | return errors.Errorf("Cannot execute hook '%s': kube client is not initialized", ansi.Color(hookName(hook), "white+b")) |
| 44 | } |
| 45 | |
| 46 | var ( |
| 47 | imageSelectors []imageselector.ImageSelector |
| 48 | err error |
| 49 | ) |
| 50 | if hook.Container.ImageSelector != "" { |
| 51 | if ctx.Config() == nil || ctx.Config().LocalCache() == nil { |
| 52 | return errors.Errorf("Cannot execute hook '%s': config is not loaded", ansi.Color(hookName(hook), "white+b")) |
| 53 | } |
| 54 | |
| 55 | if hook.Container.ImageSelector != "" { |
| 56 | imageSelector, err := runtimevar.NewRuntimeResolver(ctx.WorkingDir(), true).FillRuntimeVariablesAsImageSelector(ctx.Context(), hook.Container.ImageSelector, ctx.Config(), ctx.Dependencies()) |
| 57 | if err != nil { |
| 58 | return err |
| 59 | } |
| 60 | |
| 61 | imageSelectors = append(imageSelectors, *imageSelector) |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | executed, err := r.execute(ctx, hook, imageSelectors) |
| 66 | if err != nil { |
| 67 | return err |
| 68 | } else if !executed { |
| 69 | ctx.Log().Infof("Skip hook '%s', because no running containers were found", ansi.Color(hookName(hook), "white+b")) |
| 70 | } |
| 71 | |
| 72 | return nil |
| 73 | } |
| 74 | |
| 75 | func (r *remoteHook) execute(ctx devspacecontext.Context, hook *latest.HookConfig, imageSelector []imageselector.ImageSelector) (bool, error) { |
| 76 | labelSelector := "" |
nothing calls this directly
no test coverage detected