Merge R3 into master
[it/dep.git] / ric-common / Common-Template / helm / ric-common / templates / _context_locator.tpl
@@ -1,6 +1,5 @@
 ################################################################################
 #   Copyright (c) 2019 AT&T Intellectual Property.                             #
-#   Copyright (c) 2019 Nokia.                                                  #
 #                                                                              #
 #   Licensed under the Apache License, Version 2.0 (the "License");            #
 #   you may not use this file except in compliance with the License.           #
 
 
 
-{{- define "helmrepo.secret.user" -}}
-  {{- $user := default "helm" .Values.helmrepoCredential.user -}}
-  {{- printf "%s" $user |b64enc }}
-{{- end -}}
 
 
-{{- define "helmrepo.secret.password" -}}
-  {{- $pass := default "helm" .Values.helmrepoCredential.password -}}
-  {{- printf "%s" $pass |b64enc }}
+{{- define "locate" -}}
+  {{- $ctx := .ctx }}
+  {{- $keylist := .keylist }}
+  {{- $currentkey := first $keylist -}}
+  {{- $restkeys := rest $keylist -}}
+  {{- if empty $restkeys -}}
+    {{- $result := index $ctx $currentkey -}}
+    {{- if not (empty $result) -}}
+      {{- $result -}}
+    {{- end -}}
+  {{- else -}}
+    {{- with index $ctx $currentkey }}
+      {{- $newctx := dict "ctx" . "keylist" $restkeys -}}
+      {{- include "locate" $newctx -}}
+    {{- end -}}
+  {{- end -}}
 {{- end -}}