MCPcopy
hub / github.com/docker/compose / handleHook

Function handleHook

cmd/compose/hooks.go:174–208  ·  view source on GitHub ↗
(ctx context.Context, args []string, w io.Writer)

Source from the content-addressed store, hash-verified

172}
173
174func handleHook(ctx context.Context, args []string, w io.Writer) error {
175 if len(args) == 0 {
176 return nil
177 }
178
179 var hookData hooks.Request
180 if err := json.Unmarshal([]byte(args[0]), &hookData); err != nil {
181 return nil
182 }
183
184 hint, ok := hooksHints[hookData.RootCmd]
185 if !ok {
186 return nil
187 }
188
189 if hint.checkFlags != nil && !hint.checkFlags(hookData.Flags) {
190 return nil
191 }
192
193 if !logsTabEnabled(ctx) {
194 return nil
195 }
196
197 var appID string
198 if hint.resolveProject {
199 appID = resolveAppID(ctx, hookData.Flags)
200 }
201
202 enc := json.NewEncoder(w)
203 enc.SetEscapeHTML(false)
204 return enc.Encode(hooks.Response{
205 Type: hooks.NextSteps,
206 Template: hint.template(appID),
207 })
208}

Calls

no outgoing calls