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
389 | 389 |
--no-interpolate Don't interpolate environment variables.
|
390 | 390 |
-q, --quiet Only validate the configuration, don't print
|
391 | 391 |
anything.
|
|
392 |
--profiles Print the profile names, one per line.
|
392 | 393 |
--services Print the service names, one per line.
|
393 | 394 |
--volumes Print the volume names, one per line.
|
394 | 395 |
--hash="*" Print the service config hash, one per line.
|
|
406 | 407 |
image_digests = image_digests_for_project(self.project)
|
407 | 408 |
|
408 | 409 |
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)))
|
409 | 419 |
return
|
410 | 420 |
|
411 | 421 |
if options['--services']:
|
137 | 137 |
;;
|
138 | 138 |
esac
|
139 | 139 |
|
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" ) )
|
141 | 141 |
}
|
142 | 142 |
|
143 | 143 |
|
|
169 | 169 |
;;
|
170 | 170 |
--log-level)
|
171 | 171 |
COMPREPLY=( $( compgen -W "debug info warning error critical" -- "$cur" ) )
|
|
172 |
return
|
|
173 |
;;
|
|
174 |
--profile)
|
|
175 |
COMPREPLY=( $( compgen -W "$(__docker_compose_q config --profiles)" -- "$cur" ) )
|
172 | 176 |
return
|
173 | 177 |
;;
|
174 | 178 |
--project-directory)
|
|
617 | 621 |
--tlskey
|
618 | 622 |
"
|
619 | 623 |
|
620 | |
# These options are require special treatment when searching the command.
|
|
624 |
# These options require special treatment when searching the command.
|
621 | 625 |
local top_level_options_with_args="
|
622 | 626 |
--ansi
|
623 | 627 |
--log-level
|
|
628 |
--profile
|
624 | 629 |
"
|
625 | 630 |
|
626 | 631 |
COMPREPLY=()
|
235 | 235 |
|
236 | 236 |
result = self.dispatch(['-H=tcp://doesnotexist:8000', 'ps'], returncode=1)
|
237 | 237 |
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'}
|
238 | 243 |
|
239 | 244 |
def test_config_list_services(self):
|
240 | 245 |
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
|