I'm trying to add a conditional in my Makefile to check to see if minikube ia already running, and it if is, run a target in that same Makefile. However, it appears something is wrong with how I've written the findstring argument. Here's a snippet of my code:
So when I run this in CLI: make reset-environment
Here's the output I get back, with a few comments inserted by me with the <-- arrows:
minikube type: Control Plane host: Running kubelet: Running apiserver: Running kubeconfig: Configured <-- line 48 from my code
kubeconfig <-- line 49 from my code
ifeq (kubeconfig) <-- line 50 from my code
/bin/bash: -c: line 1: syntax error near unexpected token `kubeconfig'
/bin/bash: -c: line 1: `ifeq (kubeconfig)'
make: *** [Makefile:50: reset-environment] Error 2
According to the documentation, I have the findstring part coded correctly, which appears to be validated by the output I'm getting from link 49. But I don't understand the errors I'm hitting with line 50, and beyond.
I'm tried using different strings check for equality, and tried rewriting line 50 a few different ways, but no joy.
I also tried changing line 50 to:
ifeq ($(findstring kubeconfig,$(minikube_status)),kubeconfig)
... but that just gave me slightly different errors:
ifeq (kubeconfig,kubeconfig)
/bin/bash: -c: line 1: syntax error near unexpected token `kubeconfig,kubeconfig'
/bin/bash: -c: line 1: `ifeq (kubeconfig,kubeconfig)'
make: *** [Makefile:50: reset-environment] Error 2
Turns out that the issue was all related to the indentation, which I saw from one of the related questions after I posted this: https://stackoverflow.com/a/4483467/22191886
I unindented those lines and sure enough, it works as designed. It just looks a little janky, but I'll survive.