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

Function executeSingle

pkg/devspace/hook/hook.go:102–136  ·  view source on GitHub ↗

executeSingle executes hooks at a specific time

(ctx devspacecontext.Context, extraEnv map[string]string, event string)

Source from the content-addressed store, hash-verified

100
101// executeSingle executes hooks at a specific time
102func executeSingle(ctx devspacecontext.Context, extraEnv map[string]string, event string) error {
103 config := ctx.Config()
104 if config == nil {
105 return nil
106 }
107
108 c := config.Config()
109 if len(c.Hooks) > 0 {
110 hooksToExecute := []*latest.HookConfig{}
111
112 // Gather all hooks we should execute
113 for _, hook := range c.Hooks {
114 for _, e := range hook.Events {
115 if e == event {
116 hooksToExecute = append(hooksToExecute, hook)
117 break
118 }
119 }
120 }
121
122 // Execute hooks
123 for _, hookConfig := range hooksToExecute {
124 if hookConfig.Disabled || !command.ShouldExecuteOnOS(hookConfig.OperatingSystem) {
125 continue
126 }
127
128 err := runHook(ctx, hookConfig, extraEnv, event)
129 if err != nil {
130 return err
131 }
132 }
133 }
134
135 return nil
136}
137
138func runHook(ctx devspacecontext.Context, hookConfig *latest.HookConfig, extraEnv map[string]string, event string) error {
139 // Determine output writer

Callers 2

LogExecuteHooksFunction · 0.85
ExecuteHooksFunction · 0.85

Calls 2

runHookFunction · 0.85
ConfigMethod · 0.65

Tested by

no test coverage detected