Embed all files instead of just cue file
Signed-off-by: Vasek - Tom C <tom.chauveau@epitech.eu>
This commit is contained in:
parent
fcd90fa78a
commit
5de86cb1ee
23
pkg/pkg.go
23
pkg/pkg.go
@ -17,7 +17,7 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
// FS contains the filesystem of the stdlib.
|
// FS contains the filesystem of the stdlib.
|
||||||
//go:embed */**/*.cue */**/**/*.cue */**/*.sh
|
//go:embed alpha.dagger.io dagger.io universe.dagger.io
|
||||||
FS embed.FS
|
FS embed.FS
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -112,17 +112,6 @@ func Vendor(ctx context.Context, p string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func isAllowedExt(ext string) bool {
|
|
||||||
// List of allowed extension to vendor in
|
|
||||||
allowedExtension := []string{".cue", ".sh"}
|
|
||||||
for _, v := range allowedExtension {
|
|
||||||
if v == ext {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func extractModules(dest string) error {
|
func extractModules(dest string) error {
|
||||||
return fs.WalkDir(FS, ".", func(p string, entry fs.DirEntry, err error) error {
|
return fs.WalkDir(FS, ".", func(p string, entry fs.DirEntry, err error) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -133,10 +122,6 @@ func extractModules(dest string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if !isAllowedExt(filepath.Ext(entry.Name())) {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
contents, err := fs.ReadFile(FS, p)
|
contents, err := fs.ReadFile(FS, p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", p, err)
|
return fmt.Errorf("%s: %w", p, err)
|
||||||
@ -148,7 +133,11 @@ func extractModules(dest string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return os.WriteFile(overlayPath, contents, 0600)
|
info, err := fs.Stat(FS, p)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return os.WriteFile(overlayPath, contents, info.Mode().Perm())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user