-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make templates parsing follow directory tree #233
base: main
Are you sure you want to change the base?
Conversation
pkg/config/config.go
Outdated
} else { | ||
// Be compatible when given a single file | ||
// -> mock an FS containing only that file | ||
var err error | ||
var content []byte | ||
content, err = os.ReadFile(*tplDirName) | ||
if err != nil { | ||
return nil, fmt.Errorf("reading template file %q: %w", *tplDirName, err) | ||
} | ||
tplDirFs = fstest.MapFS{fInfo.Name(): {Data: content}} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There may be a better way to do this.
From what I've read fstest.MapFS
is actually intended for mocking files and dir trees for tests.
This is done to keep compatibility with providing a single file to --template
pkg/config/config.go
Outdated
if len(dirEntries) == 1 && !dirEntries[0].IsDir() { | ||
var content []byte | ||
content, err = fs.ReadFile(tplDirFs, dirEntries[0].Name()) | ||
if err != nil { | ||
return fmt.Errorf("reading single template file %q: %w", dirEntries[0].Name(), err) | ||
} | ||
tplDirFs = fstest.MapFS{cfg.Filename: {Data: content}} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the one above, but this is to keep compatibility with the filename
config key.
When there is more than one file being templated filename
will be ignored. Instead the output files will keep the names of the template files.
@normanjaeckel We are currently testing around with setting up OpenSlides on k3s. As with k3s deployment definitions are much more verbose, having them all in just one file (as currently done with the |
pkg/config/config.go
Outdated
if err != nil { | ||
return "", err | ||
return fmt.Errorf("reading single template file %q: %w", dirEntries[0].Name(), err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably not good.
The filename
config parameter should be obsoleted with these changes.
We may introduce a parameter like outputDirectory
for resulting files after executing templates.
New funtions: - base64Encode - base64Decode - readFile Also added $.WorkingDirectory variable containing the directory passed by the user as positional argument.
... when creating template object
No description provided.