Merge pull request #1526 from TomChv/fix/embed-sh-script

Embed shell script into universe
This commit is contained in:
Andrea Luzzardi 2022-01-28 15:22:26 -08:00 committed by GitHub
commit 025ce14ed3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 7 deletions

View File

@ -338,7 +338,9 @@ func walkStdlib(ctx context.Context, output, format string) {
return err
}
if p == "." || d.Name() == pkg.AlphaModule || !d.IsDir() || d.Name() == "cue.mod" {
// Ignore useless embedded files
if p == "." || d.Name() == pkg.AlphaModule || !d.IsDir() || d.Name() == "cue.mod" ||
strings.Contains(p, "cue.mod") || strings.Contains(p, "tests") {
return nil
}
@ -357,6 +359,10 @@ func walkStdlib(ctx context.Context, output, format string) {
lg.Warn().Str("package", p).Err(err).Msg("ignoring")
return nil
}
if strings.Contains(err.Error(), "cannot find package") {
lg.Warn().Str("package", p).Err(err).Msg("ignoring")
return nil
}
return err
}

View File

@ -17,7 +17,7 @@ import (
var (
// FS contains the filesystem of the stdlib.
//go:embed */**/*.cue */**/**/*.cue
//go:embed alpha.dagger.io dagger.io universe.dagger.io
FS embed.FS
)
@ -122,10 +122,6 @@ func extractModules(dest string) error {
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)
@ -137,7 +133,10 @@ func extractModules(dest string) error {
return err
}
return os.WriteFile(overlayPath, contents, 0600)
// Give exec permission on embedded file to freely use shell script
// Exclude permission linter
//nolint
return os.WriteFile(overlayPath, contents, 0700)
})
}