Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Commit

Permalink
Merge pull request #149 from hazelops/feature/check-dependencies
Browse files Browse the repository at this point in the history
Ensures that all dependencies are installed
  • Loading branch information
igorkotof authored Dec 7, 2021
2 parents a2f0d46 + dd76f83 commit b1523a4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 17 deletions.
36 changes: 28 additions & 8 deletions init.mk
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,39 @@ confirm:
########################################################################################################################
# Core Dependencies
GIT ?= $(shell which git)
DOCKER ?= $(shell which docker)
DOCKER ?= $(shell which docker)
AWS_CLI ?= $(shell which aws)

# Ensures that all dependencies are installed
prereqs: git docker aws-cli ssh-pub-key

docker:
ifeq (, $(DOCKER))
@echo "\033[31mX Docker is not installed or incorrectly configured. https://www.docker.com/ \033[0m"
else
@echo "\033[32m✔ Docker\033[0m"
endif

# Ensures git is installed - does not enforce version, please use latest
git:
ifeq (, $(GIT))
$(error "Docker is not installed or incorrectly configured. https://www.docker.com/")
#else
# @$(DOCKER) --version
@echo "\033[31mX Git is not installed or incorrectly configured. https://git-scm.com/downloads/ \033[0m"
else
@echo "\033[32m✔ Git\033[0m"
endif

EXECUTABLES = $(GIT) $(DOCKER) aws
K := $(foreach exec,$(EXECUTABLES),\
$(if $(shell which $(exec)),some string,$(error "No $(exec) found in PATH. Please install it.")))
aws-cli:
ifeq (, $(AWS_CLI))
@echo "\033[31mX AWS (CLI) is not installed or incorrectly configured. https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html/ \033[0m"
else
@echo "\033[32m✔ AWS (CLI)\033[0m"
endif

ssh-pub-key:
ifeq (,$(wildcard ~/.ssh/id_rsa.pub))
@echo "\033[31m! SSH Public Key is not found here: ~/.ssh/id_rsa.pub . Please make sure that you have a key and pass it via '$(SSH_PUBLIC_KEY)' variable. \033[0m"
else
@echo "\033[32m✔ SSH Public Key\033[0m"
endif

# This ensures we include main.mk and variables.mk only if it's there. If not we don't error out (IE in case of bootstrap)
-include $(INFRA_DIR)/icmk/variables.mk
Expand Down
10 changes: 1 addition & 9 deletions main.mk
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ SERVICE_NAME ?= $(ENV)-$(SVC)
.PHONY: auth help
all: help

env.debug: icmk.debug os.debug aws.debug
env.debug: prereqs icmk.debug os.debug aws.debug
icmk.debug:
@echo "\033[32m=== ICMK Info ===\033[0m"
@echo "\033[36mENV\033[0m: $(ENV)"
Expand Down Expand Up @@ -124,14 +124,6 @@ ECHO = @echo

# Dependencies
########################################################################################################################
# Ensures docker is installed - does not enforce version, please use latest
docker:
ifeq (, $(DOCKER))
$(error "Docker is not installed or incorrectly configured. https://www.docker.com/")
#else
# @$(DOCKER) --version
endif

# Ensures docker-compose is installed - does not enforce.
docker-compose: docker
ifeq (, $(COMPOSE))
Expand Down

0 comments on commit b1523a4

Please sign in to comment.