Skip to content

Commit 4cad1af

Browse files
authored
fix: Allow go template expansion in UI files. (#18672)
Allow Go template variables to be injected into the UI scaffold code.
1 parent ec52b90 commit 4cad1af

22 files changed

+13
-11
lines changed

scaffold/cmd/source.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,24 +41,26 @@ func newCmdScaffoldSource() *cobra.Command {
4141
//go:embed templates/source/*
4242
//go:embed templates/cloud-config-ui/public/*
4343
//go:embed templates/cloud-config-ui/src/*
44-
//go:embed templates/cloud-config-ui/.eslintrc.json
45-
//go:embed templates/cloud-config-ui/.prettierrc
46-
//go:embed templates/cloud-config-ui/.gitignore
47-
//go:embed templates/cloud-config-ui/.nvmrc
48-
//go:embed templates/cloud-config-ui/package.json
49-
//go:embed templates/cloud-config-ui/README.md
50-
//go:embed templates/cloud-config-ui/tsconfig.json
44+
//go:embed templates/cloud-config-ui/.eslintrc.json.tpl
45+
//go:embed templates/cloud-config-ui/.prettierrc.tpl
46+
//go:embed templates/cloud-config-ui/.gitignore.tpl
47+
//go:embed templates/cloud-config-ui/.nvmrc.tpl
48+
//go:embed templates/cloud-config-ui/package.json.tpl
49+
//go:embed templates/cloud-config-ui/README.md.tpl
50+
//go:embed templates/cloud-config-ui/tsconfig.json.tpl
5151
var sourceFS embed.FS
5252

5353
type scaffoldData struct {
5454
Org string
5555
Name string
56+
Kind string
5657
}
5758

5859
func runScaffoldSource(org string, name string, outputDir string) error {
5960
data := scaffoldData{
6061
Org: org,
6162
Name: name,
63+
Kind: "source",
6264
}
6365
if err := copyGoFiles(data, outputDir); err != nil {
6466
return fmt.Errorf("failed to copy go files: %w", err)
@@ -112,7 +114,7 @@ func copyConfigUIFiles(data scaffoldData, outputDir string) error {
112114
return nil
113115
}
114116
if strings.HasSuffix(fpath, ".tpl") {
115-
outputPath := strings.TrimSuffix(strings.TrimPrefix(fpath, "templates/source"), ".tpl")
117+
outputPath := strings.TrimSuffix(strings.TrimPrefix(fpath, "templates/"), ".tpl")
116118
fullPath := outputDir + "/" + outputPath
117119
err = writeTemplate(data, fpath, fullPath)
118120
if err != nil {

scaffold/cmd/templates/cloud-config-ui/.eslintrc.json renamed to scaffold/cmd/templates/cloud-config-ui/.eslintrc.json.tpl

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

scaffold/cmd/templates/cloud-config-ui/public/favicon.ico renamed to scaffold/cmd/templates/cloud-config-ui/public/favicon.ico.tpl

File renamed without changes.

scaffold/cmd/templates/cloud-config-ui/public/index.html renamed to scaffold/cmd/templates/cloud-config-ui/public/index.html.tpl

File renamed without changes.

scaffold/cmd/templates/cloud-config-ui/public/manifest.json renamed to scaffold/cmd/templates/cloud-config-ui/public/manifest.json.tpl

File renamed without changes.

0 commit comments

Comments
 (0)