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

fix(dev): fix issues when using container tools and cargo is not installed locally #18112

Merged
merged 4 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/actions/spelling/allow.txt
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ https
humungus
icecream
ifeq
ifneq
imobile
influxd
ionik
Expand Down
20 changes: 17 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@ export VERBOSE ?= false
# Override the container tool. Tries docker first and then tries podman.
export CONTAINER_TOOL ?= auto
ifeq ($(CONTAINER_TOOL),auto)
override CONTAINER_TOOL = $(shell docker version >/dev/null 2>&1 && echo docker || echo podman)
ifeq ($(shell docker version >/dev/null 2>&1 && echo docker), docker)
override CONTAINER_TOOL = docker
else ifeq ($(shell podman version >/dev/null 2>&1 && echo podman), podman)
override CONTAINER_TOOL = podman
else
override CONTAINER_TOOL = unknown
endif
endif
# If we're using podman create pods else if we're using docker create networks.
export CURRENT_DIR = $(shell pwd)
Expand All @@ -54,7 +60,7 @@ export AWS_ACCESS_KEY_ID ?= "dummy"
export AWS_SECRET_ACCESS_KEY ?= "dummy"

# Set version
export VERSION ?= $(shell cargo vdev version)
export VERSION ?= $(shell command -v cargo >/dev/null && cargo vdev version || echo unknown)

# Set if you are on the CI and actually want the things to happen. (Non-CI users should never set this.)
export CI ?= false
Expand Down Expand Up @@ -128,6 +134,7 @@ define ENVIRONMENT_EXEC
endef


ifneq ($(CONTAINER_TOOL), unknown)
ifeq ($(ENVIRONMENT_AUTOBUILD), true)
define ENVIRONMENT_PREPARE
@echo "Building the environment. (ENVIRONMENT_AUTOBUILD=true) This may take a few minutes..."
Expand All @@ -142,6 +149,11 @@ define ENVIRONMENT_PREPARE
$(CONTAINER_TOOL) pull $(ENVIRONMENT_UPSTREAM)
endef
endif
else
define ENVIRONMENT_PREPARE
$(error "Please install a container tool such as Docker or Podman")
endef
endif

.PHONY: check-container-tool
check-container-tool: ## Checks what container tool is installed
Expand Down Expand Up @@ -208,9 +220,11 @@ build-graphql-schema: ## Generate the `schema.json` for Vector's GraphQL API

.PHONY: check-build-tools
check-build-tools:
ifeq (, $(shell which cargo))
ifneq ($(ENVIRONMENT), true)
ifeq (, $(shell command -v cargo))
$(error "Please install Rust: https://www.rust-lang.org/tools/install")
endif
endif

##@ Cross Compiling
.PHONY: cross-enable
Expand Down