store templates with special chars in base64
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
76a92df353
commit
e53b7fb78b
File diff suppressed because one or more lines are too long
23
encoder.go
23
encoder.go
@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
@ -97,15 +98,22 @@ func (e *GenericTemplateBasedEncoder) templates() ([]string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, f := range fi {
|
for _, f := range fi {
|
||||||
|
name := f.Name()
|
||||||
skip := true
|
skip := true
|
||||||
|
if dname, err := base64.StdEncoding.DecodeString(name); err == nil {
|
||||||
|
name = string(dname)
|
||||||
|
}
|
||||||
for _, component := range components {
|
for _, component := range components {
|
||||||
if component == "all" || strings.Contains(f.Name(), "_"+component+".pb.go") {
|
if debug {
|
||||||
|
log.Printf("check file template %s for %s", name, "_"+component+".pb.go")
|
||||||
|
}
|
||||||
|
if component == "all" || strings.Contains(name, "_"+component+".pb.go") {
|
||||||
skip = false
|
skip = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if skip {
|
if skip {
|
||||||
if debug {
|
if debug {
|
||||||
log.Printf("skip template %s", f.Name())
|
log.Printf("skip template %s", name)
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -113,14 +121,14 @@ func (e *GenericTemplateBasedEncoder) templates() ([]string, error) {
|
|||||||
if f.IsDir() {
|
if f.IsDir() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if filepath.Ext(f.Name()) != ".tmpl" {
|
if filepath.Ext(name) != ".tmpl" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if e.debug {
|
if e.debug {
|
||||||
log.Printf("new template: %q", f.Name())
|
log.Printf("new template: %q", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
filenames = append(filenames, f.Name())
|
filenames = append(filenames, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
return filenames, nil
|
return filenames, nil
|
||||||
@ -209,7 +217,10 @@ func (e *GenericTemplateBasedEncoder) buildContent(templateFilename string) (str
|
|||||||
var err error
|
var err error
|
||||||
|
|
||||||
if e.templateDir == "" {
|
if e.templateDir == "" {
|
||||||
fs, err := assets.Assets.Open("/" + templateFilename)
|
fs, err := assets.Assets.Open("/" + string(base64.StdEncoding.EncodeToString([]byte(templateFilename))))
|
||||||
|
if err != nil {
|
||||||
|
fs, err = assets.Assets.Open("/" + templateFilename)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", err
|
return "", "", err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user