Skip to content

Commit

Permalink
chore: standardize on ls subcommand when interacting with the docker …
Browse files Browse the repository at this point in the history
…binary

The ls command is what is referenced in the --help output for the subcommands, so we should just use that everywhere.
  • Loading branch information
josegonzalez committed Jul 1, 2023
1 parent e465e23 commit 3541ba2
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions plugins/builder/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func listImagesByAppLabel(appName string) ([]string, error) {
command := []string{
common.DockerBin(),
"image",
"list",
"ls",
"--quiet",
"--filter",
fmt.Sprintf("label=com.dokku.app-name=%v", appName),
Expand All @@ -40,7 +40,7 @@ func listImagesByImageRepo(imageRepo string) ([]string, error) {
command := []string{
common.DockerBin(),
"image",
"list",
"ls",
"--quiet",
imageRepo,
}
Expand Down
4 changes: 2 additions & 2 deletions plugins/common/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ func ListDanglingImages(appName string) ([]string, error) {
command := []string{
DockerBin(),
"image",
"list",
"ls",
"--quiet",
"--filter",
"dangling=true",
Expand Down Expand Up @@ -360,7 +360,7 @@ func DockerFilterContainers(filters []string) ([]string, error) {
command := []string{
DockerBin(),
"container",
"list",
"ls",
"--quiet",
"--all",
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/network/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func networkExists(networkName string) (bool, error) {

// listNetworks returns a list of docker networks
func listNetworks() ([]string, error) {
b, err := sh.Command(common.DockerBin(), "network", "list", "--format", "{{ .Name }}").Output()
b, err := sh.Command(common.DockerBin(), "network", "ls", "--format", "{{ .Name }}").Output()
output := strings.TrimSpace(string(b[:]))

networks := []string{}
Expand Down
2 changes: 1 addition & 1 deletion plugins/scheduler-docker-local/core-post-deploy
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ trigger-scheduler-docker-local-core-post-deploy() {
local NAME="$APP.$DYNO"
local CURRENT_CONTAINER_ID="$(<"$container")"
# TODO: Ensure these are from the current service
local PREVIOUS_CIDS=$("$DOCKER_BIN" container list --all --quiet --filter name="^.?$NAME\$" | xargs) || true
local PREVIOUS_CIDS=$("$DOCKER_BIN" container ls --all --quiet --filter name="^.?$NAME\$" | xargs) || true
if [[ -n $PREVIOUS_CIDS ]]; then
dokku_log_verbose_quiet "Found previous container(s) ($PREVIOUS_CIDS) named $NAME"
# in case $PREVIOUS_CIDS has more than one entry
Expand Down
2 changes: 1 addition & 1 deletion plugins/scheduler-docker-local/scheduler-pre-restore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ trigger-scheduler-docker-local-scheduler-pre-restore() {

# delete all "old" containers
# shellcheck disable=SC2046
"$DOCKER_BIN" container rm $("$DOCKER_BIN" container list --all --format "{{.Names}}" --filter "label=$DOKKU_CONTAINER_LABEL" --quiet | grep -E '(.+\..+\.[0-9]+\.[0-9]+$)') &>/dev/null || true
"$DOCKER_BIN" container rm $("$DOCKER_BIN" container ls --all --format "{{.Names}}" --filter "label=$DOKKU_CONTAINER_LABEL" --quiet | grep -E '(.+\..+\.[0-9]+\.[0-9]+$)') &>/dev/null || true
}

trigger-scheduler-docker-local-scheduler-pre-restore "$@"

0 comments on commit 3541ba2

Please sign in to comment.