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


##########
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:
   I think this doesn't work, I remember checking it before:
   
   ```
   included helper when you pass a custom argument:
   
     - `.Values`: `.` becomes whatever you passed to include. If you pass (dict 
"listener" "internal"), then . is that dict, and .Values is nil.
     - `$.Values`: `$` inside a define block is the same as . at the template's 
top scope, which is still whatever was passed to include. It does NOT refer to 
the caller's $.
   
     This is a Helm/Go template limitation: include can only pass one argument, 
and that argument becomes both . and $ inside the called template.
   
     So to have both .Values and .listener available, we must either:
     1. (dict "Values" .Values "listener" "internal") — original explicit 
approach
     2. (merge (dict "listener" "internal") .) — inherits .Values from root 
context
   ```
   
   I don't think merge it easier to understand. But I am going to remove the 
comment, used it to explain this situation.



-- 
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