Add YTT template value for setting log level

This is helpful for us, amongst other users, because we want to enable "debug"
logging whenever we deploy components for testing.

See a5643e3 for addition of log level.

Signed-off-by: Andrew Keesler <akeesler@vmware.com>
This commit is contained in:
Andrew Keesler 2020-11-11 07:49:46 -05:00
parent 101394c714
commit 724c0d3eb0
No known key found for this signature in database
GPG Key ID: 27CE0444346F9413
6 changed files with 32 additions and 2 deletions

View File

@ -3,7 +3,7 @@
#@ load("@ytt:data", "data") #@ load("@ytt:data", "data")
#@ load("@ytt:json", "json") #@ load("@ytt:json", "json")
#@ load("helpers.lib.yaml", "defaultLabel", "labels", "namespace", "defaultResourceName", "defaultResourceNameWithSuffix") #@ load("helpers.lib.yaml", "defaultLabel", "labels", "namespace", "defaultResourceName", "defaultResourceNameWithSuffix", "getAndValidateLogLevel")
#@ if not data.values.into_namespace: #@ if not data.values.into_namespace:
--- ---
@ -57,6 +57,9 @@ data:
imagePullSecrets: imagePullSecrets:
- image-pull-secret - image-pull-secret
(@ end @) (@ end @)
(@ if data.values.log_level: @)
logLevel: (@= getAndValidateLogLevel() @)
(@ end @)
--- ---
#@ if data.values.image_pull_dockerconfigjson and data.values.image_pull_dockerconfigjson != "": #@ if data.values.image_pull_dockerconfigjson and data.values.image_pull_dockerconfigjson != "":
apiVersion: v1 apiVersion: v1

View File

@ -28,3 +28,11 @@ app: #@ data.values.app_name
_: #@ template.replace(defaultLabel()) _: #@ template.replace(defaultLabel())
_: #@ template.replace(data.values.custom_labels) _: #@ template.replace(data.values.custom_labels)
#@ end #@ end
#@ def getAndValidateLogLevel():
#@ log_level = data.values.log_level
#@ if log_level != "info" and log_level != "debug" and log_level != "trace" and log_level != "all":
#@ fail("log_level '" + log_level + "' is invalid")
#@ end
#@ return log_level
#@ end

View File

@ -50,3 +50,7 @@ discovery_url: #! e.g., https://example.com
#! about every 25 days. #! about every 25 days.
api_serving_certificate_duration_seconds: 2592000 api_serving_certificate_duration_seconds: 2592000
api_serving_certificate_renew_before_seconds: 2160000 api_serving_certificate_renew_before_seconds: 2160000
#! Specify the verbosity of logging: info ("nice to know" information), debug (developer
#! information), trace (timing information), all (kitchen sink).
log_level: #! By default, when this value is left unset, only warnings and errors are printed. There is no way to suppress warning and error logs.

View File

@ -3,7 +3,7 @@
#@ load("@ytt:data", "data") #@ load("@ytt:data", "data")
#@ load("@ytt:json", "json") #@ load("@ytt:json", "json")
#@ load("helpers.lib.yaml", "defaultLabel", "labels", "namespace", "defaultResourceName", "defaultResourceNameWithSuffix") #@ load("helpers.lib.yaml", "defaultLabel", "labels", "namespace", "defaultResourceName", "defaultResourceNameWithSuffix", "getAndValidateLogLevel")
#@ if not data.values.into_namespace: #@ if not data.values.into_namespace:
--- ---
@ -33,6 +33,9 @@ data:
names: names:
defaultTLSCertificateSecret: (@= defaultResourceNameWithSuffix("default-tls-certificate") @) defaultTLSCertificateSecret: (@= defaultResourceNameWithSuffix("default-tls-certificate") @)
labels: (@= json.encode(labels()).rstrip() @) labels: (@= json.encode(labels()).rstrip() @)
(@ if data.values.log_level: @)
logLevel: (@= getAndValidateLogLevel() @)
(@ end @)
--- ---
#@ if data.values.image_pull_dockerconfigjson and data.values.image_pull_dockerconfigjson != "": #@ if data.values.image_pull_dockerconfigjson and data.values.image_pull_dockerconfigjson != "":
apiVersion: v1 apiVersion: v1

View File

@ -28,3 +28,11 @@ app: #@ data.values.app_name
_: #@ template.replace(defaultLabel()) _: #@ template.replace(defaultLabel())
_: #@ template.replace(data.values.custom_labels) _: #@ template.replace(data.values.custom_labels)
#@ end #@ end
#@ def getAndValidateLogLevel():
#@ log_level = data.values.log_level
#@ if log_level != "info" and log_level != "debug" and log_level != "trace" and log_level != "all":
#@ fail("log_level '" + log_level + "' is invalid")
#@ end
#@ return log_level
#@ end

View File

@ -52,3 +52,7 @@ service_https_clusterip_port: #! when specified, creates a ClusterIP Service wit
#! Ignored unless service_http_loadbalancer_port and/or service_https_loadbalancer_port are provided. #! Ignored unless service_http_loadbalancer_port and/or service_https_loadbalancer_port are provided.
#! Optional. #! Optional.
service_loadbalancer_ip: #! e.g. 1.2.3.4 service_loadbalancer_ip: #! e.g. 1.2.3.4
#! Specify the verbosity of logging: info ("nice to know" information), debug (developer
#! information), trace (timing information), all (kitchen sink).
log_level: #! By default, when this value is left unset, only warnings and errors are printed. There is no way to suppress warning and error logs.