123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- package docker
- import (
- _ "embed"
- "github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util/pathx"
- )
- const (
- category = "docker"
- dockerTemplateFile = "docker.tpl"
- )
- //go:embed docker.tpl
- var dockerTemplate string
- // Clean deletes all templates files
- func Clean() error {
- return pathx.Clean(category)
- }
- // GenTemplates creates docker template files
- func GenTemplates() error {
- return initTemplate()
- }
- // Category returns the const string of docker category
- func Category() string {
- return category
- }
- // RevertTemplate recovers the deleted template files
- func RevertTemplate(name string) error {
- return pathx.CreateTemplate(category, name, dockerTemplate)
- }
- // Update deletes and creates new template files
- func Update() error {
- err := Clean()
- if err != nil {
- return err
- }
- return initTemplate()
- }
- func initTemplate() error {
- return pathx.InitTemplates(category, map[string]string{
- dockerTemplateFile: dockerTemplate,
- })
- }
|