status
stringclasses 1
value | repo_name
stringclasses 31
values | repo_url
stringclasses 31
values | issue_id
int64 1
104k
| title
stringlengths 4
233
| body
stringlengths 0
186k
β | issue_url
stringlengths 38
56
| pull_url
stringlengths 37
54
| before_fix_sha
stringlengths 40
40
| after_fix_sha
stringlengths 40
40
| report_datetime
unknown | language
stringclasses 5
values | commit_datetime
unknown | updated_file
stringlengths 7
188
| chunk_content
stringlengths 1
1.03M
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/modulesource.go | if err := eg.Wait(); err != nil {
return nil, fmt.Errorf("failed to resolve new dependencies: %w", err)
}
depSet := make(map[string]dagql.Instance[*core.ModuleDependency])
for _, dep := range existingDeps {
symbolic, err := dep.Self.Source.Self.Symbolic()
if err != nil {
return nil, fmt.Errorf("failed to get symbolic source ref: %w", err)
}
depSet[symbolic] = dep
}
for _, dep := range newDeps {
symbolic, err := dep.Self.Source.Self.Symbolic()
if err != nil {
return nil, fmt.Errorf("failed to get symbolic source ref: %w", err)
}
depSet[symbolic] = dep
}
finalDeps := make([]dagql.Instance[*core.ModuleDependency], 0, len(depSet))
for _, dep := range depSet {
finalDeps = append(finalDeps, dep)
}
sort.Slice(finalDeps, func(i, j int) bool {
return finalDeps[i].Self.Name < finalDeps[j].Self.Name
})
return finalDeps, nil
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/modulesource.go | func (s *moduleSchema) moduleSourceWithDependencies(
ctx context.Context,
src *core.ModuleSource,
args struct {
Dependencies []core.ModuleDependencyID
},
) (*core.ModuleSource, error) {
src = src.Clone()
newDeps, err := collectIDInstances(ctx, s.dag, args.Dependencies)
if err != nil {
return nil, fmt.Errorf("failed to load module source dependencies from ids: %w", err)
}
src.WithDependencies = append(src.WithDependencies, newDeps...)
return src, nil
}
func (s *moduleSchema) moduleSourceWithSDK(
ctx context.Context,
src *core.ModuleSource,
args struct {
SDK string
},
) (*core.ModuleSource, error) {
src = src.Clone()
src.WithSDK = args.SDK
return src, nil
}
func (s *moduleSchema) moduleSourceResolveDependency(
ctx context.Context,
src *core.ModuleSource,
args struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/modulesource.go | Dep core.ModuleSourceID
},
) (inst dagql.Instance[*core.ModuleSource], err error) {
depSrc, err := args.Dep.Load(ctx, s.dag)
if err != nil {
return inst, fmt.Errorf("failed to decode module source: %w", err)
}
if depSrc.Self.Kind == core.ModuleSourceKindGit {
return depSrc, nil
}
contextDir, err := src.ContextDirectory()
if err != nil {
return inst, fmt.Errorf("failed to get context directory: %w", err)
}
srcRootSubpath, err := src.SourceRootSubpath()
if err != nil {
return inst, fmt.Errorf("failed to get source root subpath: %w", err)
}
depRootSubpath, err := depSrc.Self.SourceRootSubpath()
if err != nil {
return inst, fmt.Errorf("failed to get source root subpath: %w", err)
}
if contextDir.Self == nil {
return inst, fmt.Errorf("cannot resolve dependency for module source with no context directory")
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/modulesource.go | depSubpath := filepath.Join(srcRootSubpath, depRootSubpath)
if !filepath.IsLocal(depSubpath) {
return inst, fmt.Errorf("module dep source path %q escapes root", depSubpath)
}
switch src.Kind {
case core.ModuleSourceKindGit:
src = src.Clone()
src.AsGitSource.Value.RootSubpath = depSubpath
newDepRefStr, err := src.RefString()
if err != nil {
return inst, fmt.Errorf("failed to get module source ref string: %w", err)
}
var newDepSrc dagql.Instance[*core.ModuleSource]
err = s.dag.Select(ctx, s.dag.Root(), &newDepSrc,
dagql.Selector{
Field: "moduleSource",
Args: []dagql.NamedInput{
{Name: "refString", Value: dagql.String(newDepRefStr)},
{Name: "stable", Value: dagql.Boolean(true)},
},
},
)
if err != nil {
return inst, fmt.Errorf("failed to load git dep: %w", err) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/modulesource.go | }
return newDepSrc, nil
case core.ModuleSourceKindLocal:
var newDepSrc dagql.Instance[*core.ModuleSource]
err = s.dag.Select(ctx, s.dag.Root(), &newDepSrc,
dagql.Selector{
Field: "moduleSource",
Args: []dagql.NamedInput{
{Name: "refString", Value: dagql.String(depSubpath)},
},
},
dagql.Selector{
Field: "withContextDirectory",
Args: []dagql.NamedInput{
{Name: "dir", Value: dagql.NewID[*core.Directory](contextDir.ID())},
},
},
)
if err != nil {
return inst, fmt.Errorf("failed to load local dep: %w", err)
}
return newDepSrc, nil
default:
return inst, fmt.Errorf("unsupported module source kind: %q", src.Kind)
}
}
func (s *moduleSchema) moduleSourceContextDirectory(
ctx context.Context,
src *core.ModuleSource,
args struct{}, |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/modulesource.go | ) (inst dagql.Instance[*core.Directory], err error) {
return src.ContextDirectory()
}
func (s *moduleSchema) moduleSourceWithContextDirectory(
ctx context.Context,
src *core.ModuleSource,
args struct {
Dir dagql.ID[*core.Directory]
},
) (*core.ModuleSource, error) {
if src.Kind != core.ModuleSourceKindLocal {
return nil, fmt.Errorf("cannot set context directory for non-local module source")
}
src = src.Clone()
var err error
src.AsLocalSource.Value.ContextDirectory, err = args.Dir.Load(ctx, s.dag)
if err != nil {
return nil, fmt.Errorf("failed to load context directory: %w", err)
}
return src, nil
}
func (s *moduleSchema) moduleSourceDirectory(
ctx context.Context,
src *core.ModuleSource,
args struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/modulesource.go | Path string
},
) (dir dagql.Instance[*core.Directory], err error) {
rootSubpath, err := src.SourceRootSubpath()
if err != nil {
return dir, fmt.Errorf("failed to get source root subpath: %w", err)
}
fullSubpath := filepath.Join("/", rootSubpath, args.Path)
contextDir, err := src.ContextDirectory()
if err != nil {
return dir, fmt.Errorf("failed to get context directory: %w", err)
}
err = s.dag.Select(ctx, contextDir, &dir,
dagql.Selector{
Field: "directory",
Args: []dagql.NamedInput{
{Name: "path", Value: dagql.String(fullSubpath)},
},
},
)
return dir, err
}
func (s *moduleSchema) moduleSourceResolveContextPathFromCaller(
ctx context.Context,
src *core.ModuleSource,
args struct{}, |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/modulesource.go | ) (string, error) {
contextAbsPath, _, err := s.resolveContextPathFromCaller(ctx, src)
return contextAbsPath, err
}
func (s *moduleSchema) resolveContextPathFromCaller(
ctx context.Context,
src *core.ModuleSource,
) (contextRootAbsPath, sourceRootAbsPath string, _ error) {
if src.Kind != core.ModuleSourceKindLocal {
return "", "", fmt.Errorf("cannot resolve non-local module source from caller")
}
rootSubpath, err := src.SourceRootSubpath()
if err != nil {
return "", "", fmt.Errorf("failed to get source root subpath: %w", err)
}
sourceRootStat, err := src.Query.Buildkit.StatCallerHostPath(ctx, rootSubpath, true)
if err != nil {
return "", "", fmt.Errorf("failed to stat source root: %w", err) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/modulesource.go | }
sourceRootAbsPath = sourceRootStat.Path
contextAbsPath, contextFound, err := callerHostFindUpContext(ctx, src.Query.Buildkit, sourceRootAbsPath)
if err != nil {
return "", "", fmt.Errorf("failed to find up root: %w", err)
}
if !contextFound {
contextAbsPath = sourceRootAbsPath
}
return contextAbsPath, sourceRootAbsPath, nil
}
func (s *moduleSchema) moduleSourceResolveFromCaller(
ctx context.Context,
src *core.ModuleSource,
args struct{},
) (inst dagql.Instance[*core.ModuleSource], err error) {
contextAbsPath, sourceRootAbsPath, err := s.resolveContextPathFromCaller(ctx, src)
if err != nil {
return inst, err
}
sourceRootRelPath, err := filepath.Rel(contextAbsPath, sourceRootAbsPath)
if err != nil {
return inst, fmt.Errorf("failed to get source root relative path: %s", err)
}
collectedDeps := dagql.NewCacheMap[string, *callerLocalDep]()
if err := s.collectCallerLocalDeps(ctx, src.Query, contextAbsPath, sourceRootAbsPath, true, src, collectedDeps); err != nil {
return inst, fmt.Errorf("failed to collect local module source deps: %w", err)
}
includeSet := map[string]struct{}{} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/modulesource.go | excludeSet := map[string]struct{}{
"**/.git": {},
}
sdkSet := map[string]core.SDK{}
sourceRootPaths := collectedDeps.Keys()
for _, rootPath := range sourceRootPaths {
rootRelPath, err := filepath.Rel(contextAbsPath, rootPath)
if err != nil {
return inst, fmt.Errorf("failed to get source root relative path: %s", err)
}
if !filepath.IsLocal(rootRelPath) {
return inst, fmt.Errorf("local module dep source path %q escapes context %q", rootRelPath, contextAbsPath)
}
localDep, err := collectedDeps.Get(ctx, rootPath)
if err != nil {
return inst, fmt.Errorf("failed to get collected local dep %s: %w", rootPath, err)
}
if rootPath == sourceRootAbsPath {
if localDep.sdk != nil {
sdkSet[localDep.sdkKey] = localDep.sdk
}
if localDep.modCfg == nil {
includeSet[sourceRootRelPath] = struct{}{} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/modulesource.go | continue
}
} else {
if localDep.modCfg == nil {
return inst, fmt.Errorf("local module source dep %s is not initialized", rootPath)
}
if localDep.sdk == nil {
return inst, fmt.Errorf("local module source dep %s has no sdk", rootPath)
}
sdkSet[localDep.sdkKey] = localDep.sdk
}
for _, path := range localDep.modCfg.Include {
absPath := filepath.Join(sourceRootAbsPath, path)
relPath, err := filepath.Rel(contextAbsPath, absPath)
if err != nil {
return inst, fmt.Errorf("failed to get relative path of config include: %s", err)
}
if !filepath.IsLocal(relPath) {
return inst, fmt.Errorf("local module dep source include path %q escapes context %q", relPath, contextAbsPath)
}
includeSet[relPath] = struct{}{} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/modulesource.go | }
for _, path := range localDep.modCfg.Exclude {
absPath := filepath.Join(sourceRootAbsPath, path)
relPath, err := filepath.Rel(contextAbsPath, absPath)
if err != nil {
return inst, fmt.Errorf("failed to get relative path of config exclude: %s", err)
}
if !filepath.IsLocal(relPath) {
return inst, fmt.Errorf("local module dep source exclude path %q escapes context %q", relPath, contextAbsPath)
}
excludeSet[relPath] = struct{}{} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/modulesource.go | }
configRelPath, err := filepath.Rel(contextAbsPath, filepath.Join(rootPath, modules.Filename))
if err != nil {
return inst, fmt.Errorf("failed to get relative path: %s", err)
}
includeSet[configRelPath] = struct{}{}
source := localDep.modCfg.Source
if source == "" {
source = "."
}
sourceAbsSubpath := filepath.Join(rootPath, source)
sourceRelSubpath, err := filepath.Rel(contextAbsPath, sourceAbsSubpath)
if err != nil {
return inst, fmt.Errorf("failed to get relative path: %s", err)
}
if !filepath.IsLocal(sourceRelSubpath) {
return inst, fmt.Errorf("local module source path %q escapes context %q", sourceRelSubpath, contextAbsPath)
}
includeSet[sourceRelSubpath+"/**/*"] = struct{}{} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/modulesource.go | }
for _, sdk := range sdkSet {
requiredPaths, err := sdk.RequiredPaths(ctx)
if err != nil {
return inst, fmt.Errorf("failed to get sdk required paths: %w", err)
}
for _, path := range requiredPaths {
includeSet[path] = struct{}{}
}
}
includes := make([]string, 0, len(includeSet))
for include := range includeSet {
includes = append(includes, include)
}
excludes := make([]string, 0, len(excludeSet))
for exclude := range excludeSet {
excludes = append(excludes, exclude)
}
pipelineName := fmt.Sprintf("load local module context %s", contextAbsPath)
ctx, subRecorder := progrock.WithGroup(ctx, pipelineName, progrock.Weak())
_, desc, err := src.Query.Buildkit.LocalImport(
ctx, subRecorder, src.Query.Platform.Spec(),
contextAbsPath,
excludes, |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/modulesource.go | includes,
)
if err != nil {
return inst, fmt.Errorf("failed to import local module source: %w", err)
}
loadedDir, err := core.LoadBlob(ctx, s.dag, desc)
if err != nil {
return inst, fmt.Errorf("failed to load local module source: %w", err)
}
return s.normalizeCallerLoadedSource(ctx, src, sourceRootRelPath, loadedDir)
}
func (s *moduleSchema) normalizeCallerLoadedSource(
ctx context.Context,
src *core.ModuleSource,
sourceRootRelPath string,
loadedDir dagql.Instance[*core.Directory],
) (inst dagql.Instance[*core.ModuleSource], err error) {
err = s.dag.Select(ctx, s.dag.Root(), &inst,
dagql.Selector{
Field: "moduleSource",
Args: []dagql.NamedInput{
{Name: "refString", Value: dagql.String(sourceRootRelPath)},
},
},
dagql.Selector{
Field: "withContextDirectory",
Args: []dagql.NamedInput{
{Name: "dir", Value: dagql.NewID[*core.Directory](loadedDir.ID())},
},
}, |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/modulesource.go | )
if src.WithName != "" {
err = s.dag.Select(ctx, inst, &inst,
dagql.Selector{
Field: "withName",
Args: []dagql.NamedInput{
{Name: "name", Value: dagql.String(src.WithName)},
},
},
)
if err != nil {
return inst, fmt.Errorf("failed to set name: %w", err)
}
}
if src.WithSDK != "" {
err = s.dag.Select(ctx, inst, &inst,
dagql.Selector{
Field: "withSDK",
Args: []dagql.NamedInput{
{Name: "sdk", Value: dagql.String(src.WithSDK)},
},
},
)
if err != nil {
return inst, fmt.Errorf("failed to set sdk: %w", err)
}
}
if src.WithSourceSubpath != "" {
err = s.dag.Select(ctx, inst, &inst,
dagql.Selector{ |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/modulesource.go | Field: "withSourceSubpath",
Args: []dagql.NamedInput{
{Name: "path", Value: dagql.String(src.WithSourceSubpath)},
},
},
)
if err != nil {
return inst, fmt.Errorf("failed to set source subdir: %w", err)
}
}
if len(src.WithDependencies) > 0 {
depIDs := make([]core.ModuleDependencyID, len(src.WithDependencies))
for i, dep := range src.WithDependencies {
depIDs[i] = dagql.NewID[*core.ModuleDependency](dep.ID())
}
err = s.dag.Select(ctx, inst, &inst,
dagql.Selector{
Field: "withDependencies",
Args: []dagql.NamedInput{
{Name: "dependencies", Value: dagql.ArrayInput[core.ModuleDependencyID](depIDs)},
},
},
)
if err != nil {
return inst, fmt.Errorf("failed to set dependency: %w", err)
}
}
return inst, err
}
type callerLocalDep struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/modulesource.go | sourceRootAbsPath string
modCfg *modules.ModuleConfig
sdk core.SDK
sdkKey string
}
func (s *moduleSchema) collectCallerLocalDeps(
ctx context.Context,
query *core.Query,
contextAbsPath string,
sourceRootAbsPath string,
topLevel bool,
src *core.ModuleSource,
collectedDeps dagql.CacheMap[string, *callerLocalDep],
) error {
_, err := collectedDeps.GetOrInitialize(ctx, sourceRootAbsPath, func(ctx context.Context) (*callerLocalDep, error) {
sourceRootRelPath, err := filepath.Rel(contextAbsPath, sourceRootAbsPath)
if err != nil { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/modulesource.go | return nil, fmt.Errorf("failed to get source root relative path: %s", err)
}
if !filepath.IsLocal(sourceRootRelPath) {
return nil, fmt.Errorf("local module dep source path %q escapes context %q", sourceRootRelPath, contextAbsPath)
}
var modCfg modules.ModuleConfig
configPath := filepath.Join(sourceRootAbsPath, modules.Filename)
configBytes, err := query.Buildkit.ReadCallerHostFile(ctx, configPath)
switch {
case err == nil:
if err := json.Unmarshal(configBytes, &modCfg); err != nil {
return nil, fmt.Errorf("error unmarshaling config at %s: %s", configPath, err)
}
case strings.Contains(err.Error(), "no such file or directory"):
if !topLevel {
return nil, fmt.Errorf("missing config file %s", configPath)
}
if src.WithSDK == "" && len(src.WithDependencies) == 0 {
return &callerLocalDep{sourceRootAbsPath: sourceRootAbsPath}, nil
}
default:
return nil, fmt.Errorf("error reading config %s: %s", configPath, err)
}
if topLevel {
if src.WithName != "" {
modCfg.Name = src.WithName
}
if src.WithSDK != "" { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/modulesource.go | modCfg.SDK = src.WithSDK
}
for _, dep := range src.WithDependencies {
refString, err := dep.Self.Source.Self.RefString()
if err != nil {
return nil, fmt.Errorf("failed to get ref string for dependency: %w", err)
}
modCfg.Dependencies = append(modCfg.Dependencies, &modules.ModuleConfigDependency{
Name: dep.Self.Name,
Source: refString,
})
}
}
localDep := &callerLocalDep{
sourceRootAbsPath: sourceRootAbsPath,
modCfg: &modCfg,
}
for _, depCfg := range modCfg.Dependencies {
parsed := parseRefString(depCfg.Source)
if parsed.kind != core.ModuleSourceKindLocal {
continue
}
depAbsPath := filepath.Join(sourceRootAbsPath, parsed.modPath)
err = s.collectCallerLocalDeps(ctx, query, contextAbsPath, depAbsPath, false, src, collectedDeps)
if err != nil {
return nil, fmt.Errorf("failed to collect local module source dep: %w", err)
}
}
if modCfg.SDK == "" {
return localDep, nil |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/modulesource.go | }
localDep.sdkKey = modCfg.SDK
localDep.sdk, err = s.builtinSDK(ctx, query, modCfg.SDK)
switch {
case err == nil:
case errors.Is(err, errUnknownBuiltinSDK):
parsed := parseRefString(modCfg.SDK)
switch parsed.kind {
case core.ModuleSourceKindLocal:
sdkPath := filepath.Join(sourceRootAbsPath, parsed.modPath)
err = s.collectCallerLocalDeps(ctx, query, contextAbsPath, sdkPath, false, src, collectedDeps)
if err != nil {
return nil, fmt.Errorf("failed to collect local sdk: %w", err)
}
callerCwdStat, err := query.Buildkit.StatCallerHostPath(ctx, ".", true)
if err != nil {
return nil, fmt.Errorf("failed to stat caller cwd: %w", err)
}
callerCwd := callerCwdStat.Path
sdkCallerRelPath, err := filepath.Rel(callerCwd, sdkPath)
if err != nil {
return nil, fmt.Errorf("failed to get relative path of local sdk: %s", err)
}
var sdkMod dagql.Instance[*core.Module]
err = s.dag.Select(ctx, s.dag.Root(), &sdkMod,
dagql.Selector{
Field: "moduleSource", |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/modulesource.go | Args: []dagql.NamedInput{
{Name: "refString", Value: dagql.String(sdkCallerRelPath)},
},
},
dagql.Selector{
Field: "resolveFromCaller",
},
dagql.Selector{
Field: "asModule",
},
dagql.Selector{
Field: "initialize",
},
)
if err != nil {
return nil, fmt.Errorf("failed to load local sdk module source: %w", err)
}
localDep.sdk, err = s.newModuleSDK(ctx, query, sdkMod, dagql.Instance[*core.Directory]{})
if err != nil {
return nil, fmt.Errorf("failed to get local sdk: %w", err)
}
localDep.sdkKey = sdkPath
case core.ModuleSourceKindGit:
localDep.sdk, err = s.sdkForModule(ctx, query, modCfg.SDK, dagql.Instance[*core.ModuleSource]{})
if err != nil {
return nil, fmt.Errorf("failed to get git module sdk: %w", err)
}
}
default: |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/modulesource.go | return nil, fmt.Errorf("failed to load sdk: %w", err)
}
return localDep, nil
})
if errors.Is(err, dagql.ErrCacheMapRecursiveCall) {
return fmt.Errorf("local module at %q has a circular dependency", sourceRootAbsPath)
}
return err
}
func callerHostFindUpContext(
ctx context.Context,
bk *buildkit.Client,
curDirPath string,
) (string, bool, error) {
if !filepath.IsAbs(curDirPath) {
return "", false, fmt.Errorf("path is not absolute: %s", curDirPath)
}
_, err := bk.StatCallerHostPath(ctx, filepath.Join(curDirPath, ".git"), false)
if err == nil {
return curDirPath, true, nil
}
if !strings.Contains(err.Error(), "no such file or directory") {
return "", false, fmt.Errorf("failed to lstat .git: %s", err)
}
if curDirPath == "/" {
return "", false, nil
}
return callerHostFindUpContext(ctx, bk, filepath.Dir(curDirPath))
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/sdk.go | package schema
import (
"context"
"errors"
"fmt"
"path/filepath"
"github.com/dagger/dagger/analytics"
"github.com/dagger/dagger/dagql"
"github.com/vito/progrock"
"github.com/dagger/dagger/core"
"github.com/dagger/dagger/internal/distconsts"
)
const (
runtimeWorkdirPath = "/scratch"
)
func (s *moduleSchema) sdkForModule(
ctx context.Context, |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/sdk.go | query *core.Query,
sdk string,
parentSrc dagql.Instance[*core.ModuleSource],
) (core.SDK, error) {
if sdk == "" {
return nil, errors.New("sdk ref is required")
}
builtinSDK, err := s.builtinSDK(ctx, query, sdk)
if err == nil {
return builtinSDK, nil
} else if !errors.Is(err, errUnknownBuiltinSDK) {
return nil, err
}
var sdkSource dagql.Instance[*core.ModuleSource]
err = s.dag.Select(ctx, s.dag.Root(), &sdkSource,
dagql.Selector{
Field: "moduleSource",
Args: []dagql.NamedInput{
{Name: "refString", Value: dagql.String(sdk)},
},
},
)
if err != nil {
return nil, fmt.Errorf("failed to get sdk source for %s: %w", sdk, err)
}
var sdkMod dagql.Instance[*core.Module]
err = s.dag.Select(ctx, parentSrc, &sdkMod,
dagql.Selector{
Field: "resolveDependency",
Args: []dagql.NamedInput{ |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/sdk.go | {Name: "dep", Value: dagql.NewID[*core.ModuleSource](sdkSource.ID())},
},
},
dagql.Selector{
Field: "asModule",
},
dagql.Selector{
Field: "initialize",
},
)
if err != nil {
return nil, fmt.Errorf("failed to load sdk module %s: %w", sdk, err)
}
return s.newModuleSDK(ctx, query, sdkMod, dagql.Instance[*core.Directory]{})
}
var errUnknownBuiltinSDK = fmt.Errorf("unknown builtin sdk")
func (s *moduleSchema) builtinSDK(ctx context.Context, root *core.Query, sdkName string) (core.SDK, error) {
switch sdkName {
case "go":
return &goSDK{root: root, dag: s.dag}, nil
case "python":
return s.loadBuiltinSDK(ctx, root, sdkName, distconsts.PythonSDKEngineContainerModulePath)
case "typescript":
return s.loadBuiltinSDK(ctx, root, sdkName, distconsts.TypescriptSDKEngineContainerModulePath)
default:
return nil, fmt.Errorf("%s: %w", sdkName, errUnknownBuiltinSDK)
}
}
type moduleSDK struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/sdk.go | mod dagql.Instance[*core.Module]
dag *dagql.Server
sdk dagql.Object
}
func (s *moduleSchema) newModuleSDK(
ctx context.Context,
root *core.Query,
sdkModMeta dagql.Instance[*core.Module],
optionalFullSDKSourceDir dagql.Instance[*core.Directory],
) (*moduleSDK, error) {
ctx = analytics.WithInternal(ctx)
dag := dagql.NewServer(root)
dag.Cache = root.Cache
if err := sdkModMeta.Self.Install(ctx, dag); err != nil {
return nil, fmt.Errorf("failed to install sdk module %s: %w", sdkModMeta.Self.Name(), err) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/sdk.go | }
for _, defaultDep := range sdkModMeta.Self.Query.DefaultDeps.Mods {
if err := defaultDep.Install(ctx, dag); err != nil {
return nil, fmt.Errorf("failed to install default dep %s for sdk module %s: %w", defaultDep.Name(), sdkModMeta.Self.Name(), err)
}
}
var sdk dagql.Object
var constructorArgs []dagql.NamedInput
if optionalFullSDKSourceDir.Self != nil {
constructorArgs = []dagql.NamedInput{
{Name: "sdkSourceDir", Value: dagql.Opt(dagql.NewID[*core.Directory](optionalFullSDKSourceDir.ID()))},
}
}
if err := dag.Select(ctx, dag.Root(), &sdk,
dagql.Selector{
Field: gqlFieldName(sdkModMeta.Self.Name()),
Args: constructorArgs,
},
); err != nil {
return nil, fmt.Errorf("failed to get sdk object for sdk module %s: %w", sdkModMeta.Self.Name(), err)
}
return &moduleSDK{mod: sdkModMeta, dag: dag, sdk: sdk}, nil
}
func (sdk *moduleSDK) Codegen(ctx context.Context, deps *core.ModDeps, source dagql.Instance[*core.ModuleSource]) (*core.GeneratedCode, error) {
ctx = analytics.WithInternal(ctx)
introspectionJSON, err := deps.SchemaIntrospectionJSON(ctx, true)
if err != nil {
return nil, fmt.Errorf("failed to get schema introspection json during %s module sdk codegen: %w", sdk.mod.Self.Name(), err)
}
var inst dagql.Instance[*core.GeneratedCode] |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/sdk.go | err = sdk.dag.Select(ctx, sdk.sdk, &inst, dagql.Selector{
Field: "codegen",
Args: []dagql.NamedInput{
{
Name: "modSource",
Value: dagql.NewID[*core.ModuleSource](source.ID()),
},
{
Name: "introspectionJson",
Value: dagql.String(introspectionJSON),
},
},
})
if err != nil {
return nil, fmt.Errorf("failed to call sdk module codegen: %w", err)
}
return inst.Self, nil
}
func (sdk *moduleSDK) Runtime(ctx context.Context, deps *core.ModDeps, source dagql.Instance[*core.ModuleSource]) (*core.Container, error) {
ctx = analytics.WithInternal(ctx)
introspectionJSON, err := deps.SchemaIntrospectionJSON(ctx, true)
if err != nil {
return nil, fmt.Errorf("failed to get schema introspection json during %s module sdk runtime: %w", sdk.mod.Self.Name(), err)
}
var inst dagql.Instance[*core.Container]
err = sdk.dag.Select(ctx, sdk.sdk, &inst,
dagql.Selector{
Field: "moduleRuntime",
Args: []dagql.NamedInput{
{ |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/sdk.go | Name: "modSource",
Value: dagql.NewID[*core.ModuleSource](source.ID()),
},
{
Name: "introspectionJson",
Value: dagql.String(introspectionJSON),
},
},
},
dagql.Selector{
Field: "withWorkdir",
Args: []dagql.NamedInput{
{
Name: "path",
Value: dagql.NewString(runtimeWorkdirPath),
},
},
},
)
if err != nil {
return nil, fmt.Errorf("failed to call sdk module moduleRuntime: %w", err)
}
return inst.Self, nil
}
func (sdk *moduleSDK) RequiredPaths(ctx context.Context) ([]string, error) {
ctx = analytics.WithInternal(ctx)
var paths []string
err := sdk.dag.Select(ctx, sdk.sdk, &paths,
dagql.Selector{
Field: "requiredPaths", |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/sdk.go | },
)
if err != nil {
return nil, fmt.Errorf("failed to call sdk module requiredPaths: %w", err)
}
return paths, nil
}
func (s *moduleSchema) loadBuiltinSDK(
ctx context.Context,
root *core.Query,
name string,
engineContainerModulePath string,
) (*moduleSDK, error) {
ctx, recorder := progrock.WithGroup(ctx, fmt.Sprintf("load builtin module sdk %s", name))
fullSDKSourcePath := filepath.Dir(engineContainerModulePath)
_, desc, err := root.Buildkit.EngineContainerLocalImport(
ctx,
recorder,
root.Platform.Spec(),
fullSDKSourcePath,
nil,
nil,
)
if err != nil {
return nil, fmt.Errorf("failed to import full sdk source for sdk %s from engine container filesystem: %w", name, err)
}
fullSDKDir, err := core.LoadBlob(ctx, s.dag, desc) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/sdk.go | if err != nil {
return nil, fmt.Errorf("failed to load full sdk source for module sdk %s: %w", name, err)
}
var sdkModDir dagql.Instance[*core.Directory]
err = s.dag.Select(ctx, fullSDKDir, &sdkModDir,
dagql.Selector{
Field: "directory",
Args: []dagql.NamedInput{
{Name: "path", Value: dagql.String(filepath.Base(engineContainerModulePath))},
},
},
)
if err != nil {
return nil, fmt.Errorf("failed to import module sdk %s: %w", name, err)
}
var sdkMod dagql.Instance[*core.Module]
err = s.dag.Select(ctx, sdkModDir, &sdkMod,
dagql.Selector{
Field: "asModule",
},
dagql.Selector{
Field: "initialize",
},
)
if err != nil {
return nil, fmt.Errorf("failed to load embedded sdk module %q: %w", name, err)
}
return s.newModuleSDK(ctx, root, sdkMod, fullSDKDir)
}
const ( |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/sdk.go | goSDKUserModContextDirPath = "/src"
goSDKRuntimePath = "/runtime"
goSDKIntrospectionJSONPath = "/schema.json"
)
/*
goSDK is the one special sdk not implemented as module, instead the
`cmd/codegen/` binary is packaged into a container w/ the go runtime,
tarball'd up and included in the engine image.
The Codegen and Runtime methods are implemented by loading that tarball and
executing the codegen binary inside it to generate user code and then execute
it with the resulting /runtime binary.
*/
type goSDK struct {
root *core.Query
dag *dagql.Server
}
func (sdk *goSDK) Codegen(
ctx context.Context,
deps *core.ModDeps,
source dagql.Instance[*core.ModuleSource],
) (*core.GeneratedCode, error) {
ctr, err := sdk.baseWithCodegen(ctx, deps, source)
if err != nil {
return nil, err
}
var modifiedSrcDir dagql.Instance[*core.Directory]
if err := sdk.dag.Select(ctx, ctr, &modifiedSrcDir, dagql.Selector{
Field: "directory",
Args: []dagql.NamedInput{
{ |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/sdk.go | Name: "path",
Value: dagql.String(goSDKUserModContextDirPath),
},
},
}); err != nil {
return nil, fmt.Errorf("failed to get modified source directory for go module sdk codegen: %w", err)
}
return &core.GeneratedCode{
Code: modifiedSrcDir,
VCSGeneratedPaths: []string{
"dagger.gen.go",
"querybuilder/**",
},
}, nil
}
func (sdk *goSDK) Runtime(
ctx context.Context,
deps *core.ModDeps,
source dagql.Instance[*core.ModuleSource],
) (*core.Container, error) {
ctr, err := sdk.baseWithCodegen(ctx, deps, source)
if err != nil {
return nil, err
}
if err := sdk.dag.Select(ctx, ctr, &ctr,
dagql.Selector{
Field: "withExec",
Args: []dagql.NamedInput{
{
Name: "args", |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/sdk.go | Value: dagql.ArrayInput[dagql.String]{
"go", "build",
"-o", goSDKRuntimePath,
".",
},
},
{
Name: "skipEntrypoint",
Value: dagql.NewBoolean(true),
},
},
},
dagql.Selector{
Field: "withEntrypoint",
Args: []dagql.NamedInput{
{
Name: "args",
Value: dagql.ArrayInput[dagql.String]{
goSDKRuntimePath,
},
},
},
},
dagql.Selector{
Field: "withWorkdir",
Args: []dagql.NamedInput{
{
Name: "path",
Value: dagql.NewString(runtimeWorkdirPath),
}, |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/sdk.go | },
},
); err != nil {
return nil, fmt.Errorf("failed to exec go build in go module sdk container runtime: %w", err)
}
return ctr.Self, nil
}
func (sdk *goSDK) RequiredPaths(_ context.Context) ([]string, error) {
return []string{
"**/go.mod",
"**/go.sum",
"**/go.work",
"**/go.work.sum",
"**/vendor/",
"**/*.go",
}, nil
}
func (sdk *goSDK) baseWithCodegen(
ctx context.Context,
deps *core.ModDeps,
src dagql.Instance[*core.ModuleSource],
) (dagql.Instance[*core.Container], error) {
var ctr dagql.Instance[*core.Container]
introspectionJSON, err := deps.SchemaIntrospectionJSON(ctx, true)
if err != nil {
return ctr, fmt.Errorf("failed to get schema introspection json during module sdk codegen: %w", err) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/sdk.go | }
modName, err := src.Self.ModuleOriginalName(ctx)
if err != nil {
return ctr, fmt.Errorf("failed to get module name for go module sdk codegen: %w", err)
}
contextDir, err := src.Self.ContextDirectory()
if err != nil {
return ctr, fmt.Errorf("failed to get context directory for go module sdk codegen: %w", err)
}
srcSubpath, err := src.Self.SourceSubpathWithDefault(ctx)
if err != nil {
return ctr, fmt.Errorf("failed to get subpath for go module sdk codegen: %w", err)
}
ctr, err = sdk.base(ctx)
if err != nil {
return ctr, err
}
var emptyDir dagql.Instance[*core.Directory]
if err := sdk.dag.Select(ctx, sdk.dag.Root(), &emptyDir, dagql.Selector{Field: "directory"}); err != nil {
return ctr, fmt.Errorf("failed to create empty directory for go module sdk codegen: %w", err)
}
var updatedContextDir dagql.Instance[*core.Directory]
if err := sdk.dag.Select(ctx, contextDir, &updatedContextDir,
dagql.Selector{
Field: "withDirectory",
Args: []dagql.NamedInput{ |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/sdk.go | {Name: "path", Value: dagql.String(srcSubpath)},
{Name: "directory", Value: dagql.NewID[*core.Directory](emptyDir.ID())},
},
},
dagql.Selector{
Field: "withoutFile",
Args: []dagql.NamedInput{
{
Name: "path",
Value: dagql.String(filepath.Join(srcSubpath, "dagger.gen.go")),
},
},
},
); err != nil {
return ctr, fmt.Errorf("failed to remove dagger.gen.go from source directory: %w", err)
}
if err := sdk.dag.Select(ctx, ctr, &ctr, dagql.Selector{
Field: "withNewFile",
Args: []dagql.NamedInput{
{
Name: "path",
Value: dagql.NewString(goSDKIntrospectionJSONPath),
},
{
Name: "contents",
Value: dagql.NewString(introspectionJSON),
},
{
Name: "permissions",
Value: dagql.NewInt(0444), |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/sdk.go | },
},
}, dagql.Selector{
Field: "withMountedDirectory",
Args: []dagql.NamedInput{
{
Name: "path",
Value: dagql.NewString(goSDKUserModContextDirPath),
},
{
Name: "source",
Value: dagql.NewID[*core.Directory](updatedContextDir.ID()),
},
},
}, dagql.Selector{
Field: "withWorkdir",
Args: []dagql.NamedInput{
{
Name: "path",
Value: dagql.NewString(filepath.Join(goSDKUserModContextDirPath, srcSubpath)),
},
},
}, dagql.Selector{
Field: "withoutDefaultArgs",
}, dagql.Selector{
Field: "withExec",
Args: []dagql.NamedInput{
{
Name: "args",
Value: dagql.ArrayInput[dagql.String]{ |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/sdk.go | "--module-context", goSDKUserModContextDirPath,
"--module-name", dagql.String(modName),
"--propagate-logs=true",
"--introspection-json-path", goSDKIntrospectionJSONPath,
},
},
{
Name: "experimentalPrivilegedNesting",
Value: dagql.NewBoolean(true),
},
},
}); err != nil {
return ctr, fmt.Errorf("failed to mount introspection json file into go module sdk container codegen: %w", err)
}
return ctr, nil
}
func (sdk *goSDK) base(ctx context.Context) (dagql.Instance[*core.Container], error) {
var inst dagql.Instance[*core.Container]
ctx, recorder := progrock.WithGroup(ctx, "load builtin module sdk go")
tarDir, tarName := filepath.Split(distconsts.GoSDKEngineContainerTarballPath)
_, desc, err := sdk.root.Buildkit.EngineContainerLocalImport(
ctx,
recorder,
sdk.root.Platform.Spec(),
tarDir,
nil,
[]string{tarName},
)
if err != nil {
return inst, fmt.Errorf("failed to import go module sdk tarball from engine container filesystem: %s", err) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/sdk.go | }
blobDir, err := core.LoadBlob(ctx, sdk.dag, desc)
if err != nil {
return inst, fmt.Errorf("failed to load go module sdk tarball: %w", err)
}
var tarballFile dagql.Instance[*core.File]
if err := sdk.dag.Select(ctx, blobDir, &tarballFile, dagql.Selector{
Field: "file",
Args: []dagql.NamedInput{
{
Name: "path",
Value: dagql.String(tarName),
},
},
}); err != nil {
return inst, fmt.Errorf("failed to get tarball file from go module sdk tarball: %w", err)
}
var modCache dagql.Instance[*core.CacheVolume]
if err := sdk.dag.Select(ctx, sdk.dag.Root(), &modCache, dagql.Selector{
Field: "cacheVolume",
Args: []dagql.NamedInput{
{
Name: "key",
Value: dagql.String("modgomodcache"),
},
},
}); err != nil {
return inst, fmt.Errorf("failed to get mod cache from go module sdk tarball: %w", err)
}
var buildCache dagql.Instance[*core.CacheVolume] |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/sdk.go | if err := sdk.dag.Select(ctx, sdk.dag.Root(), &buildCache, dagql.Selector{
Field: "cacheVolume",
Args: []dagql.NamedInput{
{
Name: "key",
Value: dagql.String("modgobuildcache"),
},
},
}); err != nil {
return inst, fmt.Errorf("failed to get build cache from go module sdk tarball: %w", err)
}
var ctr dagql.Instance[*core.Container]
if err := sdk.dag.Select(ctx, sdk.dag.Root(), &ctr, dagql.Selector{
Field: "container",
}, dagql.Selector{
Field: "import",
Args: []dagql.NamedInput{
{
Name: "source",
Value: dagql.NewID[*core.File](tarballFile.ID()),
},
},
}, dagql.Selector{
Field: "withMountedCache",
Args: []dagql.NamedInput{
{
Name: "path",
Value: dagql.String("/go/pkg/mod"),
},
{ |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,623 | Need integ tests for git modules | Right now all our integ tests only use local refs because git modules are locked into github repos and we've been trying to avoid tests depending on modules in an external git repo. However, I think we should just bite the bullet on that at this point since missing that test coverage is too big a gap. | https://github.com/dagger/dagger/issues/6623 | https://github.com/dagger/dagger/pull/6693 | 6a3689eeb680920fe5f830ac972be3dc1fa4f29b | a659c04b9982ef90a999dc20efb9485b11eda556 | "2024-02-08T18:15:16Z" | go | "2024-02-20T10:52:53Z" | core/schema/sdk.go | Name: "cache",
Value: dagql.NewID[*core.CacheVolume](modCache.ID()),
},
{
Name: "sharing",
Value: core.CacheSharingModeShared,
},
},
}, dagql.Selector{
Field: "withMountedCache",
Args: []dagql.NamedInput{
{
Name: "path",
Value: dagql.String("/root/.cache/go-build"),
},
{
Name: "cache",
Value: dagql.NewID[*core.CacheVolume](buildCache.ID()),
},
{
Name: "sharing",
Value: core.CacheSharingModeShared,
},
},
}); err != nil {
return inst, fmt.Errorf("failed to get container from go module sdk tarball: %w", err)
}
return ctr, nil
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | cmd/codegen/generator/go/templates/format.go | package templates
import (
"strings"
"github.com/dagger/dagger/cmd/codegen/generator"
)
type FormatTypeFunc struct {
scope string
}
func (f *FormatTypeFunc) WithScope(scope string) generator.FormatTypeFuncs {
if scope != "" {
scope += "."
}
clone := *f
clone.scope = scope
return &clone
}
func (f *FormatTypeFunc) FormatKindList(representation string) string {
representation = "[]" + representation
return representation
}
func (f *FormatTypeFunc) FormatKindScalarString(representation string) string {
representation += "string"
return representation
}
func (f *FormatTypeFunc) FormatKindScalarInt(representation string) string {
representation += "int"
return representation |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | cmd/codegen/generator/go/templates/format.go | }
func (f *FormatTypeFunc) FormatKindScalarFloat(representation string) string {
representation += "float"
return representation
}
func (f *FormatTypeFunc) FormatKindScalarBoolean(representation string) string {
representation += "bool"
return representation
}
func (f *FormatTypeFunc) FormatKindScalarDefault(representation string, refName string, input bool) string {
if obj, rest, ok := strings.Cut(refName, "ID"); input && ok && rest == "" {
representation += "*" + f.scope + obj
} else {
representation += f.scope + refName
}
return representation
}
func (f *FormatTypeFunc) FormatKindObject(representation string, refName string, input bool) string {
representation += f.scope + formatName(refName)
return representation
}
func (f *FormatTypeFunc) FormatKindInputObject(representation string, refName string, input bool) string {
representation += f.scope + formatName(refName)
return representation
}
func (f *FormatTypeFunc) FormatKindEnum(representation string, refName string) string {
representation += f.scope + refName
return representation
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | package core
import (
"context"
_ "embed"
"encoding/json"
"fmt"
"go/format"
"os"
"os/exec"
"path/filepath"
"strings"
"testing"
"time"
"github.com/MakeNowJust/heredoc/v2"
"github.com/dagger/dagger/core/modules"
"github.com/dagger/dagger/dagql/idproto"
"github.com/iancoleman/strcase"
"github.com/moby/buildkit/identity"
"github.com/stretchr/testify/require"
"github.com/tidwall/gjson"
"golang.org/x/sync/errgroup"
"dagger.io/dagger"
"github.com/dagger/dagger/cmd/codegen/introspection"
)
func TestModuleGoInit(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | t.Parallel()
t.Run("from scratch", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=bare", "--sdk=go"))
out, err := modGen.
With(daggerQuery(`{bare{containerEcho(stringArg:"hello"){stdout}}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"bare":{"containerEcho":{"stdout":"hello\n"}}}`, out)
})
t.Run("reserved go.mod name", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=go", "--sdk=go"))
out, err := modGen.
With(daggerQuery(`{go{containerEcho(stringArg:"hello"){stdout}}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"go":{"containerEcho":{"stdout":"hello\n"}}}`, out)
})
t.Run("uses expected Go module name, camel-cases Dagger module name", func(t *testing.T) {
t.Parallel() |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=My-Module", "--sdk=go"))
out, err := modGen.
With(daggerQuery(`{myModule{containerEcho(stringArg:"hello"){stdout}}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"myModule":{"containerEcho":{"stdout":"hello\n"}}}`, out)
generated, err := modGen.File("go.mod").Contents(ctx)
require.NoError(t, err)
require.Contains(t, generated, "module main")
})
t.Run("creates go.mod beneath an existing go.mod if context is beneath it", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
WithNewFile("/work/go.mod", dagger.ContainerWithNewFileOpts{
Contents: "module example.com/test\n",
}).
WithNewFile("/work/foo.go", dagger.ContainerWithNewFileOpts{
Contents: "package foo\n",
}).
WithWorkdir("/work/ci").
With(daggerExec("init", "--name=beneathGoMod", "--sdk=go"))
out, err := modGen. |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | With(daggerQuery(`{beneathGoMod{containerEcho(stringArg:"hello"){stdout}}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"beneathGoMod":{"containerEcho":{"stdout":"hello\n"}}}`, out)
t.Run("names Go module after Dagger module", func(t *testing.T) {
generated, err := modGen.Directory("dagger").File("go.mod").Contents(ctx)
require.NoError(t, err)
require.Contains(t, generated, "module main")
})
})
t.Run("respects existing go.mod", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
WithExec([]string{"go", "mod", "init", "example.com/test"}).
With(daggerExec("init", "--name=hasGoMod", "--sdk=go"))
out, err := modGen.
With(daggerQuery(`{hasGoMod{containerEcho(stringArg:"hello"){stdout}}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"hasGoMod":{"containerEcho":{"stdout":"hello\n"}}}`, out)
t.Run("preserves module name", func(t *testing.T) {
generated, err := modGen.File("go.mod").Contents(ctx)
require.NoError(t, err)
require.Contains(t, generated, "module example.com/test")
})
})
t.Run("respects existing go.work", func(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
WithExec([]string{"go", "mod", "init", "example.com/test"}).
WithExec([]string{"go", "work", "init"}).
WithExec([]string{"go", "work", "use", "."}).
With(daggerExec("init", "--name=hasGoMod", "--sdk=go"))
out, err := modGen.
With(daggerQuery(`{hasGoMod{containerEcho(stringArg:"hello"){stdout}}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"hasGoMod":{"containerEcho":{"stdout":"hello\n"}}}`, out)
t.Run("go.work is edited", func(t *testing.T) {
generated, err := modGen.File("go.work").Contents(ctx)
require.NoError(t, err)
require.Contains(t, generated, "\t.\n")
require.Contains(t, generated, "\t./dagger\n")
})
})
t.Run("ignores go.work for subdir", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
WithExec([]string{"go", "mod", "init", "example.com/test"}).
WithExec([]string{"go", "work", "init"}).
WithExec([]string{"go", "work", "use", "."}). |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | With(daggerExec("init", "--name=hasGoMod", "--sdk=go", "subdir"))
out, err := modGen.
WithWorkdir("./subdir").
With(daggerQuery(`{hasGoMod{containerEcho(stringArg:"hello"){stdout}}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"hasGoMod":{"containerEcho":{"stdout":"hello\n"}}}`, out)
t.Run("go.work is unedited", func(t *testing.T) {
generated, err := modGen.File("go.work").Contents(ctx)
require.NoError(t, err)
require.Contains(t, generated, "use .\n")
})
})
t.Run("respects parent go.mod if root points to it", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
generated := goGitBase(t, c).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
WithExec([]string{"go", "mod", "init", "example.com/test"}).
WithNewFile("/work/foo.go", dagger.ContainerWithNewFileOpts{
Contents: "package foo\n",
}).
With(daggerExec("init", "--name=child", "--sdk=go", "./child")).
WithWorkdir("/work/child").
With(daggerExec("develop")). |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | Directory("/work")
parentEntries, err := generated.Entries(ctx)
require.NoError(t, err)
require.Equal(t, []string{".git", "child", "foo.go", "go.mod", "go.sum"}, parentEntries)
childEntries, err := generated.Directory("child").Entries(ctx)
require.NoError(t, err)
require.NotContains(t, childEntries, "go.mod")
t.Run("preserves parent module name", func(t *testing.T) {
goMod, err := generated.File("go.mod").Contents(ctx)
require.NoError(t, err)
require.Contains(t, goMod, "module example.com/test")
})
})
t.Run("respects existing go.mod even if root points to parent that has go.mod", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
generated := goGitBase(t, c).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
WithExec([]string{"git", "init"}).
WithExec([]string{"go", "mod", "init", "example.com/test"}).
WithNewFile("/work/foo.go", dagger.ContainerWithNewFileOpts{
Contents: "package foo\n",
}).
WithWorkdir("/work/child").
WithExec([]string{"go", "mod", "init", "my-mod"}).
WithWorkdir("/work").
With(daggerExec("init", "--source=./child", "--name=child", "--sdk=go", "./child")).
WithWorkdir("/work/child"). |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | With(daggerExec("develop")).
Directory("/work")
parentEntries, err := generated.Entries(ctx)
require.NoError(t, err)
require.Equal(t, []string{".git", "child", "foo.go", "go.mod"}, parentEntries)
childEntries, err := generated.Directory("child").Entries(ctx)
require.NoError(t, err)
require.Contains(t, childEntries, "go.mod")
require.Contains(t, childEntries, "go.sum")
})
t.Run("respects existing main.go", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
WithNewFile("/work/main.go", dagger.ContainerWithNewFileOpts{
Contents: `
package main
type HasMainGo struct {}
func (m *HasMainGo) Hello() string { return "Hello, world!" }
`,
}).
With(daggerExec("init", "--name=hasMainGo", "--sdk=go", "--source=."))
out, err := modGen.
With(daggerQuery(`{hasMainGo{hello}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"hasMainGo":{"hello":"Hello, world!"}}`, out) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | })
t.Run("respects existing main.go even if it uses types not generated yet", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
WithNewFile("/work/main.go", dagger.ContainerWithNewFileOpts{
Contents: `
package main
type HasDaggerTypes struct {}
func (m *HasDaggerTypes) Hello() *Container {
return dag.Container().
From("` + alpineImage + `").
WithExec([]string{"echo", "Hello, world!"})
}
`,
}).
With(daggerExec("init", "--source=.", "--name=hasDaggerTypes", "--sdk=go"))
out, err := modGen.
With(daggerQuery(`{hasDaggerTypes{hello{stdout}}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"hasDaggerTypes":{"hello":{"stdout":"Hello, world!\n"}}}`, out)
})
t.Run("respects existing package without creating main.go", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | WithWorkdir("/work").
WithNewFile("/work/notmain.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
type HasNotMainGo struct {}
func (m *HasNotMainGo) Hello() string { return "Hello, world!" }
`,
}).
With(daggerExec("init", "--source=.", "--name=hasNotMainGo", "--sdk=go"))
out, err := modGen.
With(daggerQuery(`{hasNotMainGo{hello}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"hasNotMainGo":{"hello":"Hello, world!"}}`, out)
})
t.Run("with source", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=bare", "--sdk=go", "--source=some/subdir"))
out, err := modGen.
With(daggerQuery(`{bare{containerEcho(stringArg:"hello"){stdout}}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"bare":{"containerEcho":{"stdout":"hello\n"}}}`, out)
sourceSubdirEnts, err := modGen.Directory("/work/some/subdir").Entries(ctx)
require.NoError(t, err)
require.Contains(t, sourceSubdirEnts, "main.go")
sourceRootEnts, err := modGen.Directory("/work").Entries(ctx) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | require.NoError(t, err)
require.NotContains(t, sourceRootEnts, "main.go")
})
}
func TestModuleInitLICENSE(t *testing.T) {
t.Run("bootstraps Apache-2.0 LICENSE file if none found", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=licensed-to-ill", "--sdk=go"))
content, err := modGen.File("LICENSE").Contents(ctx)
require.NoError(t, err)
require.Contains(t, content, "Apache License, Version 2.0")
})
t.Run("creates LICENSE file in the directory specified by arg", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=licensed-to-ill", "--sdk=go", "./mymod"))
content, err := modGen.File("mymod/LICENSE").Contents(ctx)
require.NoError(t, err)
require.Contains(t, content, "Apache License, Version 2.0")
})
t.Run("does not bootstrap LICENSE file if it exists in the parent dir", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
WithNewFile("/work/LICENSE", dagger.ContainerWithNewFileOpts{
Contents: "doesnt matter",
}).
WithWorkdir("/work/sub").
With(daggerExec("init", "--name=licensed-to-ill", "--sdk=go"))
_, err := modGen.File("LICENSE").Contents(ctx)
require.Error(t, err)
})
t.Run("bootstraps a LICENSE file when requested, even if it exists in the parent dir", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
WithNewFile("/work/LICENSE", dagger.ContainerWithNewFileOpts{
Contents: "doesnt matter",
}).
WithWorkdir("/work/sub").
With(daggerExec("init", "--name=licensed-to-ill", "--sdk=go", "--license=MIT"))
content, err := modGen.File("LICENSE").Contents(ctx)
require.NoError(t, err)
require.Contains(t, content, "MIT License")
})
}
func TestModuleGit(t *testing.T) {
t.Parallel()
type testCase struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | sdk string
gitGeneratedFiles []string
gitIgnoredFiles []string
}
for _, tc := range []testCase{
{
sdk: "go",
gitGeneratedFiles: []string{
"/dagger.gen.go",
"/querybuilder/**",
},
},
{
sdk: "python",
gitGeneratedFiles: []string{
"/sdk/**",
},
gitIgnoredFiles: []string{ |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | "/sdk",
},
},
{
sdk: "typescript",
gitGeneratedFiles: []string{
"/sdk/**",
},
gitIgnoredFiles: []string{
"/sdk",
},
},
} {
tc := tc
t.Run(fmt.Sprintf("module %s git", tc.sdk), func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := goGitBase(t, c).
With(daggerExec("init", "--name=bare", "--sdk="+tc.sdk))
out, err := modGen.
With(daggerQuery(`{bare{containerEcho(stringArg:"hello"){stdout}}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"bare":{"containerEcho":{"stdout":"hello\n"}}}`, out)
t.Run("configures .gitattributes", func(t *testing.T) {
ignore, err := modGen.File(".gitattributes").Contents(ctx)
require.NoError(t, err)
for _, fileName := range tc.gitGeneratedFiles {
require.Contains(t, ignore, fmt.Sprintf("%s linguist-generated\n", fileName))
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | })
if len(tc.gitIgnoredFiles) > 0 {
t.Run("configures .gitignore", func(t *testing.T) {
ignore, err := modGen.File(".gitignore").Contents(ctx)
require.NoError(t, err)
for _, fileName := range tc.gitIgnoredFiles {
require.Contains(t, ignore, fileName)
}
})
}
})
}
}
var goSignatures string
func TestModuleGoSignatures(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=minimal", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: goSignatures,
})
t.Run("func Hello() string", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{hello}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"hello":"hello"}}`, out)
})
t.Run("func Echo(string) string", func(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | out, err := modGen.With(daggerQuery(`{minimal{echo(msg: "hello")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echo":"hello...hello...hello..."}}`, out)
})
t.Run("func EchoPointer(*string) string", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{echoPointer(msg: "hello")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoPointer":"hello...hello...hello..."}}`, out)
})
t.Run("func EchoPointerPointer(**string) string", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{echoPointerPointer(msg: "hello")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoPointerPointer":"hello...hello...hello..."}}`, out)
})
t.Run("func EchoOptional(string) string", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{echoOptional(msg: "hello")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptional":"hello...hello...hello..."}}`, out)
out, err = modGen.With(daggerQuery(`{minimal{echoOptional}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptional":"default...default...default..."}}`, out)
})
t.Run("func EchoOptionalPointer(string) string", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{echoOptionalPointer(msg: "hello")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptionalPointer":"hello...hello...hello..."}}`, out)
out, err = modGen.With(daggerQuery(`{minimal{echoOptionalPointer}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptionalPointer":"default...default...default..."}}`, out)
}) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | t.Run("func EchoOptionalSlice([]string) string", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{echoOptionalSlice(msg: ["hello", "there"])}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptionalSlice":"hello+there...hello+there...hello+there..."}}`, out)
out, err = modGen.With(daggerQuery(`{minimal{echoOptionalSlice}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptionalSlice":"foobar...foobar...foobar..."}}`, out)
})
t.Run("func Echoes([]string) []string", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{echoes(msgs: ["hello"])}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoes":["hello...hello...hello..."]}}`, out)
})
t.Run("func EchoesVariadic(...string) string", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{echoesVariadic(msgs: ["hello"])}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoesVariadic":"hello...hello...hello..."}}`, out)
})
t.Run("func HelloContext(context.Context) string", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{helloContext}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"helloContext":"hello context"}}`, out)
})
t.Run("func EchoContext(context.Context, string) string", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{echoContext(msg: "hello")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoContext":"ctx.hello...ctx.hello...ctx.hello..."}}`, out)
})
t.Run("func HelloStringError() (string, error)", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{helloStringError}}`)).Stdout(ctx) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"helloStringError":"hello i worked"}}`, out)
})
t.Run("func HelloVoid()", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{helloVoid}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"helloVoid":null}}`, out)
})
t.Run("func HelloVoidError() error", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{helloVoidError}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"helloVoidError":null}}`, out)
})
t.Run("func EchoOpts(string, string, int) error", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{echoOpts(msg: "hi")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOpts":"hi"}}`, out)
out, err = modGen.With(daggerQuery(`{minimal{echoOpts(msg: "hi", suffix: "!", times: 2)}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOpts":"hi!hi!"}}`, out)
})
t.Run("func EchoOptsInline(struct{string, string, int}) error", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{echoOptsInline(msg: "hi")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptsInline":"hi"}}`, out)
out, err = modGen.With(daggerQuery(`{minimal{echoOptsInline(msg: "hi", suffix: "!", times: 2)}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptsInline":"hi!hi!"}}`, out)
})
t.Run("func EchoOptsInlinePointer(*struct{string, string, int}) error", func(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | out, err := modGen.With(daggerQuery(`{minimal{echoOptsInlinePointer(msg: "hi")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptsInlinePointer":"hi"}}`, out)
out, err = modGen.With(daggerQuery(`{minimal{echoOptsInlinePointer(msg: "hi", suffix: "!", times: 2)}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptsInlinePointer":"hi!hi!"}}`, out)
})
t.Run("func EchoOptsInlineCtx(ctx, struct{string, string, int}) error", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{echoOptsInlineCtx(msg: "hi")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptsInlineCtx":"hi"}}`, out)
out, err = modGen.With(daggerQuery(`{minimal{echoOptsInlineCtx(msg: "hi", suffix: "!", times: 2)}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptsInlineCtx":"hi!hi!"}}`, out)
})
t.Run("func EchoOptsInlineTags(struct{string, string, int}) error", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{echoOptsInlineTags(msg: "hi")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptsInlineTags":"hi"}}`, out)
out, err = modGen.With(daggerQuery(`{minimal{echoOptsInlineTags(msg: "hi", suffix: "!", times: 2)}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptsInlineTags":"hi!hi!"}}`, out)
})
t.Run("func EchoOptsPragmas(string, string, int) error", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{echoOptsPragmas(msg: "hi")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptsPragmas":"hi...hi...hi..."}}`, out)
})
}
func TestModuleGoSignaturesBuiltinTypes(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=minimal", "--sdk=go")).
WithNewFile("dagger/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
type Minimal struct {}
func (m *Minimal) Read(ctx context.Context, dir Directory) (string, error) {
return dir.File("foo").Contents(ctx)
}
func (m *Minimal) ReadPointer(ctx context.Context, dir *Directory) (string, error) {
return dir.File("foo").Contents(ctx)
}
func (m *Minimal) ReadSlice(ctx context.Context, dir []Directory) (string, error) {
return dir[0].File("foo").Contents(ctx)
}
func (m *Minimal) ReadVariadic(ctx context.Context, dir ...Directory) (string, error) {
return dir[0].File("foo").Contents(ctx)
}
func (m *Minimal) ReadOptional(
ctx context.Context, |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | dir *Directory, // +optional
) (string, error) {
if dir != nil {
return dir.File("foo").Contents(ctx)
}
return "", nil
}
`,
})
out, err := modGen.With(daggerQuery(`{directory{withNewFile(path: "foo", contents: "bar"){id}}}`)).Stdout(ctx)
require.NoError(t, err)
dirID := gjson.Get(out, "directory.withNewFile.id").String()
t.Run("func Read(ctx, Directory) (string, error)", func(t *testing.T) {
out, err := modGen.With(daggerQuery(fmt.Sprintf(`{minimal{read(dir: "%s")}}`, dirID))).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"read":"bar"}}`, out)
})
t.Run("func ReadPointer(ctx, *Directory) (string, error)", func(t *testing.T) {
out, err := modGen.With(daggerQuery(fmt.Sprintf(`{minimal{readPointer(dir: "%s")}}`, dirID))).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"readPointer":"bar"}}`, out)
})
t.Run("func ReadSlice(ctx, []Directory) (string, error)", func(t *testing.T) {
out, err := modGen.With(daggerQuery(fmt.Sprintf(`{minimal{readSlice(dir: ["%s"])}}`, dirID))).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"readSlice":"bar"}}`, out)
})
t.Run("func ReadVariadic(ctx, ...Directory) (string, error)", func(t *testing.T) {
out, err := modGen.With(daggerQuery(fmt.Sprintf(`{minimal{readVariadic(dir: ["%s"])}}`, dirID))).Stdout(ctx)
require.NoError(t, err) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | require.JSONEq(t, `{"minimal":{"readVariadic":"bar"}}`, out)
})
t.Run("func ReadOptional(ctx, Optional[Directory]) (string, error)", func(t *testing.T) {
out, err := modGen.With(daggerQuery(fmt.Sprintf(`{minimal{readOptional(dir: "%s")}}`, dirID))).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"readOptional":"bar"}}`, out)
out, err = modGen.With(daggerQuery(`{minimal{readOptional}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"readOptional":""}}`, out)
})
}
func TestModuleGoSignaturesUnexported(t *testing.T) {
t.Parallel()
var logs safeBuffer
c, ctx := connect(t, dagger.WithLogOutput(&logs))
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=minimal", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
type Minimal struct {}
type Foo struct {}
type bar struct {}
func (m *Minimal) Hello(name string) string {
return name
}
func (f *Foo) Hello(name string) string {
return name
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | func (b *bar) Hello(name string) string {
return name
}
`,
})
objs := inspectModuleObjects(ctx, t, modGen)
require.Equal(t, 1, len(objs.Array()))
require.Equal(t, "Minimal", objs.Get("0.name").String())
modGen = c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=minimal", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
type Minimal struct {}
type Foo struct {}
type bar struct {}
func (m *Minimal) Hello(name string) Foo {
return Foo{}
}
func (f *Foo) Hello(name string) string {
return name
}
func (b *bar) Hello(name string) string {
return name
}
`,
})
objs = inspectModuleObjects(ctx, t, modGen)
require.Equal(t, 2, len(objs.Array())) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | require.Equal(t, "Minimal", objs.Get("0.name").String())
require.Equal(t, "MinimalFoo", objs.Get("1.name").String())
modGen = c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=minimal", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
type Minimal struct {}
type Foo struct {
Bar bar
}
type bar struct {}
func (m *Minimal) Hello(name string) Foo {
return Foo{}
}
func (f *Foo) Hello(name string) string {
return name
}
func (b *bar) Hello(name string) string {
return name
}
`,
})
_, err := modGen.With(moduleIntrospection).Stderr(ctx)
require.Error(t, err)
require.NoError(t, c.Close())
require.Contains(t, logs.String(), "cannot code-generate unexported type bar")
}
func TestModuleGoSignaturesMixMatch(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | t.Parallel()
var logs safeBuffer
c, ctx := connect(t, dagger.WithLogOutput(&logs))
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=minimal", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
type Minimal struct {}
func (m *Minimal) Hello(name string, opts struct{}, opts2 struct{}) string {
return name
}
`,
})
_, err := modGen.With(daggerQuery(`{minimal{hello}}`)).Stdout(ctx)
require.Error(t, err)
require.NoError(t, c.Close())
require.Contains(t, logs.String(), "nested structs are not supported")
}
func TestModuleGoSignaturesNameConflict(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | t.Parallel()
var logs safeBuffer
c, ctx := connect(t, dagger.WithLogOutput(&logs))
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=minimal", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
type Minimal struct {
Foo Foo
Bar Bar
Baz Baz
}
type Foo struct {}
type Bar struct {}
type Baz struct {}
func (m *Foo) Hello(name string) string {
return name
}
func (f *Bar) Hello(name string, name2 string) string {
return name + name2
}
func (b *Baz) Hello() (string, error) {
return "", nil
}
`,
}) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | objs := inspectModuleObjects(ctx, t, modGen)
require.Equal(t, 4, len(objs.Array()))
require.Equal(t, "Minimal", objs.Get("0.name").String())
require.Equal(t, "MinimalFoo", objs.Get("1.name").String())
require.Equal(t, "MinimalBar", objs.Get("2.name").String())
require.Equal(t, "MinimalBaz", objs.Get("3.name").String())
}
func TestModuleGoDocs(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=minimal", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: goSignatures,
})
logGen(ctx, t, modGen.Directory("."))
obj := inspectModuleObjects(ctx, t, modGen).Get("0")
require.Equal(t, "Minimal", obj.Get("name").String())
hello := obj.Get(`functions.#(name="hello")`)
require.Equal(t, "hello", hello.Get("name").String())
require.Empty(t, hello.Get("description").String())
require.Empty(t, hello.Get("args").Array())
echoOpts := obj.Get(`functions.#(name="echoOpts")`)
require.Equal(t, "echoOpts", echoOpts.Get("name").String())
require.Equal(t, "EchoOpts does some opts things", echoOpts.Get("description").String())
require.Len(t, echoOpts.Get("args").Array(), 3)
require.Equal(t, "msg", echoOpts.Get("args.0.name").String()) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | require.Equal(t, "the message to echo", echoOpts.Get("args.0.description").String())
require.Equal(t, "suffix", echoOpts.Get("args.1.name").String())
require.Equal(t, "String to append to the echoed message", echoOpts.Get("args.1.description").String())
require.Equal(t, "times", echoOpts.Get("args.2.name").String())
require.Equal(t, "Number of times to repeat the message", echoOpts.Get("args.2.description").String())
echoOpts = obj.Get(`functions.#(name="echoOptsInline")`)
require.Equal(t, "echoOptsInline", echoOpts.Get("name").String())
require.Equal(t, "EchoOptsInline does some opts things", echoOpts.Get("description").String())
require.Len(t, echoOpts.Get("args").Array(), 3)
require.Equal(t, "msg", echoOpts.Get("args.0.name").String())
require.Equal(t, "the message to echo", echoOpts.Get("args.0.description").String())
require.Equal(t, "suffix", echoOpts.Get("args.1.name").String())
require.Equal(t, "String to append to the echoed message", echoOpts.Get("args.1.description").String())
require.Equal(t, "times", echoOpts.Get("args.2.name").String())
require.Equal(t, "Number of times to repeat the message", echoOpts.Get("args.2.description").String())
echoOpts = obj.Get(`functions.#(name="echoOptsPragmas")`)
require.Equal(t, "echoOptsPragmas", echoOpts.Get("name").String())
require.Len(t, echoOpts.Get("args").Array(), 3)
require.Equal(t, "msg", echoOpts.Get("args.0.name").String())
require.Equal(t, "", echoOpts.Get("args.0.defaultValue").String())
require.Equal(t, "suffix", echoOpts.Get("args.1.name").String())
require.Equal(t, "String to append to the echoed message", echoOpts.Get("args.1.description").String())
require.Equal(t, "\"...\"", echoOpts.Get("args.1.defaultValue").String())
require.Equal(t, "times", echoOpts.Get("args.2.name").String())
require.Equal(t, "3", echoOpts.Get("args.2.defaultValue").String())
require.Equal(t, "Number of times to repeat the message", echoOpts.Get("args.2.description").String())
}
func TestModuleGoDocsEdgeCases(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=minimal", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
// Minimal is a thing
type Minimal struct {
// X is this
X, Y string // Y is not this
// +private
Z string
}
// some docs
func (m *Minimal) Hello(foo string, bar string,
// hello
baz string, qux string, x string, // lol
) string {
return foo + bar
}
func (m *Minimal) HelloMore(
// foo here
foo,
// bar here
bar string,
) string {
return foo + bar
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | func (m *Minimal) HelloMoreInline(opts struct{
// foo here
foo, bar string
}) string {
return opts.foo + opts.bar
}
func (m *Minimal) HelloAgain( // docs for helloagain
foo string,
bar string, // docs for bar
baz string,
) string {
return foo + bar
}
func (m *Minimal) HelloFinal(
foo string) string { // woops
return foo
}
`,
})
logGen(ctx, t, modGen.Directory("."))
obj := inspectModuleObjects(ctx, t, modGen).Get("0")
require.Equal(t, "Minimal", obj.Get("name").String())
require.Equal(t, "Minimal is a thing", obj.Get("description").String())
hello := obj.Get(`functions.#(name="hello")`)
require.Equal(t, "hello", hello.Get("name").String())
require.Len(t, hello.Get("args").Array(), 5)
require.Equal(t, "foo", hello.Get("args.0.name").String())
require.Equal(t, "", hello.Get("args.0.description").String())
require.Equal(t, "bar", hello.Get("args.1.name").String())
require.Equal(t, "", hello.Get("args.1.description").String()) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | require.Equal(t, "baz", hello.Get("args.2.name").String())
require.Equal(t, "hello", hello.Get("args.2.description").String())
require.Equal(t, "qux", hello.Get("args.3.name").String())
require.Equal(t, "", hello.Get("args.3.description").String())
require.Equal(t, "x", hello.Get("args.4.name").String())
require.Equal(t, "lol", hello.Get("args.4.description").String())
hello = obj.Get(`functions.#(name="helloMore")`)
require.Equal(t, "helloMore", hello.Get("name").String())
require.Len(t, hello.Get("args").Array(), 2)
require.Equal(t, "foo", hello.Get("args.0.name").String())
require.Equal(t, "foo here", hello.Get("args.0.description").String())
require.Equal(t, "bar", hello.Get("args.1.name").String())
require.Equal(t, "bar here", hello.Get("args.1.description").String())
hello = obj.Get(`functions.#(name="helloMoreInline")`)
require.Equal(t, "helloMoreInline", hello.Get("name").String())
require.Len(t, hello.Get("args").Array(), 2)
require.Equal(t, "foo", hello.Get("args.0.name").String())
require.Equal(t, "foo here", hello.Get("args.0.description").String())
require.Equal(t, "bar", hello.Get("args.1.name").String())
require.Equal(t, "", hello.Get("args.1.description").String())
hello = obj.Get(`functions.#(name="helloAgain")`)
require.Equal(t, "helloAgain", hello.Get("name").String())
require.Len(t, hello.Get("args").Array(), 3)
require.Equal(t, "foo", hello.Get("args.0.name").String())
require.Equal(t, "", hello.Get("args.0.description").String())
require.Equal(t, "bar", hello.Get("args.1.name").String())
require.Equal(t, "docs for bar", hello.Get("args.1.description").String())
require.Equal(t, "baz", hello.Get("args.2.name").String())
require.Equal(t, "", hello.Get("args.2.description").String())
hello = obj.Get(`functions.#(name="helloFinal")`) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | require.Equal(t, "helloFinal", hello.Get("name").String())
require.Len(t, hello.Get("args").Array(), 1)
require.Equal(t, "foo", hello.Get("args.0.name").String())
require.Equal(t, "", hello.Get("args.0.description").String())
require.Len(t, obj.Get(`fields`).Array(), 2)
prop := obj.Get(`fields.#(name="x")`)
require.Equal(t, "x", prop.Get("name").String())
require.Equal(t, "X is this", prop.Get("description").String())
prop = obj.Get(`fields.#(name="y")`)
require.Equal(t, "y", prop.Get("name").String())
require.Equal(t, "", prop.Get("description").String())
}
func TestModuleGoWeirdFields(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=minimal", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
type Z string
type Minimal struct {
// field with single (normal) name
W string
// field with multiple names
X, Y string
// field with no names
Z |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | }
func New() Minimal {
return Minimal{
W: "-",
X: "-",
Y: "-",
Z: Z("-"),
}
}
// struct with no fields
type Bar struct{}
func (m *Minimal) Say(
// field with single (normal) name
a string,
// field with multiple names
b, c string,
// field with no names (not included, mixed names not allowed)
// string
) string {
return a + " " + b + " " + c
}
func (m *Minimal) Hello(
// field with no names
string,
) string {
return "hello"
}
func (m *Minimal) SayOpts(opts struct{
// field with single (normal) name
A string |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | // field with multiple names
B, C string
// field with no names (not included because of above)
// string
}) string {
return opts.A + " " + opts.B + " " + opts.C
}
func (m *Minimal) HelloOpts(opts struct{
// field with no names
string
}) string {
return "hello"
}
`,
})
out, err := modGen.With(daggerQuery(`{minimal{w, x, y, z}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal": {"w": "-", "x": "-", "y": "-", "z": "-"}}`, out)
for _, name := range []string{"say", "sayOpts"} {
out, err := modGen.With(daggerQuery(`{minimal{%s(a: "hello", b: "world", c: "!")}}`, name)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, fmt.Sprintf(`{"minimal": {"%s": "hello world !"}}`, name), out)
}
for _, name := range []string{"hello", "helloOpts"} {
out, err := modGen.With(daggerQuery(`{minimal{%s(string: "")}}`, name)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, fmt.Sprintf(`{"minimal": {"%s": "hello"}}`, name), out)
}
}
func TestModuleGoFieldMustBeNil(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=minimal", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "fmt"
type Minimal struct {
Src *Directory
Name *string
}
func New() *Minimal {
return &Minimal{}
}
func (m *Minimal) IsEmpty() bool {
if m.Name != nil {
panic(fmt.Sprintf("name should be nil but is %v", m.Name))
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | if m.Src != nil {
panic(fmt.Sprintf("src should be nil but is %v", m.Src))
}
return true
}
`,
})
out, err := modGen.With(daggerQuery(`{minimal{isEmpty}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal": {"isEmpty": true}}`, out)
}
func TestModuleDescription(t *testing.T) {
t.Parallel()
type source struct {
file string
contents string
}
for _, tc := range []struct {
sdk string
sources []source
}{
{
sdk: "go",
sources: []source{
{
file: "main.go",
contents: `
// Test module, short description
//
// Long description, with full sentences. |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | package main
// Test object, short description
type Test struct {
// +default="foo"
Foo string
}
`,
},
},
},
{
sdk: "go",
sources: []source{
{
file: "a.go",
contents: `
// First, but not main
package main
type Foo struct {}
`,
},
{
file: "z.go",
contents: `
// Test module, short description
//
// Long description, with full sentences.
package main
// Test object, short description
type Test struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | }
func (*Test) Foo() Foo {
return Foo{}
}
`,
},
},
},
{
sdk: "python",
sources: []source{
{
file: "src/main.py",
contents: `
"""Test module, short description
Long description, with full sentences.
"""
from dagger import field, object_type
@object_type
class Test:
"""Test object, short description"""
foo: str = field(default="foo")
`,
},
},
},
{
sdk: "python",
sources: []source{
{ |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | file: "src/main/foo.py",
contents: `
"""Not the main file"""
from dagger import field, object_type
@object_type
class Foo:
bar: str = field(default="bar")
`,
},
{
file: "src/main/__init__.py",
contents: `
"""Test module, short description
Long description, with full sentences.
"""
from dagger import function, object_type
from .foo import Foo
@object_type
class Test:
"""Test object, short description"""
foo = function(Foo)
`,
},
},
},
{
sdk: "typescript",
sources: []source{
{
file: "src/index.ts", |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | contents: `
/**
* Test module, short description
*
* Long description, with full sentences.
*/
import { object, field } from '@dagger.io/dagger'
/**
* Test object, short description
*/
@object()
class Test {
@field()
foo: string = "foo"
}
`,
},
},
},
{
sdk: "typescript",
sources: []source{
{
file: "src/foo.ts",
contents: `
/**
* Not the main file
*/
import { object, field } from '@dagger.io/dagger'
@object() |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | export class Foo {
@field()
bar = "bar"
}
`,
},
{
file: "src/index.ts",
contents: `
/**
* Test module, short description
*
* Long description, with full sentences.
*/
import { object, field } from '@dagger.io/dagger'
import { Foo } from "./foo"
/**
* Test object, short description
*/
@object()
class Test {
@func()
foo(): Foo {
return new Foo()
}
}
`,
},
},
}, |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | } {
tc := tc
t.Run(fmt.Sprintf("%s with %d files", tc.sdk, len(tc.sources)), func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work")
for _, src := range tc.sources {
src := src
modGen = modGen.WithNewFile(src.file, dagger.ContainerWithNewFileOpts{
Contents: heredoc.Doc(src.contents),
})
}
mod := inspectModule(ctx, t,
modGen.With(daggerExec("init", "--source=.", "--name=test", "--sdk="+tc.sdk)))
require.Equal(t,
"Test module, short description\n\nLong description, with full sentences.",
mod.Get("description").String(),
)
require.Equal(t,
"Test object, short description",
mod.Get("objects.#.asObject|#(name=Test).description").String(),
)
})
}
}
func TestModulePrivateField(t *testing.T) {
t.Parallel()
for _, tc := range []struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | sdk string
source string
}{
{
sdk: "go",
source: `package main
type Minimal struct {
Foo string
Bar string // +private
}
func (m *Minimal) Set(foo string, bar string) *Minimal {
m.Foo = foo
m.Bar = bar
return m
}
func (m *Minimal) Hello() string {
return m.Foo + m.Bar
}
`,
},
{
sdk: "python",
source: `from dagger import field, function, object_type
@object_type
class Minimal:
foo: str = field(default="")
bar: str = ""
@function
def set(self, foo: str, bar: str) -> "Minimal":
self.foo = foo |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | self.bar = bar
return self
@function
def hello(self) -> str:
return self.foo + self.bar
`,
},
{
sdk: "typescript",
source: `
import { object, func, field } from "@dagger.io/dagger"
@object()
class Minimal {
@field()
foo: string
bar?: string
constructor(foo?: string, bar?: string) {
this.foo = foo
this.bar = bar
}
@func()
set(foo: string, bar: string): Minimal {
this.foo = foo
this.bar = bar
return this
}
@func()
hello(): string {
return this.foo + this.bar
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | }
`,
},
} {
tc := tc
t.Run(tc.sdk, func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=minimal", "--sdk="+tc.sdk)).
With(sdkSource(tc.sdk, tc.source))
obj := inspectModuleObjects(ctx, t, modGen).Get("0")
require.Equal(t, "Minimal", obj.Get("name").String())
require.Len(t, obj.Get(`fields`).Array(), 1)
prop := obj.Get(`fields.#(name="foo")`)
require.Equal(t, "foo", prop.Get("name").String())
out, err := modGen.With(daggerQuery(`{minimal{set(foo: "abc", bar: "xyz"){hello}}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"set":{"hello": "abcxyz"}}}`, out)
out, err = modGen.With(daggerQuery(`{minimal{set(foo: "abc", bar: "xyz"){foo}}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"set":{"foo": "abc"}}}`, out)
_, err = modGen.With(daggerQuery(`{minimal{set(foo: "abc", bar: "xyz"){bar}}}`)).Stdout(ctx)
require.ErrorContains(t, err, `Minimal has no such field: "bar"`)
})
}
}
func TestModuleGoExtendCore(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | t.Parallel()
var logs safeBuffer
c, ctx := connect(t, dagger.WithLogOutput(&logs))
_, err := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=container", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
func (c *Container) Echo(ctx context.Context, msg string) (string, error) {
return c.WithExec([]string{"echo", msg}).Stdout(ctx)
}
`,
}).
With(daggerQuery(`{container{from(address:"` + alpineImage + `"){echo(msg:"echo!"){stdout}}}}`)).
Sync(ctx)
require.Error(t, err)
require.NoError(t, c.Close())
t.Log(logs.String())
require.Contains(t, logs.String(), "cannot define methods on objects from outside this module")
}
func TestModuleGoBadCtx(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | t.Parallel()
var logs safeBuffer
c, ctx := connect(t, dagger.WithLogOutput(&logs))
_, err := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=foo", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
type Foo struct {}
func (f *Foo) Echo(ctx context.Context, ctx2 context.Context) (string, error) {
return "", nil
}
`,
}).
With(daggerQuery(`{foo{echo}}`)).
Sync(ctx)
require.Error(t, err)
require.NoError(t, c.Close())
t.Log(logs.String())
require.Contains(t, logs.String(), "unexpected context type")
}
func TestModuleCustomTypes(t *testing.T) {
t.Parallel()
type testCase struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | sdk string
source string
}
for _, tc := range []testCase{
{
sdk: "go",
source: `package main
import "strings"
type Test struct{}
func (m *Test) Repeater(msg string, times int) *Repeater {
return &Repeater{
Message: msg,
Times: times,
}
}
type Repeater struct {
Message string
Times int
}
func (t *Repeater) Render() string {
return strings.Repeat(t.Message, t.Times)
}
`,
},
{
sdk: "python",
source: `from dagger import field, function, object_type
@object_type
class Repeater:
message: str = field(default="") |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | times: int = field(default=0)
@function
def render(self) -> str:
return self.message * self.times
@function
def repeater(msg: str, times: int) -> Repeater:
return Repeater(message=msg, times=times)
`,
},
{
sdk: "typescript",
source: `
import { object, func, field } from "@dagger.io/dagger"
@object()
class Repeater {
@field()
message: string
@field()
times: number
constructor(message: string, times: number) {
this.message = message
this.times = times
}
@func()
render(): string {
return this.message.repeat(this.times)
}
}
@object()
class Test { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | @func()
repeater(msg: string, times: number): Repeater {
return new Repeater(msg, times)
}
}
`,
},
} {
tc := tc
t.Run(fmt.Sprintf("custom %s types", tc.sdk), func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
out, err := modInit(ctx, t, c, tc.sdk, tc.source).
With(daggerQuery(`{test{repeater(msg:"echo!", times: 3){render}}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"test":{"repeater":{"render":"echo!echo!echo!"}}}`, out)
})
}
}
func TestModuleReturnTypeDetection(t *testing.T) {
t.Parallel()
type testCase struct {
sdk string
source string
}
for _, tc := range []testCase{
{
sdk: "go",
source: `package main |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | type Foo struct {}
type X struct {
Message string ` + "`json:\"message\"`" + `
}
func (m *Foo) MyFunction() X {
return X{Message: "foo"}
}
`,
},
{
sdk: "python",
source: `from dagger import field, function, object_type
@object_type
class X:
message: str = field(default="")
@function
def my_function() -> X:
return X(message="foo")
`,
},
{
sdk: "typescript",
source: `
import { object, func, field } from "@dagger.io/dagger"
@object()
class X {
@field()
message: string
constructor(message: string) {
this.message = message; |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | }
}
@object()
class Foo {
@func()
myFunction(): X {
return new X("foo");
}
}
`,
},
} {
tc := tc
t.Run(tc.sdk, func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=foo", "--sdk="+tc.sdk)).
With(sdkSource(tc.sdk, tc.source))
out, err := modGen.With(daggerQuery(`{foo{myFunction{message}}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"foo":{"myFunction":{"message":"foo"}}}`, out)
})
}
}
func TestModuleReturnObject(t *testing.T) {
t.Parallel()
type testCase struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | sdk string
source string
}
for _, tc := range []testCase{
{
sdk: "go",
source: `package main
type Foo struct {}
type X struct {
Message string ` + "`json:\"message\"`" + `
When string ` + "`json:\"Timestamp\"`" + `
To string ` + "`json:\"recipient\"`" + `
From string
}
func (m *Foo) MyFunction() X {
return X{Message: "foo", When: "now", To: "user", From: "admin"}
}
`,
},
{
sdk: "python",
source: `from dagger import field, function, object_type
@object_type
class X: |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | message: str = field(default="")
when: str = field(default="", name="Timestamp")
to: str = field(default="", name="recipient")
from_: str = field(default="", name="from")
@object_type
class Foo:
@function
def my_function(self) -> X:
return X(message="foo", when="now", to="user", from_="admin")
`,
},
{
sdk: "typescript",
source: `
import { object, func, field } from "@dagger.io/dagger"
@object()
class X {
@field()
message: string
@field()
timestamp: string
@field()
recipient: string
@field()
from: string
constructor(message: string, timestamp: string, recipient: string, from: string) {
this.message = message;
this.timestamp = timestamp;
this.recipient = recipient;
this.from = from; |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,669 | π installed module is unusable (codegen'd with wrong capitalization) | ### What is the issue?
Created module for running remote commands via SSH https://daggerverse.dev/mod/github.com/samalba/dagger-modules/ssh@35ed3e343d7e6faa3eab44570ee7531914dd4e65
I initialized the module with:
`dagger init --name ssh --sdk go --source .`
The module code uses a struct named `Ssh`. It works fine as standalone. However when you install the module from another module, it's available via `dag.SSH()` (different capitalization), which then fails to compile, because it cannot find the module version.
Simple way to reproduce: install the module from any other module and try to use it.
### Dagger version
dagger v0.9.10 (registry.dagger.io/engine) darwin/arm64 | https://github.com/dagger/dagger/issues/6669 | https://github.com/dagger/dagger/pull/6692 | a659c04b9982ef90a999dc20efb9485b11eda556 | 15cb7d10a00d0e0b19ea1a2e8fc07cf8c360d04c | "2024-02-13T22:55:54Z" | go | "2024-02-20T11:15:21Z" | core/integration/module_test.go | }
}
@object()
class Foo {
@func()
myFunction(): X {
return new X("foo", "now", "user", "admin");
}
}
`,
},
} {
tc := tc
t.Run(tc.sdk, func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=foo", "--sdk="+tc.sdk)).
With(sdkSource(tc.sdk, tc.source))
out, err := modGen.With(daggerQuery(`{foo{myFunction{message, recipient, from, timestamp}}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"foo":{"myFunction":{"message":"foo", "recipient":"user", "from":"admin", "timestamp":"now"}}}`, out)
})
}
}
func TestModuleReturnNestedObject(t *testing.T) {
t.Parallel()
type testCase struct { |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.