chore: standardize on ls subcommand when interacting with the docker binary

The ls command is what is referenced in the --help output for the subcommands, so we should just use that everywhere.
This commit is contained in:
Jose Diaz-Gonzalez
2023-07-01 03:29:00 -04:00
parent 5dc2f20432
commit 4436bb2023
5 changed files with 7 additions and 7 deletions

View File

@@ -16,7 +16,7 @@ func listImagesByAppLabel(appName string) ([]string, error) {
command := []string{ command := []string{
common.DockerBin(), common.DockerBin(),
"image", "image",
"list", "ls",
"--quiet", "--quiet",
"--filter", "--filter",
fmt.Sprintf("label=com.dokku.app-name=%v", appName), fmt.Sprintf("label=com.dokku.app-name=%v", appName),
@@ -40,7 +40,7 @@ func listImagesByImageRepo(imageRepo string) ([]string, error) {
command := []string{ command := []string{
common.DockerBin(), common.DockerBin(),
"image", "image",
"list", "ls",
"--quiet", "--quiet",
imageRepo, imageRepo,
} }

View File

@@ -303,7 +303,7 @@ func ListDanglingImages(appName string) ([]string, error) {
command := []string{ command := []string{
DockerBin(), DockerBin(),
"image", "image",
"list", "ls",
"--quiet", "--quiet",
"--filter", "--filter",
"dangling=true", "dangling=true",
@@ -360,7 +360,7 @@ func DockerFilterContainers(filters []string) ([]string, error) {
command := []string{ command := []string{
DockerBin(), DockerBin(),
"container", "container",
"list", "ls",
"--quiet", "--quiet",
"--all", "--all",
} }

View File

@@ -128,7 +128,7 @@ func networkExists(networkName string) (bool, error) {
// listNetworks returns a list of docker networks // listNetworks returns a list of docker networks
func listNetworks() ([]string, error) { 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[:])) output := strings.TrimSpace(string(b[:]))
networks := []string{} networks := []string{}

View File

@@ -37,7 +37,7 @@ trigger-scheduler-docker-local-core-post-deploy() {
local NAME="$APP.$DYNO" local NAME="$APP.$DYNO"
local CURRENT_CONTAINER_ID="$(<"$container")" local CURRENT_CONTAINER_ID="$(<"$container")"
# TODO: Ensure these are from the current service # 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 if [[ -n $PREVIOUS_CIDS ]]; then
dokku_log_verbose_quiet "Found previous container(s) ($PREVIOUS_CIDS) named $NAME" dokku_log_verbose_quiet "Found previous container(s) ($PREVIOUS_CIDS) named $NAME"
# in case $PREVIOUS_CIDS has more than one entry # in case $PREVIOUS_CIDS has more than one entry

View File

@@ -14,7 +14,7 @@ trigger-scheduler-docker-local-scheduler-pre-restore() {
# delete all "old" containers # delete all "old" containers
# shellcheck disable=SC2046 # 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 "$@" trigger-scheduler-docker-local-scheduler-pre-restore "$@"