(ctx context.Context, project *types.Project, service types.ServiceConfig, command string)
| 61 | var mux sync.Mutex |
| 62 | |
| 63 | func (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 | |
| 108 | func (s *composeService) executePlugin(cmd *exec.Cmd, command string, service types.ServiceConfig) (pluginVariables, error) { //nolint:gocyclo |
| 109 | var action string |
no test coverage detected