Helm: File name only

Created on 23 Aug 2018  路  1Comment  路  Source: helm/helm

Output of helm version: v2.9.0
Output of kubectl version: v1.11.2
Cloud Provider/Platform (AKS, GKE, Minikube etc.): N/A

The following will produce the file name with the full path:

data:
 {{ $root := . }}
   {{ range $path, $bytes := .Files.Glob "conf-dir/opsc/conf/ssl/*" }}
   {{ $path }}: |
 {{ $root.Files.Get $path | indent 4 }}
 {{ end }}

The output like:

  conf-dir/opsc/conf/ssl/opscenter.key: |
    -----BEGIN PRIVATE KEY-----
    MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQC6V2RD5yeSiSnY
    61CePFkM+ayZXgYnNexpPKpBaPNNczG6L8XHrOf5mG/fqdaYuak1dXq/KtD8Wtw8
    aShbciyDf9imPJOI6OjNzHEU7gIKeBTHg3CvXYtyjebFnZ/urjY5zrk7rsR5kRzy
    CK+cncEs9h9o8Hh4/ach61tNTZbwtYkB/k9uNF/3r9teLXNqcOn8IRh5cTbYLhD6

How do we produce the following output with just the file name instead?

  opscenter.key: |
    -----BEGIN PRIVATE KEY-----
    MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQC6V2RD5yeSiSnY
    61CePFkM+ayZXgYnNexpPKpBaPNNczG6L8XHrOf5mG/fqdaYuak1dXq/KtD8Wtw8
    aShbciyDf9imPJOI6OjNzHEU7gIKeBTHg3CvXYtyjebFnZ/urjY5zrk7rsR5kRzy
    CK+cncEs9h9o8Hh4/ach61tNTZbwtYkB/k9uNF/3r9teLXNqcOn8IRh5cTbYLhD6

Most helpful comment

Found the solution:

data:
 {{ $root := . }}
 {{ range $path, $bytes := .Files.Glob "conf-dir/opsc/conf/ssl/*" }}
 {{ base $path }}: |
   {{ $root.Files.Get $path }}
 {{ end }}

>All comments

Found the solution:

data:
 {{ $root := . }}
 {{ range $path, $bytes := .Files.Glob "conf-dir/opsc/conf/ssl/*" }}
 {{ base $path }}: |
   {{ $root.Files.Get $path }}
 {{ end }}
Was this page helpful?
0 / 5 - 0 ratings