remove hardcoded stdlib path
Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
parent
5b7b1cab79
commit
337ed0d1cc
@ -12,6 +12,7 @@ import (
|
|||||||
"go.dagger.io/dagger/client"
|
"go.dagger.io/dagger/client"
|
||||||
"go.dagger.io/dagger/compiler"
|
"go.dagger.io/dagger/compiler"
|
||||||
"go.dagger.io/dagger/state"
|
"go.dagger.io/dagger/state"
|
||||||
|
"go.dagger.io/dagger/stdlib"
|
||||||
)
|
)
|
||||||
|
|
||||||
func CurrentProject(ctx context.Context) *state.Project {
|
func CurrentProject(ctx context.Context) *state.Project {
|
||||||
@ -90,7 +91,7 @@ func FormatValue(val *compiler.Value) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if val.LookupPath(cue.MakePath(
|
if val.LookupPath(cue.MakePath(
|
||||||
cue.Hid("_secret", "alpha.dagger.io/dagger"),
|
cue.Hid("_secret", stdlib.PackageName),
|
||||||
cue.Str("id"),
|
cue.Str("id"),
|
||||||
)).Exists() {
|
)).Exists() {
|
||||||
return "dagger.#Secret"
|
return "dagger.#Secret"
|
||||||
|
@ -346,7 +346,7 @@ func walkStdlib(ctx context.Context, output, format string) {
|
|||||||
return nil
|
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")
|
lg.Info().Str("package", pkgName).Str("format", format).Msg("generating doc")
|
||||||
val, err := loadCode(pkgName)
|
val, err := loadCode(pkgName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
|
|
||||||
"github.com/gofrs/flock"
|
"github.com/gofrs/flock"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
"go.dagger.io/dagger/stdlib"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -15,7 +16,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func isUniverse(repoName string) bool {
|
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) {
|
func Install(ctx context.Context, workspace, repoName, versionConstraint string) (*Require, error) {
|
||||||
|
@ -7,6 +7,8 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"go.dagger.io/dagger/stdlib"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Require struct {
|
type Require struct {
|
||||||
@ -25,7 +27,7 @@ func newRequire(repoName, versionConstraint string) (*Require, error) {
|
|||||||
switch {
|
switch {
|
||||||
case strings.HasPrefix(repoName, "github.com"):
|
case strings.HasPrefix(repoName, "github.com"):
|
||||||
return parseGithubRepoName(repoName, versionConstraint)
|
return parseGithubRepoName(repoName, versionConstraint)
|
||||||
case strings.HasPrefix(repoName, "alpha.dagger.io"):
|
case strings.HasPrefix(repoName, stdlib.ModuleName):
|
||||||
return parseDaggerRepoName(repoName, versionConstraint)
|
return parseDaggerRepoName(repoName, versionConstraint)
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("repo name does not match suported providers")
|
return nil, fmt.Errorf("repo name does not match suported providers")
|
||||||
@ -52,7 +54,7 @@ func parseGithubRepoName(repoName, versionConstraint string) (*Require, error) {
|
|||||||
}, nil
|
}, 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) {
|
func parseDaggerRepoName(repoName, versionConstraint string) (*Require, error) {
|
||||||
repoMatches := daggerRepoNameRegex.FindStringSubmatch(repoName)
|
repoMatches := daggerRepoNameRegex.FindStringSubmatch(repoName)
|
||||||
@ -62,7 +64,7 @@ func parseDaggerRepoName(repoName, versionConstraint string) (*Require, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return &Require{
|
return &Require{
|
||||||
repo: "alpha.dagger.io",
|
repo: stdlib.ModuleName,
|
||||||
path: repoMatches[1],
|
path: repoMatches[1],
|
||||||
version: repoMatches[2],
|
version: repoMatches[2],
|
||||||
versionConstraint: versionConstraint,
|
versionConstraint: versionConstraint,
|
||||||
|
@ -8,11 +8,12 @@ import (
|
|||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
bkgw "github.com/moby/buildkit/frontend/gateway/client"
|
bkgw "github.com/moby/buildkit/frontend/gateway/client"
|
||||||
"go.dagger.io/dagger/compiler"
|
"go.dagger.io/dagger/compiler"
|
||||||
|
"go.dagger.io/dagger/stdlib"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
fsIDPath = cue.MakePath(
|
fsIDPath = cue.MakePath(
|
||||||
cue.Hid("_fs", "alpha.dagger.io/dagger"),
|
cue.Hid("_fs", stdlib.PackageName),
|
||||||
cue.Str("id"),
|
cue.Str("id"),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -6,11 +6,12 @@ import (
|
|||||||
|
|
||||||
"cuelang.org/go/cue"
|
"cuelang.org/go/cue"
|
||||||
"go.dagger.io/dagger/compiler"
|
"go.dagger.io/dagger/compiler"
|
||||||
|
"go.dagger.io/dagger/stdlib"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
secretIDPath = cue.MakePath(
|
secretIDPath = cue.MakePath(
|
||||||
cue.Hid("_secret", "alpha.dagger.io/dagger"),
|
cue.Hid("_secret", stdlib.PackageName),
|
||||||
cue.Str("id"),
|
cue.Str("id"),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -6,11 +6,12 @@ import (
|
|||||||
|
|
||||||
"cuelang.org/go/cue"
|
"cuelang.org/go/cue"
|
||||||
"go.dagger.io/dagger/compiler"
|
"go.dagger.io/dagger/compiler"
|
||||||
|
"go.dagger.io/dagger/stdlib"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
serviceIDPath = cue.MakePath(
|
serviceIDPath = cue.MakePath(
|
||||||
cue.Hid("_service", "alpha.dagger.io/dagger"),
|
cue.Hid("_service", stdlib.PackageName),
|
||||||
cue.Str("id"),
|
cue.Str("id"),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -399,7 +399,7 @@ func VendorUniverse(ctx context.Context, p string) error {
|
|||||||
// add universe and lock file to `.gitignore`
|
// add universe and lock file to `.gitignore`
|
||||||
if err := os.WriteFile(
|
if err := os.WriteFile(
|
||||||
path.Join(p, "cue.mod", "pkg", ".gitignore"),
|
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,
|
0600,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -408,7 +408,7 @@ func VendorUniverse(ctx context.Context, p string) error {
|
|||||||
log.Ctx(ctx).Debug().Str("mod", p).Msg("vendoring universe")
|
log.Ctx(ctx).Debug().Str("mod", p).Msg("vendoring universe")
|
||||||
if err := stdlib.Vendor(ctx, p); err != nil {
|
if err := stdlib.Vendor(ctx, p); err != nil {
|
||||||
// FIXME(samalba): disabled install remote stdlib temporarily
|
// 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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,8 +17,9 @@ var (
|
|||||||
//go:embed **/*.cue **/*/*.cue
|
//go:embed **/*.cue **/*/*.cue
|
||||||
FS embed.FS
|
FS embed.FS
|
||||||
|
|
||||||
PackageName = "alpha.dagger.io"
|
ModuleName = "alpha.dagger.io"
|
||||||
Path = path.Join("cue.mod", "pkg", PackageName)
|
PackageName = fmt.Sprintf("%s/dagger", ModuleName)
|
||||||
|
Path = path.Join("cue.mod", "pkg", ModuleName)
|
||||||
lockFilePath = path.Join("cue.mod", "dagger.lock")
|
lockFilePath = path.Join("cue.mod", "dagger.lock")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user