[VOL-5358] - misc edits needed to support repo:onf-make use.
config.mk
---------
- Simple copyright notice update.
makefiles/commands/include.mk
makefiles/commands/kubectl/include.mk
-------------------------------------y
- Added a central installer for the kubectl command.
- Rename commands 'help::' target to commands-help.
- Default help is growing long in the stream.
makefiles/commands/kail/include.mk
makefiles/commands/pre-commit/
makefiles/commands/tox/tox.mk
----------------------------------
- Update copyright notice
- Changed default help target to target commands-help and define
{command-name}-help for individual targets. Default help target
is beginning to grow long displaying everything.
makefiles/docker/include.mk
---------------------------
- Update include docker config file (directory mount paths) to also load
the config from lf/local/docker/config/include.mk to avoid storing
all custom repo configs in repo:onf-make.
Signed-off-by: Joey Armstrong <jarmstrong@linuxfoundation.org>
Change-Id: I075be7c710bd7308ce258109455cc2ea2a3ae780
diff --git a/makefiles/commands/include.mk b/makefiles/commands/include.mk
index 72ea975..3f37981 100644
--- a/makefiles/commands/include.mk
+++ b/makefiles/commands/include.mk
@@ -25,10 +25,15 @@
$(if $(DEBUG),$(warning ENTER))
include $(onf-mk-dir)/commands/kail/include.mk
+ include $(onf-mk-dir)/commands/kubectl/include.mk
include $(onf-mk-dir)/commands/pre-commit/include.mk
include $(onf-mk-dir)/commands/tox/include.mk
$(if $(DEBUG),$(warning LEAVE))
+help ::
+ @printf ' %-33.33s %s\n' 'commands-help' \
+ 'Display verbose help for targets makefiles/commands/*'
+
mk-include--onf-commands := true
endif # mk-include--onf-commands
diff --git a/makefiles/commands/kail/include.mk b/makefiles/commands/kail/include.mk
index 3dccf1a..48b7238 100644
--- a/makefiles/commands/kail/include.mk
+++ b/makefiles/commands/kail/include.mk
@@ -22,14 +22,6 @@
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
@@ -48,4 +40,15 @@
.PHONY: kail
kail : $(kail-cmd)
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
+commands-help :: kail-help
+
+.PHONY: kail-help
+kail-help ::
+ @echo " kail Install the kail command"
+ifdef VERBOSE
+ @echo " make kail KAIL_PATH="
+endif
+
# [EOF]
diff --git a/makefiles/commands/kubectl/include.mk b/makefiles/commands/kubectl/include.mk
new file mode 100644
index 0000000..e22e4d1
--- /dev/null
+++ b/makefiles/commands/kubectl/include.mk
@@ -0,0 +1,138 @@
+# -*- 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
+# -----------------------------------------------------------------------
+
+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-versions += v1.31.0
+
+# kubectl-ver ?= v1.23# # voltha v2.12 (?)
+kubectl-ver ?= v1.31.0# # 2024-08-23: 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
+# -----------------------------------------------------------------------
+# [NOTE] Remove --no-progress-meter switch for now, not supporte by
+# curl in ubuntu 18.04-LTS.
+# -----------------------------------------------------------------------
+$(kubectl-ver-cmd):
+
+# $(call banner,(kubectl install: $(kubectl-ver)))
+ @echo "kubectl install: $(kubectl-ver)"
+
+ @mkdir --mode 0755 -p $(dir $@)
+
+ curl \
+ --output $@ \
+ --location "$(kube-url)"
+
+ @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
+## -----------------------------------------------------------------------
+commands-help :: kubectl-help
+
+.PHONY: kubectl-help
+kubectl-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/makefiles/commands/pre-commit/pre-commit.mk b/makefiles/commands/pre-commit/pre-commit.mk
index 0bb075d..6b59a0c 100644
--- a/makefiles/commands/pre-commit/pre-commit.mk
+++ b/makefiles/commands/pre-commit/pre-commit.mk
@@ -29,17 +29,12 @@
## -----------------------------------------------------------------------
## -----------------------------------------------------------------------
-help ::
- @printf ' %-33.33s %s\n' 'pre-commit' \
- 'Invoke command pre-commit'
- @printf ' %-33.33s %s\n' 'pre-commit-help' \
- 'Display extended target help (pre-commit-*)'
+commands-help :: pre-commit-help
-## -----------------------------------------------------------------------
-## -----------------------------------------------------------------------
-tox-help ::
- @printf ' %-33.33s %s\n' 'tox-run' \
- 'Self documenting alias for command tox'
+.PHONY: pre-commit-help
+pre-commit-help ::
+ @printf ' %-33.33s %s\n' 'pre-commit-install' \
+ 'Invoke the pre-commit hook linting tool'
$(if $(DEBUG),$(warning LEAVE))
diff --git a/makefiles/commands/tox/tox.mk b/makefiles/commands/tox/tox.mk
index e542d6a..c0ad741 100644
--- a/makefiles/commands/tox/tox.mk
+++ b/makefiles/commands/tox/tox.mk
@@ -28,7 +28,7 @@
## -----------------------------------------------------------------------
## Intent: Invoke the tox command
## -----------------------------------------------------------------------
-tox run-tox : tox-version
+tox run-tox tox-run : tox-version
$(activate) && tox $(tox-args)
## -----------------------------------------------------------------------
@@ -39,15 +39,12 @@
## -----------------------------------------------------------------------
## -----------------------------------------------------------------------
-help ::
+commands-help :: tox-help
+
+.PHONY: tox-help
+tox-help ::
@printf ' %-33.33s %s\n' 'tox' \
'Invoke tox (python test automation)'
- @printf ' %-33.33s %s\n' 'tox-help' \
- 'Display extended target help (tox-*)'
-
-## -----------------------------------------------------------------------
-## -----------------------------------------------------------------------
-tox-help ::
@printf ' %-33.33s %s\n' 'tox-run' \
'Self documenting alias for command tox'
diff --git a/makefiles/docker/include.mk b/makefiles/docker/include.mk
index 958cd35..1561782 100644
--- a/makefiles/docker/include.mk
+++ b/makefiles/docker/include.mk
@@ -22,14 +22,24 @@
$(if $(DEBUG),$(warning ENTER))
-# Per-repository
-include $(onf-mk-dir)/docker/config/$(--repo-name--).mk
-
# ------------------- ##
# ---] GLOBALS [--- ##
# ------------------- ##
VOLTHA_TOOLS_VERSION ?= 2.4.0
+# -------------------- ##
+# ---] INCLUDES [--- ##
+# -------------------- ##
+# include $(onf-mk-dir)/docker/help.mk
+
+# -----------------------------------------------------------------------
+# Load per-repository config: docker mount points, etc
+# -----------------------------------------------------------------------
+include $(firstword $(wildcard \
+ $(local-mk-dir)/docker/config/include.mk \
+ $(onf-mk-dir)/docker/config/$(--repo-name--).mk \
+))
+
# ---------------------------------
# Induce error for misconfiguration
# ---------------------------------