-
-
Notifications
You must be signed in to change notification settings - Fork 512
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Matthieu MOREL <[email protected]>
- Loading branch information
Showing
9 changed files
with
94 additions
and
90 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package template | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"text/template" | ||
) | ||
|
||
func Generate(t *template.Template, exampleFilePath string, name string, data any) error { | ||
err := os.MkdirAll(filepath.Dir(exampleFilePath), 0o755) | ||
if err != nil { | ||
return err | ||
} | ||
exampleFile, _ := os.Create(exampleFilePath) | ||
defer exampleFile.Close() | ||
|
||
err = t.ExecuteTemplate(exampleFile, name, data) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package workflow | ||
|
||
import ( | ||
"path/filepath" | ||
"text/template" | ||
|
||
internal_template "github.com/testcontainers/testcontainers-go/modulegen/internal/template" | ||
) | ||
|
||
func Generate(githubWorkflowsDir string, examples []string, modules []string) error { | ||
projectDirectories := newProjectDirectories(examples, modules) | ||
name := "ci.yml.tmpl" | ||
t, err := template.New(name).ParseFiles(filepath.Join("_template", name)) | ||
if err != nil { | ||
return err | ||
} | ||
return internal_template.Generate(t, filepath.Join(githubWorkflowsDir, "ci.yml"), name, projectDirectories) | ||
} |
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,17 @@ | ||
package workflow | ||
|
||
import ( | ||
"strings" | ||
) | ||
|
||
type ProjectDirectories struct { | ||
Examples string | ||
Modules string | ||
} | ||
|
||
func newProjectDirectories(examples []string, modules []string) *ProjectDirectories { | ||
return &ProjectDirectories{ | ||
Examples: strings.Join(examples, ", "), | ||
Modules: strings.Join(modules, ", "), | ||
} | ||
} |
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