[VOL-5358] - build & test repo using new AMI image

lf/local/include.mk
lf/onf-make/makefiles/etc/include.mk
------------------------------------
  o Include etc/features.mk early for access to macros: banner, banner-enter, banner-leave.

.gitignore
lf/local/commands/include.mk
lf/local/commands/kubectl.mk
-------------------------------------------
  o repo:voltha-openolt-adapter jobs failing due to kubectl being mia.
  o Jobs succeded by coincidence: ./kubectl or /usr/local/bin/kubectl would be used.
  o Problematic, different or stale command versions can be used.
  o Add logic to support a central installer for the kubectl command.
  o This will provide a consistent version & program behavior for the entire job run.

Change-Id: I301e7288b2910ac30f8e148c91a31a3c09b37022
diff --git a/.gitignore b/.gitignore
index 3ace541..a892921 100644
--- a/.gitignore
+++ b/.gitignore
@@ -46,4 +46,6 @@
 a.out
 archives/
 
+bin/kubectl*
+
 # [EOF]
diff --git a/lf/local/commands/include.mk b/lf/local/commands/include.mk
new file mode 100644
index 0000000..72c06d0
--- /dev/null
+++ b/lf/local/commands/include.mk
@@ -0,0 +1,36 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2022-2024 Open Networking Foundation (ONF) and the ONF Contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-FileCopyrightText: 2024 Open Networking Foundation (ONF) and the ONF Contributors
+# SPDX-License-Identifier: Apache-2.0
+# -----------------------------------------------------------------------
+# https://gerrit.opencord.org/plugins/gitiles/onf-make
+# ONF.makefile.version = 1.0
+# -----------------------------------------------------------------------
+
+$(if $(DEBUG),$(warning ENTER))
+
+##-------------------##
+##---]  TARGETS  [---##
+##-------------------##
+
+# [TODO] Relocate kail.mk here, cleanup needed
+# include $(onf-mk-loc)/commands/kail.mk
+include $(onf-mk-loc)/commands/kubectl.mk
+
+$(if $(DEBUG),$(warning LEAVE))
+
+# [EOF]
diff --git a/lf/local/commands/kail.mk b/lf/local/commands/kail.mk
new file mode 100644
index 0000000..158554f
--- /dev/null
+++ b/lf/local/commands/kail.mk
@@ -0,0 +1,46 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2022-2024 Open Networking Foundation (ONF) and the ONF Contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# -----------------------------------------------------------------------
+
+MAKEDIR ?= $(error MAKEDIR= is required)
+
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
+help::
+	@echo "  kail            Install the kail command"
+ifdef VERBOSE
+	@echo "                  make kail KAIL_PATH="
+endif
+
+# -----------------------------------------------------------------------
+# Install the 'kail' tool if needed: https://github.com/boz/kail
+#   o WORKSPACE - jenkins aware
+#   o Default to /usr/local/bin/kail
+#       + revisit this, system directories should not be a default path.
+#       + requires sudo and potential exists for overwrite conflict.
+# -----------------------------------------------------------------------
+KAIL_PATH ?= $(if $(WORKSPACE),$(WORKSPACE)/bin,/usr/local/bin)
+kail-cmd  ?= $(KAIL_PATH)/kail
+$(kail-cmd):
+	etc/godownloader.sh -b .
+	rsync -v --checksum kail "$@"
+	$@ version
+	$(RM) kail
+
+.PHONY: kail
+kail : $(kail-cmd)
+
+# [EOF]
diff --git a/lf/local/commands/kubectl.mk b/lf/local/commands/kubectl.mk
new file mode 100644
index 0000000..cd27527
--- /dev/null
+++ b/lf/local/commands/kubectl.mk
@@ -0,0 +1,134 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2024 Open Networking Foundation Contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# -----------------------------------------------------------------------
+# SPDX-FileCopyrightText: 2024 Open Networking Foundation Contributors
+# SPDX-License-Identifier: Apache-2.0
+# -----------------------------------------------------------------------
+# Intent: Centralized logic for installing the kubectl command
+# -----------------------------------------------------------------------
+
+export .DEFAULT_GOAL := help
+
+MAKEDIR ?= $(error MAKEDIR= is required)
+
+# -----------------------------------------------------------------------
+# Install command by version to prevent one bad download from
+# taking all jobs out of action.  Do not rely on /usr/local/bin/kubectl,
+# command can easily become stagnant.
+# -----------------------------------------------------------------------
+
+# Supported versions
+kubectl-versions	+= v1.23
+kubectl-versions	+= v1.30.3
+
+# kubectl-ver         ?= v1.23#          # voltha v2.12 (?)
+kubectl-ver         ?= v1.30.3#          # 2024-07-22: latest release
+kubectl-ver		    ?= $(shell curl -L -s https://dl.k8s.io/release/stable.txt)
+kubectl-ver			?= $(error kubectl-ver= is required)
+
+kube-url			:= https://dl.k8s.io/release/$(kubectl-ver)/bin/linux/amd64/kubectl
+
+# -----------------------------------------------------------------------
+# Install the 'kubectl' tool if needed: https://github.com/boz/kubectl
+#   o WORKSPACE - jenkins aware
+#   o Default to /usr/local/bin/kubectl
+#       + revisit this, system directories should not be a default path.
+#       + requires sudo and potential exists for overwrite conflict.
+# -----------------------------------------------------------------------
+KUBECTL_PATH	?= $(if $(WORKSPACE),$(WORKSPACE)/bin,/usr/local/bin)
+kubectl-cmd		?= $(KUBECTL_PATH)/kubectl
+kubectl-ver-cmd	:= $(kubectl-cmd).$(kubectl-ver)
+
+# -----------------------------------------------------------------------
+# 1) Generic target for installing kubectl
+# -----------------------------------------------------------------------
+.PHONY: kubectl
+kubectl : $(kubectl-cmd) $(kubectl-version)
+
+# -----------------------------------------------------------------------
+# 2) Activate by copying the version approved by voltha release into place.
+#    bin/kubectl.123
+#    bin/kubectl.456
+#    cp bin/kubectl.123 bin/kubectl
+# -----------------------------------------------------------------------
+$(kubectl-cmd) : $(kubectl-ver-cmd)
+
+	$(call banner-enter,Target $@ (ver=$(kubectl-ver)))
+	ln -fns $< $@
+	$(call banner-leave,Target $@ (ver=$(kubectl-ver)))
+
+# -----------------------------------------------------------------------
+# 3) Intent: Download versioned kubectl into the local build directory
+# -----------------------------------------------------------------------
+$(kubectl-ver-cmd):
+
+#	$(call banner,(kubectl install: $(kubectl-ver)))
+	@echo "kubectl install: $(kubectl-ver)"
+
+	@mkdir --mode 0755 -p $(dir $@)
+
+	curl \
+	  --output $@ \
+	  --location "$(kube-url)" \
+	  --no-progress-meter
+
+	@umask 0 && chmod 0555 $@
+
+# -----------------------------------------------------------------------
+# Intent: Display command version
+# -----------------------------------------------------------------------
+# NOTE:
+#   - kubectl version requires connection to a running server.
+#   - use a simple display answer to avoid installation failure source
+# -----------------------------------------------------------------------
+kubectl-version :
+
+	@echo
+	realpath --canonicalize-existing $(kubectl-cmd)
+
+	@echo
+	-$(kubectl-cmd) version
+
+## -----------------------------------------------------------------------
+## Intent: Display target help
+## -----------------------------------------------------------------------
+help::
+	@printf '  %-33.33s %s\n' 'kubectl'       'Install the kubectl command'
+
+	@$(foreach ver,$(kubectl-versions),\
+	  @printf '  %-33.33s %s\n' 'kubectl-$(ver)' 'Install versioned kubectl' \
+	)
+
+	@printf '  %-33.33s %s\n' 'kubectl-version' \
+	  'Display installed command version'
+
+ifdef VERBOSE
+	@echo "                  make kubectl KUBECTL_PATH="
+endif
+
+## -----------------------------------------------------------------------
+## Intent: Remove binaries to force clean download and install
+## -----------------------------------------------------------------------
+clean ::
+	$(RM) $(kubectl-cmd)
+
+sterile :: clean
+	$(RM) $(kubectl-ver-cmd)
+
+# [SEE ALSO]
+# https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/
+
+# [EOF]
diff --git a/lf/local/include.mk b/lf/local/include.mk
index 1a9e5b3..9c61772 100644
--- a/lf/local/include.mk
+++ b/lf/local/include.mk
@@ -24,9 +24,13 @@
 ##---]  GLOBALS  [---##
 ##-------------------##
 
-#--------------------##
+##--------------------##
 ##---]  INCLUDES  [---##
 ##--------------------##
+# include $(onf-mk-lib)/etc/features.mk
+$(call include-once,$(onf-mk-lib)/etc/features.mk)
+
+include $(onf-mk-loc)/commands/include.mk
 
 ##-------------------##
 ##---]  TARGETS  [---##
diff --git a/makefiles/include.mk b/makefiles/include.mk
index 0db8732..96f35db 100644
--- a/makefiles/include.mk
+++ b/makefiles/include.mk
@@ -64,6 +64,7 @@
 ##-------------------##
 ##---]  TARGETS  [---##
 ##-------------------##
+$(error onf-mkdir=$(ONF_MAKEDIR))
 include $(ONF_MAKEDIR)/targets/include.mk # clean, sterile
 
 $(if $(DEBUG),$(warning LEAVE))