You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ts...@apache.org on 2022/10/13 07:56:38 UTC

[camel-k] 02/03: Adds a help rule to the install Makefile

This is an automated email from the ASF dual-hosted git repository.

tsato pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit dba36a864d35a45ead9c5e5151a449ee669599f8
Author: phantomjinx <p....@phantomjinx.co.uk>
AuthorDate: Wed Oct 5 18:11:49 2022 +0100

    Adds a help rule to the install Makefile
    
    * Prints each rule's description and parameters by walking the
      install/Makefile
    
    * Quietens needless kustomize messages that might cause needless
      confusion to user's trying the install
---
 install/Makefile       | 110 ++++++++++++++++++++++++++++++-------------------
 install/script/help.sh |  12 ++++++
 2 files changed, 80 insertions(+), 42 deletions(-)

diff --git a/install/Makefile b/install/Makefile
index a84e6273f..6854f83b2 100644
--- a/install/Makefile
+++ b/install/Makefile
@@ -109,15 +109,15 @@ endef
 #
 define add-remove-kind-patch
 	@(cd $(1) && \
-		$(KUSTOMIZE) edit $(2) patch --path $(3) --kind $(4))
+		$(KUSTOMIZE) edit $(2) patch --path $(3) --kind $(4) &> /dev/null)
 endef
 
 #
 # Macro for adding / removing the prometheus resources for monitoring
 #
 define add-remove-operator-monitoring
-	cd $(1) && \
-		$(KUSTOMIZE) edit $(2) resource ../$(CONFIG)/prometheus
+	@(cd $(1) && \
+		$(KUSTOMIZE) edit $(2) resource ../$(CONFIG)/prometheus &> /dev/null)
 endef
 
 .PHONY: have-platform check_admin setup-cluster .setup-kubernetes .setup-openshift setup
@@ -165,19 +165,23 @@ ifneq ($(CRD_SUPPORT),OK)
 	$(error *** CRD API FAILURE: $(CRD_SUPPORT) ****)
 endif
 
+#---
+#
+#@ setup-cluster
 #
-# Setup the cluster installation by installing crds and cluster roles.
+#== Setup the cluster installation by installing crds and cluster roles.
 #
 # Will either call setup-cluster-openshift (then setup-cluster-kubernetes) or
 # setup-cluster-kubernetes depending on the identity of the cluster
 #
-# Cluster-admin privileges are required.
+#=== Cluster-admin privileges are required.
 #
-# PARAMETERS:
-#   NAMESPACE: Sets the namespace for the resources
-#   PLATFORM:  Override the discovered platform, if required
-#   DRY_RUN:     true - Prints the resources to be applied instead of applying them
+#* PARAMETERS:
+#** NAMESPACE: Sets the namespace for the resources
+#** PLATFORM:  Override the discovered platform, if required
+#** DRY_RUN:   If 'true', prints the resources to be applied instead of applying them
 #
+#---
 setup-cluster: check-admin check-crd-api-support have-platform kustomize kubectl
 # Set the namespace in the setup-cluster kustomization yaml
 	@$(call set-kustomize-namespace,$@)
@@ -200,18 +204,22 @@ else
 		sed 's/$(PLACEHOLDER)/$(NAMESPACE)/'
 endif
 
+#---
 #
-# Setup the installation by installing roles and granting
-# privileges for the installing operator.
+#@ setup
 #
-# Cluster-admin privileges are required.
+#== Setup the installation by installing roles and granting privileges for the installing operator.
 #
-# PARAMETERS:
-#   NAMESPACE: Sets the namespace for the resources
-#   GLOBAL:    Converts all roles & bindings to cluster-level [true|false]
-#   PLATFORM:  Override the discovered platform, if required
-#   DRY_RUN:     true - Prints the resources to be applied instead of applying them
+#=== Calls setup-cluster
+#=== Cluster-admin privileges are required.
 #
+#* PARAMETERS:
+#** NAMESPACE: Sets the namespace for the resources
+#** GLOBAL:    Converts all roles & bindings to cluster-level [true|false]
+#** PLATFORM:  Override the discovered platform, if required
+#** DRY_RUN:     If 'true', prints the resources to be applied instead of applying them
+#
+#---
 setup: setup-cluster
 # Set the namespace in the setup kustomization yaml
 	@$(call set-kustomize-namespace,$@)
@@ -262,24 +270,28 @@ endif
 .operator-can-monitor: kubectl
 	@output=$$(kubectl get crd prometheusrules.monitoring.coreos.com 2>&1) || (echo "****" && echo "**** ERROR: Montoring not available as Prometheus CRDs not installed in cluster ****" && echo "****"; exit 1)
 
+#---
+#
+#@ operator
 #
-# Install the operator deployment and related resources
+#== Install the operator deployment and related resources
 #
-# Cluster-admin privileges are required.
+#=== Cluster-admin privileges are required.
 #
-# PARAMETERS:
-#   NAMESPACE:          Set the namespace to install the operator into
-#   PLATFORM:           Override the discovered platform, if required
-#   GLOBAL:             Sets the operator to watch all namespaces for custom resources [true|false]
-#   CUSTOM_IMAGE:       Set a custom operator image name
-#   CUSTOM_VERSION:     Set a custom operator image version/tag
-#   ALWAYS_PULL_IMAGES: Sets whether to always pull the operator image [true|false]
-#   MONITORING:         Adds the prometheus monitoring resources
-#   MONITORING_PORT:    Set a custom monitoring port
-#   HEALTH_PORT:        Set a custom health port
-#   LOGGING_LEVEL:      Set the level of logging [info|debug]
-#   DRY_RUN:            Prints the resources to be applied instead of applying them
+#* PARAMETERS:
+#** NAMESPACE:          Set the namespace to install the operator into
+#** PLATFORM:           Override the discovered platform, if required
+#** GLOBAL:             Sets the operator to watch all namespaces for custom resources [true|false]
+#** CUSTOM_IMAGE:       Set a custom operator image name
+#** CUSTOM_VERSION:     Set a custom operator image version/tag
+#** ALWAYS_PULL_IMAGES: Sets whether to always pull the operator image [true|false]
+#** MONITORING:         Adds the prometheus monitoring resources
+#** MONITORING_PORT:    Set a custom monitoring port
+#** HEALTH_PORT:        Set a custom health port
+#** LOGGING_LEVEL:      Set the level of logging [info|debug]
+#** DRY_RUN:            Prints the resources to be applied instead of applying them
 #
+#---
 operator: check-admin have-platform check-crd-api-support kustomize kubectl .operator-port-patch .operator-log-level-patch
 ifeq ($(MONITORING), true)
 	@$(MAKE) -s .operator-can-monitor
@@ -337,16 +349,20 @@ endif
 .platform-openshift-patch:
 	@sed -i 's/.*profile:.*/  profile: OpenShift/' $(SAMPLES)/$(INT_PLATFORM_PATCH).$(YAML)
 
+#---
 #
-# Install the integration platform
+#@ platform
 #
-# Cluster-admin privileges are required.
+#== Install the integration platform
 #
-# PARAMETERS:
-#   NAMESPACE: Set the namespace to install the operator into
-#   PLATFORM:  Override the discovered platform, if required
-#   DRY_RUN:   Prints the resources to be applied instead of applying them [true,false]
+#=== Cluster-admin privileges are required.
 #
+#* PARAMETERS:
+#** NAMESPACE: Set the namespace to install the operator into
+#** PLATFORM:  Override the discovered platform, if required
+#** DRY_RUN:   Prints the resources to be applied instead of applying them [true,false]
+#
+#---
 platform: have-platform kustomize kubectl
 # Cannot be a dependency as PLATFORM could contain 'ERROR: '
 	@$(MAKE) .platform-$(PLATFORM)-patch
@@ -360,14 +376,18 @@ endif
 
 .PHONY: example
 
+#---
+#
+#@ example
 #
-# Installs the example integration
+#== Installs the example integration
 #
-# PARAMETERS:
-#   NAMESPACE: Set the namespace to install the example into
-#   PLATFORM:  Override the discovered platform, if required
-#   DRY_RUN:   Prints the resources to be applied instead of applying them [true, false]
+#* PARAMETERS:
+#** NAMESPACE: Set the namespace to install the example into
+#** PLATFORM:  Override the discovered platform, if required
+#** DRY_RUN:   Prints the resources to be applied instead of applying them [true, false]
 #
+#---
 example: kubectl
 # Set the namespace in the setup kustomization yaml
 	@$(call set-kustomize-namespace,$@)
@@ -376,3 +396,9 @@ ifeq ($(DRY_RUN), false)
 else
 	@$(KUSTOMIZE) build $(KOPTIONS) $@
 endif
+
+.DEFAULT_GOAL := help
+.PHONY: help
+help: ## Show this help screen.
+	@#./script/help.sh $(MAKEFILE_LIST)
+	@awk 'BEGIN { printf "\nUsage: make \033[31m<PARAM1=val1 PARAM2=val2>\033[0m \033[36m<target>\033[0m\n"; printf "\nAvailable targets are:\n" } /^#@/ { printf "\033[36m%-15s\033[0m", $$2; subdesc=0; next } /^#===/ { printf "%-14s \033[32m%s\033[0m\n", " ", substr($$0, 5); subdesc=1; next } /^#==/ { printf "\033[0m%s\033[0m\n\n", substr($$0, 4); next } /^#\*\*/ { printf "%-14s \033[31m%s\033[0m\n", " ", substr($$0, 4); next } /^#\*/ && (subdesc == 1) { printf "\n"; next } /^#\-\-\-/ { pri [...]
diff --git a/install/script/help.sh b/install/script/help.sh
new file mode 100755
index 000000000..a38fa0bee
--- /dev/null
+++ b/install/script/help.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+awk 'BEGIN {
+      printf "\nUsage: make \033[31m<PARAM1=val1 PARAM2=val2>\033[0m \033[36m<target>\033[0m\n"
+      printf "\nAvailable targets are:\n"
+    }
+    /^#@/ { printf "\033[36m%-15s\033[0m", $2; subdesc=0; next }
+    /^#===/ { printf "%-14s \033[32m%s\033[0m\n", " ", substr($0, 5); subdesc=1; next }
+    /^#==/ { printf "\033[0m%s\033[0m\n\n", substr($0, 4); next }
+    /^#\*\*/ { printf "%-14s \033[31m%s\033[0m\n", " ", substr($0, 4); next }
+    /^#\*/ && (subdesc == 1) { printf "\n"; next }
+    /^#\-\-\-/ { printf "\n"; next }' ${1}