diff --git a/cmd/dagger/cmd/common/common.go b/cmd/dagger/cmd/common/common.go index bb875234..71929ccd 100644 --- a/cmd/dagger/cmd/common/common.go +++ b/cmd/dagger/cmd/common/common.go @@ -12,6 +12,7 @@ import ( "go.dagger.io/dagger/client" "go.dagger.io/dagger/compiler" "go.dagger.io/dagger/state" + "go.dagger.io/dagger/stdlib" ) func CurrentProject(ctx context.Context) *state.Project { @@ -90,7 +91,7 @@ func FormatValue(val *compiler.Value) string { } if val.LookupPath(cue.MakePath( - cue.Hid("_secret", "alpha.dagger.io/dagger"), + cue.Hid("_secret", stdlib.PackageName), cue.Str("id"), )).Exists() { return "dagger.#Secret" diff --git a/cmd/dagger/cmd/doc.go b/cmd/dagger/cmd/doc.go index 049536e2..dcdc3f3f 100644 --- a/cmd/dagger/cmd/doc.go +++ b/cmd/dagger/cmd/doc.go @@ -346,7 +346,7 @@ func walkStdlib(ctx context.Context, output, format string) { return nil } - pkgName := fmt.Sprintf("alpha.dagger.io/%s", p) + pkgName := fmt.Sprintf("%s/%s", stdlib.ModuleName, p) lg.Info().Str("package", pkgName).Str("format", format).Msg("generating doc") val, err := loadCode(pkgName) if err != nil { diff --git a/mod/mod.go b/mod/mod.go index bf49c284..21bfd0d1 100644 --- a/mod/mod.go +++ b/mod/mod.go @@ -8,6 +8,7 @@ import ( "github.com/gofrs/flock" "github.com/rs/zerolog/log" + "go.dagger.io/dagger/stdlib" ) const ( @@ -15,7 +16,7 @@ const ( ) func isUniverse(repoName string) bool { - return strings.HasPrefix(strings.ToLower(repoName), "alpha.dagger.io") + return strings.HasPrefix(strings.ToLower(repoName), stdlib.ModuleName) } func Install(ctx context.Context, workspace, repoName, versionConstraint string) (*Require, error) { diff --git a/mod/require.go b/mod/require.go index 157a7f1a..4e04ee07 100644 --- a/mod/require.go +++ b/mod/require.go @@ -7,6 +7,8 @@ import ( "path/filepath" "regexp" "strings" + + "go.dagger.io/dagger/stdlib" ) type Require struct { @@ -25,7 +27,7 @@ func newRequire(repoName, versionConstraint string) (*Require, error) { switch { case strings.HasPrefix(repoName, "github.com"): return parseGithubRepoName(repoName, versionConstraint) - case strings.HasPrefix(repoName, "alpha.dagger.io"): + case strings.HasPrefix(repoName, stdlib.ModuleName): return parseDaggerRepoName(repoName, versionConstraint) default: return nil, fmt.Errorf("repo name does not match suported providers") @@ -52,7 +54,7 @@ func parseGithubRepoName(repoName, versionConstraint string) (*Require, error) { }, nil } -var daggerRepoNameRegex = regexp.MustCompile(`alpha.dagger.io([a-zA-Z0-9/_.-]*)@?([0-9a-zA-Z.-]*)`) +var daggerRepoNameRegex = regexp.MustCompile(stdlib.ModuleName + `([a-zA-Z0-9/_.-]*)@?([0-9a-zA-Z.-]*)`) func parseDaggerRepoName(repoName, versionConstraint string) (*Require, error) { repoMatches := daggerRepoNameRegex.FindStringSubmatch(repoName) @@ -62,7 +64,7 @@ func parseDaggerRepoName(repoName, versionConstraint string) (*Require, error) { } return &Require{ - repo: "alpha.dagger.io", + repo: stdlib.ModuleName, path: repoMatches[1], version: repoMatches[2], versionConstraint: versionConstraint, diff --git a/plancontext/fs.go b/plancontext/fs.go index 8073b95c..f0b012f2 100644 --- a/plancontext/fs.go +++ b/plancontext/fs.go @@ -8,11 +8,12 @@ import ( "github.com/google/uuid" bkgw "github.com/moby/buildkit/frontend/gateway/client" "go.dagger.io/dagger/compiler" + "go.dagger.io/dagger/stdlib" ) var ( fsIDPath = cue.MakePath( - cue.Hid("_fs", "alpha.dagger.io/dagger"), + cue.Hid("_fs", stdlib.PackageName), cue.Str("id"), ) ) diff --git a/plancontext/secret.go b/plancontext/secret.go index 6ccd75c1..a03b2739 100644 --- a/plancontext/secret.go +++ b/plancontext/secret.go @@ -6,11 +6,12 @@ import ( "cuelang.org/go/cue" "go.dagger.io/dagger/compiler" + "go.dagger.io/dagger/stdlib" ) var ( secretIDPath = cue.MakePath( - cue.Hid("_secret", "alpha.dagger.io/dagger"), + cue.Hid("_secret", stdlib.PackageName), cue.Str("id"), ) ) diff --git a/plancontext/service.go b/plancontext/service.go index 3f5ad71f..a8079099 100644 --- a/plancontext/service.go +++ b/plancontext/service.go @@ -6,11 +6,12 @@ import ( "cuelang.org/go/cue" "go.dagger.io/dagger/compiler" + "go.dagger.io/dagger/stdlib" ) var ( serviceIDPath = cue.MakePath( - cue.Hid("_service", "alpha.dagger.io/dagger"), + cue.Hid("_service", stdlib.PackageName), cue.Str("id"), ) ) diff --git a/state/project.go b/state/project.go index db99b71d..ec180a8f 100644 --- a/state/project.go +++ b/state/project.go @@ -399,7 +399,7 @@ func VendorUniverse(ctx context.Context, p string) error { // add universe and lock file to `.gitignore` if err := os.WriteFile( path.Join(p, "cue.mod", "pkg", ".gitignore"), - []byte(fmt.Sprintf("# generated by dagger\n%s\ndagger.lock\n", stdlib.PackageName)), + []byte(fmt.Sprintf("# generated by dagger\n%s\ndagger.lock\n", stdlib.ModuleName)), 0600, ); err != nil { return err @@ -408,7 +408,7 @@ func VendorUniverse(ctx context.Context, p string) error { log.Ctx(ctx).Debug().Str("mod", p).Msg("vendoring universe") if err := stdlib.Vendor(ctx, p); err != nil { // FIXME(samalba): disabled install remote stdlib temporarily - // if _, err := mod.Install(ctx, p, "alpha.dagger.io", ""); err != nil { + // if _, err := mod.Install(ctx, p, stdlib.ModuleName, ""); err != nil { return err } diff --git a/stdlib/stdlib.go b/stdlib/stdlib.go index a31ce6cc..0c255882 100644 --- a/stdlib/stdlib.go +++ b/stdlib/stdlib.go @@ -17,8 +17,9 @@ var ( //go:embed **/*.cue **/*/*.cue FS embed.FS - PackageName = "alpha.dagger.io" - Path = path.Join("cue.mod", "pkg", PackageName) + ModuleName = "alpha.dagger.io" + PackageName = fmt.Sprintf("%s/dagger", ModuleName) + Path = path.Join("cue.mod", "pkg", ModuleName) lockFilePath = path.Join("cue.mod", "dagger.lock") )