affo commented on code in PR #2506:
URL: https://github.com/apache/fluss/pull/2506#discussion_r2910112660


##########
helm/templates/_security.tpl:
##########
@@ -0,0 +1,149 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+#
+
+{{/*
+Returns the authentication mechanism value of a given listener.
+Allowed mechanism values: 'none', 'plain'
+Usage:
+  include "fluss.security.listener.mechanism" (dict "Values" .Values 
"listener" "client")
+
+Explanation:
+(dict "Values" .Values "listener" "client") is a Helm template map, literally 
passed as a single argument to include.
+
+- dict: creates a key value map
+- "Values": is a key, .Values is its value
+- "listener": is a key, "client" is its value
+
+So this builds an object like:
+{
+  Values: .Values,
+  listener: "client"
+}
+
+Inside the called helper, in this case, 'fluss.security.listener.mechanism', 
it is accessed as:
+- .Values -> the chart values
+- .listener -> "client"
+
+The reason for this is that include can only pass one argument, so dict is a 
standard way to pass multiple named inputs.
+*/}}
+{{- define "fluss.security.listener.mechanism" -}}
+{{- $listener := index .Values.security .listener | default (dict) -}}

Review Comment:
   Definitely true! Thanks for the explanation!
   
   However, it is irrelevant to put the explanation in the code as a comment as 
this is standard Go template 🀝 
   
   I think it would be beneficial not to name `.Values` as `Values` πŸ˜… 
   That is kind of confusing because it really feels like you are accessing the 
root values directly in the function and passing an extra argument for the sake 
of it🀝 
   
   Maybe better to rename to `context`? E.g.:
   
   ```
   include "fluss.security.listener.mechanism" (dict "context" .Values 
"listenerName" "client")
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to