From 048da72439428f2ae16eaad393acfe136a5ae585 Mon Sep 17 00:00:00 2001 From: "Han Verstraete (OpenFaaS Ltd)" Date: Tue, 14 Mar 2023 09:08:05 +0100 Subject: [PATCH] Detect advanced features - Detect the Function Builder API - Add Icon for multiple namespaces Signed-off-by: Han Verstraete (OpenFaaS Ltd) --- main.go | 54 ++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 12 deletions(-) diff --git a/main.go b/main.go index a08d490..fb1ae1d 100644 --- a/main.go +++ b/main.go @@ -198,6 +198,14 @@ func main() { panic(err) } + builderDeps, err := clientset.AppsV1().Deployments("").List(ctx, metav1.ListOptions{ + LabelSelector: "component=pro-builder,app.kubernetes.io/part-of=openfaas", + }) + + if err != nil { + panic(err) + } + fmt.Printf("OpenFaaS Pro Report\n") namespaces, err := clientset.CoreV1().Namespaces().List(ctx, metav1.ListOptions{}) @@ -254,6 +262,8 @@ func main() { jetstream := false internalNats := false + functionBuilder := false + for _, dep := range deps.Items { if dep.Name == "queue-worker" { @@ -390,6 +400,10 @@ func main() { } } + if len(builderDeps.Items) > 0 { + functionBuilder = true + } + var nsFunctions = make(map[string][]Function) for _, namespace := range functionNamespaces { @@ -426,24 +440,23 @@ func main() { fmt.Printf("queue_worker_replicas: %d\n", queueWorkerReplicas) fmt.Printf("queue_worker_ack_wait: %s\n", queueWorkerAckWait) fmt.Printf("queue_worker_max_inflight: %d\n", queueWorkerMaxInflight) - fmt.Printf("\n") - } - - fmt.Printf("\nFunction namespaces:\n\n") - for _, namespace := range functionNamespaces { - fmt.Printf("- %s\n", namespace) } if len(autoscalerImage) > 0 { - fmt.Printf("\nautoscaler\n\n") + fmt.Printf("\nAutoscaler\n\n") - fmt.Printf("autoscaler_image: %s", autoscalerImage) + fmt.Printf("autoscaler_image: %s\n", autoscalerImage) } if len(dashboardImage) > 0 { - fmt.Printf("\ndashboard\n\n") + fmt.Printf("\nDashboard\n\n") - fmt.Printf("dashboard_image: %s", dashboardImage) + fmt.Printf("dashboard_image: %s\n", dashboardImage) + } + + fmt.Printf("\nFunction namespaces:\n\n") + for _, namespace := range functionNamespaces { + fmt.Printf("- %s\n", namespace) } asyncIcon := "❌" @@ -483,6 +496,16 @@ func main() { jetstreamIcon = "✅" } + functionBuilderIcon := "❌" + if functionBuilder { + functionBuilderIcon = "✅" + } + + multipleNamespacesIcon := "❌" + if len(functionNamespaces) > 0 { + multipleNamespacesIcon = "✅" + } + fmt.Printf(` Features detected: @@ -494,10 +517,17 @@ Features detected: - %s Dashboard - %s JetStream - %s Istio - `, asyncIcon, proGatewayIcon, gwHAIcon, operatorIcon, autoscalerIcon, dashboardIcon, jetstreamIcon, istioIcon) - fmt.Printf(`Other: + fmt.Printf(` +Advanced features: + +- %s Function Builder API +- %s Multiple namespaces +`, functionBuilderIcon, multipleNamespacesIcon) + + fmt.Printf(` +Other: - Kubernetes version: %s - Asynchronous concurrency (cluster): %d