Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker-compose plugin service names only if container exists ? #10636

Closed
adamwojt opened this issue Jan 28, 2022 · 8 comments
Closed

docker-compose plugin service names only if container exists ? #10636

adamwojt opened this issue Jan 28, 2022 · 8 comments
Labels
Area: plugin Issue or PR related to a plugin Bug Something isn't working Resolution: wontfix This will not be worked on Topic: completion Pull Request or issue regarding completion

Comments

@adamwojt
Copy link

adamwojt commented Jan 28, 2022

Describe the bug

with:

  • docker-compose up <tab>
  • docker-compose run <tab>

There seem to be no autocomplete without services actually running (after docker-compose up). Is that how the autocomplete is suppose to work? Sometimes it's needed to get autocomplete for services when nothing is actually running so that for example one could choose which services to up.

Steps to reproduce

docker-compose run <tab> without any services running.

Expected behavior

docker-compose run/up <tab> without services running should autocomplete services.

Screenshots and recordings

No response

OS / Linux distribution

Linux adam-work 5.15.13-arch1-1 #1 SMP PREEMPT Wed, 05 Jan 2022 16:20:59 +0000 x86_64 GNU/Linux

Zsh version

zsh 5.8 (x86_64-pc-linux-gnu)

Terminal emulator

kitty 0.24.1 created by Kovid Goyal

If using WSL on Windows, which version of WSL

No response

Additional context

  • Docker Compose version 2.2.3
  • omz at commit 11a87ea
  • Docker version 20.10.12, build e91ed5707e
@adamwojt
Copy link
Author

adamwojt commented Jan 28, 2022

Seems that taking this approach fixed it for me.

# All services defined in docker-compose.yml
__docker-compose_all_services_in_compose_file() {
local already_selected
local -a services
already_selected=$(echo $words | tr " " "|")
__docker-compose_q ps --services "$@" \

Change from ps to config

Perhaps this could be released?

@mcornella
Copy link
Member

We bundled the upstream completion, but it looks like they removed it in v2 and it's still not ready. That is all to say that I'm ok with a unilateral change, as long as it doesn't introduce breaking changes.

Are you willing to make a PR?

@mcornella mcornella added Area: plugin Issue or PR related to a plugin Bug Something isn't working Topic: completion Pull Request or issue regarding completion labels Jan 28, 2022
@adamwojt
Copy link
Author

adamwojt commented Jan 29, 2022

We bundled the upstream completion, but it looks like they removed it in v2 and it's still not ready. That is all to say that I'm ok with a unilateral change, as long as it doesn't introduce breaking changes.

Are you willing to make a PR?

@mcornella I could but it's not as easy as it looks actually. Having had second look on this we have some parts that rely on ps --filter, for example:

'*:services:__docker-compose_services_from_build' && ret=0

# All services that are defined by a Dockerfile reference
__docker-compose_services_from_build() {
[[ $PREFIX = -* ]] && return 1
__docker-compose_services_all --filter source=build
}

Which is impossible to filter with config but in current situation it would not complete properly anyway if services don't have their container. Also I've noticed that for v2.2.3 compose doesn't have filtering on ps via source=build anyway.

$ docker-compose ps --services --filter source=build
> not implemented

So I could make PR but we need to decide if we want to go this direction where all service based completion is taken from docker-compose config --services solely. This might be way to go, unless we want to seperate some like stop to take from ps - which would make sense as they have to be running first.

@adamwojt
Copy link
Author

@mcornella Submitted what worked for me: #10638

@adamwojt adamwojt changed the title docker-compose plugin service names only when running ? docker-compose plugin service names only if container exists ? Jan 29, 2022
@HanKruiger
Copy link

A downside of only use the services from docker-compose config --services for certain commands is that for people who like to chain commands it is not possible to autocomplete. Example:

docker-compose down && docker-compose up --build -d && docker-compose logs -f service-1

For the final part, I would be unable to auto-complete it, because at the moment of writing the command, the service service-1 will not be up yet.

Is it possible to change this behaviour with configuration?

@adamwojt
Copy link
Author

adamwojt commented Feb 9, 2022

A downside of only use the services from docker-compose config --services for certain commands is that for people who like to chain commands it is not possible to autocomplete. Example:

docker-compose down && docker-compose up --build -d && docker-compose logs -f service-1

For the final part, I would be unable to auto-complete it, because at the moment of writing the command, the service service-1 will not be up yet.

Is it possible to change this behaviour with configuration?

This is not true. Even if using docker-compose config --services you would get autocomplete for all services in the file. Have a look on my PR, I describe how I resolved this.
Also in your presented situation, exactly in current state of the plugin you would not get autocomplete as it is taken from docker-compose ps which need to have container created. Maybe you mixed ps with config ?

@HanKruiger
Copy link

Apologies if I'm misunderstanding, but in your description, it says:

  • for build, create, images, pull, push, run, up take services using docker-compose config --services (parses file), for rest: take it from docker-compose ps --services (have to have container).

This list does not include the logs command, so I assumed it still uses docker-compose ps --services.

@mcornella
Copy link
Member

Doing cleanup of old issues. I disagree with my previous statement that we could fix this on our side. Let's continue the conversation on the upstream project.

@mcornella mcornella closed this as not planned Won't fix, can't repro, duplicate, stale Apr 14, 2023
@mcornella mcornella added the Resolution: wontfix This will not be worked on label Apr 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: plugin Issue or PR related to a plugin Bug Something isn't working Resolution: wontfix This will not be worked on Topic: completion Pull Request or issue regarding completion
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants