282759c0e5
In preparation for Europa, we will vendor multiple CUE modules: - `pkg/alpha.dagger.io`: legacy non-europa packages - `pkg/dagger.io`: core Europa packages - `pkg/universe.dagger.io`: Europa universe Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
51 lines
1009 B
Go
51 lines
1009 B
Go
package pkg
|
|
|
|
import (
|
|
"context"
|
|
"embed"
|
|
"fmt"
|
|
"io/fs"
|
|
"os"
|
|
"path"
|
|
"path/filepath"
|
|
)
|
|
|
|
var (
|
|
// FS contains the filesystem of the stdlib.
|
|
//go:embed alpha.dagger.io/**/*.cue alpha.dagger.io/**/*/*.cue alpha.dagger.io/europa/dagger/*.cue alpha.dagger.io/europa/dagger/engine/*.cue
|
|
FS embed.FS
|
|
|
|
AlphaModule = "alpha.dagger.io"
|
|
EnginePackage = fmt.Sprintf("%s/europa/dagger/engine", AlphaModule)
|
|
)
|
|
|
|
func Vendor(ctx context.Context, dest string) error {
|
|
// Write the current version
|
|
return fs.WalkDir(FS, ".", func(p string, entry fs.DirEntry, err error) error {
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if !entry.Type().IsRegular() {
|
|
return nil
|
|
}
|
|
|
|
if filepath.Ext(entry.Name()) != ".cue" {
|
|
return nil
|
|
}
|
|
|
|
contents, err := fs.ReadFile(FS, p)
|
|
if err != nil {
|
|
return fmt.Errorf("%s: %w", p, err)
|
|
}
|
|
|
|
overlayPath := path.Join(dest, p)
|
|
|
|
if err := os.MkdirAll(filepath.Dir(overlayPath), 0755); err != nil {
|
|
return err
|
|
}
|
|
|
|
return os.WriteFile(overlayPath, contents, 0600)
|
|
})
|
|
}
|