Codebase list docker-compose / 84afa51
Merge pull request #8061 from albers/completion-profiles Add bash completion for profiles and a command to list profiles Chris Crone authored 3 years ago GitHub committed 3 years ago
4 changed file(s) with 37 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
389389 --no-interpolate Don't interpolate environment variables.
390390 -q, --quiet Only validate the configuration, don't print
391391 anything.
392 --profiles Print the profile names, one per line.
392393 --services Print the service names, one per line.
393394 --volumes Print the volume names, one per line.
394395 --hash="*" Print the service config hash, one per line.
406407 image_digests = image_digests_for_project(self.project)
407408
408409 if options['--quiet']:
410 return
411
412 if options['--profiles']:
413 profiles = set()
414 for service in compose_config.services:
415 if 'profiles' in service:
416 for profile in service['profiles']:
417 profiles.add(profile)
418 print('\n'.join(sorted(profiles)))
409419 return
410420
411421 if options['--services']:
137137 ;;
138138 esac
139139
140 COMPREPLY=( $( compgen -W "--hash --help --no-interpolate --quiet -q --resolve-image-digests --services --volumes" -- "$cur" ) )
140 COMPREPLY=( $( compgen -W "--hash --help --no-interpolate --profiles --quiet -q --resolve-image-digests --services --volumes" -- "$cur" ) )
141141 }
142142
143143
169169 ;;
170170 --log-level)
171171 COMPREPLY=( $( compgen -W "debug info warning error critical" -- "$cur" ) )
172 return
173 ;;
174 --profile)
175 COMPREPLY=( $( compgen -W "$(__docker_compose_q config --profiles)" -- "$cur" ) )
172176 return
173177 ;;
174178 --project-directory)
617621 --tlskey
618622 "
619623
620 # These options are require special treatment when searching the command.
624 # These options require special treatment when searching the command.
621625 local top_level_options_with_args="
622626 --ansi
623627 --log-level
628 --profile
624629 "
625630
626631 COMPREPLY=()
235235
236236 result = self.dispatch(['-H=tcp://doesnotexist:8000', 'ps'], returncode=1)
237237 assert "Couldn't connect to Docker daemon" in result.stderr
238
239 def test_config_list_profiles(self):
240 self.base_dir = 'tests/fixtures/config-profiles'
241 result = self.dispatch(['config', '--profiles'])
242 assert set(result.stdout.rstrip().split('\n')) == {'debug', 'frontend', 'gui'}
238243
239244 def test_config_list_services(self):
240245 self.base_dir = 'tests/fixtures/v2-full'
0 version: '3.8'
1 services:
2 frontend:
3 image: frontend
4 profiles: ["frontend", "gui"]
5 phpmyadmin:
6 image: phpmyadmin
7 depends_on:
8 - db
9 profiles:
10 - debug
11 backend:
12 image: backend
13 db:
14 image: mysql