-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: write runtime templates & other fixes (#7)
* feat: update go to 1.20 Signed-off-by: Mathew Wicks <thesuperzapper@users.noreply.github.com> * feat: write runtime templates Signed-off-by: Mathew Wicks <thesuperzapper@users.noreply.github.com> * ci: pin builds to go 1.20.4 Signed-off-by: Mathew Wicks <thesuperzapper@users.noreply.github.com> --------- Signed-off-by: Mathew Wicks <thesuperzapper@users.noreply.github.com>
- Loading branch information
1 parent
d6964a7
commit 43b1f16
Showing
8 changed files
with
101 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package generate | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
) | ||
|
||
const ( | ||
InputDirTemplateFile = "input_dir" | ||
OutputDirTemplateFile = "output_dir" | ||
) | ||
|
||
// WriteRuntimeTemplates writes the runtime templates to the specified directory | ||
func WriteRuntimeTemplates(runtimeTemplatePath string, inputDirConfig string, outputDirConfig string) error { | ||
// check if the runtime templates folder exists, and create it if not | ||
runtimeDirExists, err := DirectoryExists(runtimeTemplatePath) | ||
if err != nil { | ||
return err | ||
} | ||
if !runtimeDirExists { | ||
err = os.MkdirAll(runtimeTemplatePath, 0755) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
|
||
// write `--input-dir` config as a template file | ||
inputDirTemplatePath := filepath.Join(runtimeTemplatePath, InputDirTemplateFile) | ||
err = os.WriteFile(inputDirTemplatePath, []byte(inputDirConfig), 0644) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// write `--output-dir` config as a template file | ||
outputDirTemplatePath := filepath.Join(runtimeTemplatePath, OutputDirTemplateFile) | ||
err = os.WriteFile(outputDirTemplatePath, []byte(outputDirConfig), 0644) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters