-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: templates: Multiple templates import no longer breaks when depen…
…ds of each others in sub-task pluggin (#79) Fixes #74 Signed-off-by: Romain Beuque <[email protected]> Signed-off-by: Romain Beuque <[email protected]>
- Loading branch information
Showing
3 changed files
with
56 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package templateimport | ||
|
||
import ( | ||
"sync" | ||
) | ||
|
||
var ( | ||
mu sync.Mutex | ||
discoveredTemplates []string = []string{} | ||
) | ||
|
||
// AddTemplate registers a template name currently being imported | ||
func AddTemplate(templateName string) { | ||
mu.Lock() | ||
defer mu.Unlock() | ||
discoveredTemplates = append(discoveredTemplates, templateName) | ||
} | ||
|
||
// GetTemplates returns template names currently being imported. | ||
// Used when template needs to validate dependency with others templates (check existance, ...) | ||
func GetTemplates() []string { | ||
mu.Lock() | ||
defer mu.Unlock() | ||
return discoveredTemplates | ||
} | ||
|
||
// CleanTemplates flushes the template names list being imported. | ||
func CleanTemplates() { | ||
mu.Lock() | ||
defer mu.Unlock() | ||
discoveredTemplates = []string{} | ||
} |