Skip to content

Commit

Permalink
Fix docs
Browse files Browse the repository at this point in the history
Signed-off-by: Joana Hrotko <joana.hrotko@docker.com>
  • Loading branch information
jhrotko committed Mar 18, 2024
1 parent 30bebc7 commit 9ec0c08
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 2 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ RUN --mount=type=bind,target=. \
FROM build-base AS test
ARG CGO_ENABLED=0
ARG BUILD_TAGS
ENV COMPOSE_MENU=FALSE
RUN --mount=type=bind,target=. \
--mount=type=cache,target=/root/.cache \
--mount=type=cache,target=/go/pkg/mod \
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

PKG := github.com/docker/compose/v2
export COMPOSE_MENU = FALSE
VERSION ?= $(shell git describe --match 'v[0-9]*' --dirty='.m' --always --tags)

GO_LDFLAGS ?= -w -X ${PKG}/internal.Version=${VERSION}
Expand Down
5 changes: 3 additions & 2 deletions cmd/compose/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,9 @@ func upCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *c
flags.IntVar(&up.waitTimeout, "wait-timeout", 0, "Maximum duration to wait for the project to be running|healthy")
flags.BoolVarP(&up.watch, "watch", "w", false, "Watch source code and rebuild/refresh containers when files are updated.")
composeMenu := true
if os.Getenv(ComposeMenu) != "" {
composeMenu = utils.StringToBool(os.Getenv(ComposeMenu))
composeMenuEnv, err := utils.GetEnvBool(ComposeMenu)
if err != nil {
composeMenu = composeMenuEnv
}
flags.BoolVar(&up.navigationMenu, "navigation-menu", composeMenu, "While running in attach mode, enable helpful shortcuts.")

Expand Down
1 change: 1 addition & 0 deletions docs/reference/compose_up.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Create and start containers
| `--dry-run` | | | Execute command in dry run mode |
| `--exit-code-from` | `string` | | Return the exit code of the selected service container. Implies --abort-on-container-exit |
| `--force-recreate` | | | Recreate containers even if their configuration and image haven't changed |
| `--navigation-menu` | | | While running in attach mode, enable helpful shortcuts. |
| `--no-attach` | `stringArray` | | Do not attach (stream logs) to the specified services |
| `--no-build` | | | Don't build an image, even if it's policy |
| `--no-color` | | | Produce monochrome output |
Expand Down
10 changes: 10 additions & 0 deletions docs/reference/docker_compose_up.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,16 @@ options:
experimentalcli: false
kubernetes: false
swarm: false
- option: navigation-menu
value_type: bool
default_value: "false"
description: While running in attach mode, enable helpful shortcuts.
deprecated: false
hidden: false
experimental: false
experimentalcli: false
kubernetes: false
swarm: false
- option: no-attach
value_type: stringArray
default_value: '[]'
Expand Down
22 changes: 22 additions & 0 deletions pkg/utils/stringutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package utils

import (
"fmt"
"os"
"strconv"
"strings"
)
Expand All @@ -40,3 +42,23 @@ func StringToBool(s string) bool {
b, _ := strconv.ParseBool(s)
return b
}

func getEnvStr(key string) (string, error) {
v := os.Getenv(key)
if v == "" {
return v, fmt.Errorf("env var not defined")
}
return v, nil
}

func GetEnvBool(key string) (bool, error) {
s, err := getEnvStr(key)
if err != nil {
return false, err
}
v, err := strconv.ParseBool(s)
if err != nil {
return false, err
}
return v, nil
}

0 comments on commit 9ec0c08

Please sign in to comment.