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

Method runPlugin

pkg/compose/plugins.go:63–106  ·  pkg/compose/plugins.go::composeService.runPlugin
(ctx context.Context, project *types.Project, service types.ServiceConfig, command string)

Source from the content-addressed store, hash-verified

61var mux sync.Mutex
62
63func (s *composeService) runPlugin(ctx context.Context, project *types.Project, service types.ServiceConfig, command string) error {
64 provider := *service.Provider
65
66 plugin, err := s.getPluginBinaryPath(provider.Type)
67 if err != nil {
68 return err
69 }
70
71 cmd, err := s.setupPluginCommand(ctx, project, service, plugin, command)
72 if err != nil {
73 return err
74 }
75 if cmd == nil {
76 return nil
77 }
78
79 variables, err := s.executePlugin(cmd, command, service)
80 if err != nil {
81 return err
82 }
83
84 if command == "stop" {
85 return nil
86 }
87
88 mux.Lock()
89 defer mux.Unlock()
90 for name, s := range project.Services {
91 if _, ok := s.DependsOn[service.Name]; ok {
92 prefix := strings.ToUpper(service.Name) + "_"
93 for key, val := range variables.prefixed {
94 s.Environment[prefix+key] = &val
95 }
96 for key, val := range variables.raw {
97 if existing, ok := s.Environment[key]; ok && (existing == nil || *existing != val) {
98 logrus.Warnf("provider %q overrides environment variable %q in service %q", service.Name, key, name)
99 }
100 s.Environment[key] = &val
101 }
102 project.Services[name] = s
103 }
104 }
105 return nil
106}
107
108func (s *composeService) executePlugin(cmd *exec.Cmd, command string, service types.ServiceConfig) (pluginVariables, error) { //nolint:gocyclo
109 var action string

Callers 3

stopMethod · 0.95
downMethod · 0.95
executeNodeMethod · 0.80

Calls 4

getPluginBinaryPathMethod · 0.95
setupPluginCommandMethod · 0.95
executePluginMethod · 0.95
LockMethod · 0.45

Tested by

no test coverage detected