Make's "define" feature (macros) is subtle and it took me a long time to
convince myself this all works. In particular, we (prior to this commit)
are terribly inconsistent about the use of `$` vs `$$`. We mostly get
away with it because the "variables" are more like "constants", but the
inconsistency trips up some things. For example, using `$(shell)`
inside a macro will run at macro expansion time rather than when the
resulting make code is executed.
For a contrived, but concrete example, derived from our Makefile:
```
define MACRO
ifeq ($(DBG),1)
$(warning dbg is $(DBG))
endif
endef # macro
TGTS=a b c
$(foreach pfx, $(TGTS), $(eval $(MACRO)))
default:
@echo $@
```
yields:
```
$ make
Makefile:8: dbg is
Makefile:8: dbg is
Makefile:8: dbg is
default
$ make DBG=1
Makefile:8: dbg is 1
Makefile:8: dbg is 1
Makefile:8: dbg is 1
default
```
This is because `$(warning)` is evaluated as the macro is expanded.
Replace that with `$(shell)` and you can see how you might end up
running a bunch of things you didn't need to run. The fix is:
```
define MACRO
ifeq ($(DBG),1)
$$(warning dbg is $$(DBG))
endif
endef # macro
TGTS=a b c
$(foreach pfx, $(TGTS), $(eval $(MACRO)))
default:
@echo $@
```
which yields:
```
$ make
default
$ make DBG=1
Makefile:8: dbg is 1
Makefile:8: dbg is 1
Makefile:8: dbg is 1
default
```
We COULD have only changed `$(warning)` to `$$(warning)` and left
`$(DBG)` alone, because that's a cheap expansion. I chose NOT to do
that here because it requires brainpower to think about this all, and it
seems easier to set a simple rule: inside a `define`/`endef` block, you
always use `$$` unless you KNOW that you NEED expansion-time evaluation
(as in the `$(prefix)` in this commit, which is effectively an argument
to the macros).
Only build and run go2make on the first pass. If that generates a new
GO_PKGDEPS_FILE, make will restart the whole process and set MAKE_RESTARTS to
a numeric value.
We can use this to avoid re-running go2make, which saves a few seconds
each build.
Since removing dockershim, `make test-e2e-node` will fail by default as
there is no provided container runtime endpoint.
This commit defaults us to using containerd's default socket path as the
local test target, rather than failing hard.
Goal of this commit is to add some missing features when the
Kubernetes API is accessed through a SOCKS5 proxy. That's for
example the case when port-forwarding is used (`kubectl port-forward`)
or when exec'ing inside a container (`kubectl exec`), with this
commit it'll now be possible to use both.
Signed-off-by: Romain Aviolat <romain.aviolat@kudelskisecurity.com>
Signed-off-by: Romain Jufer <romain.jufer@kudelskisecurity.com>