Skip to content

Commit b434f12

Browse files
committed
Fix spurious Makefile logs when setup isn't complete
Fix issues resulting from Makefile semantics which result in statements being executed outside of the context of a rule: * Fix message logging that current-context is not set when there's no kubeconfig file (e.g. in CI). This checks if we're in minikube only. * Fix message warning that operator-sdk is not installed on every invocation; only print warning if a rule requires operator-sdk Signed-off-by: Angel Misevski <[email protected]>
1 parent 1ae4001 commit b434f12

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Makefile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ PLATFORM := kubernetes
5050
endif
5151

5252
# minikube handling
53-
ifeq ($(shell $(K8S_CLI) config current-context),minikube)
53+
ifeq ($(shell $(K8S_CLI) config current-context 2>&1),minikube)
5454
export ROUTING_SUFFIX := $(shell minikube ip).nip.io
5555
endif
5656

@@ -340,6 +340,18 @@ KUSTOMIZE=$(shell which kustomize)
340340
endif
341341

342342
_operator_sdk:
343+
@{ \
344+
if ! command -v operator-sdk &> /dev/null; then \
345+
echo 'operator-sdk $(OPERATOR_SDK_VERSION) is expected to be used for this target but it is not installed' ;\
346+
exit 1 ;\
347+
else \
348+
SDK_VER=$$(operator-sdk version | cut -d , -f 1 | cut -d : -f 2 | cut -d \" -f 2) && \
349+
if [ "$${SDK_VER}" != $(OPERATOR_SDK_VERSION) ]; then \
350+
echo "WARN: operator-sdk $(OPERATOR_SDK_VERSION) is expected to be used for this target but $${SDK_VER} found"
351+
echo "WARN: Please use the recommended operator-sdk if you face any issue"
352+
fi \
353+
fi \
354+
}
343355
ifneq ($(shell operator-sdk version | cut -d , -f 1 | cut -d : -f 2 | cut -d \" -f 2),$(OPERATOR_SDK_VERSION))
344356
@echo 'WARN: operator-sdk $(OPERATOR_SDK_VERSION) is expected to be used for this target but $(shell operator-sdk version | cut -d , -f 1 | cut -d : -f 2 | cut -d \" -f 2) found.'
345357
@echo 'WARN: Please use the recommended operator-sdk if you face any issue.'

0 commit comments

Comments
 (0)