1
0

desktop.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. Copyright 2024 Docker Compose CLI authors
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package compose
  14. import (
  15. "context"
  16. "github.com/docker/compose/v2/internal/desktop"
  17. "github.com/docker/compose/v2/internal/experimental"
  18. "github.com/sirupsen/logrus"
  19. )
  20. func (s *composeService) SetDesktopClient(cli *desktop.Client) {
  21. s.desktopCli = cli
  22. }
  23. func (s *composeService) SetExperiments(experiments *experimental.State) {
  24. s.experiments = experiments
  25. }
  26. func (s *composeService) manageDesktopFileSharesEnabled(ctx context.Context) bool {
  27. // there's some slightly redundancy here to avoid fetching the config if
  28. // we can already tell the feature state - in practice, we
  29. if !s.isDesktopIntegrationActive() || !s.experiments.AutoFileShares() {
  30. return false
  31. }
  32. fileSharesConfig, err := s.desktopCli.GetFileSharesConfig(ctx)
  33. if err != nil {
  34. logrus.Debugf("Failed to retrieve file shares config: %v", err)
  35. return false
  36. }
  37. return fileSharesConfig.Active && fileSharesConfig.Compose.ManageBindMounts
  38. }