32 lines
678 B
Go
32 lines
678 B
Go
package builtin
|
|
|
|
import (
|
|
"embed"
|
|
"strings"
|
|
|
|
"gitea.maximumdirect.net/eric/scriptorium/internal/profile"
|
|
)
|
|
|
|
const assetRoot = "assets"
|
|
|
|
//go:embed assets/**/*.yml
|
|
var assets embed.FS
|
|
|
|
func NewRepository() profile.Repository {
|
|
return profile.NewFSRepository(assets, assetRoot)
|
|
}
|
|
|
|
func NewRepositoryWithPrimary(primary profile.Repository) profile.Repository {
|
|
if primary == nil {
|
|
return NewRepository()
|
|
}
|
|
return profile.NewOverlayRepository(primary, NewRepository())
|
|
}
|
|
|
|
func NewRepositoryWithDirectory(dir string) profile.Repository {
|
|
if strings.TrimSpace(dir) == "" {
|
|
return NewRepository()
|
|
}
|
|
return NewRepositoryWithPrimary(profile.NewFilesystemRepository(dir))
|
|
}
|