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
timestamp[us, tz=UTC] | language
stringclasses 5
values | commit_datetime
timestamp[us, tz=UTC] | updated_file
stringlengths 7
188
| chunk_content
stringlengths 1
1.03M
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | cmd/dagger/module.go | fn func(context.Context, *client.Client, *dagger.Module, *cobra.Command, []string) error,
presetSecretToken string,
) func(*cobra.Command, []string) error {
return func(cmd *cobra.Command, cmdArgs []string) error {
return withEngineAndTUI(cmd.Context(), client.Params{
SecretToken: presetSecretToken,
}, func(ctx context.Context, engineClient *client.Client) (err error) {
modConf, err := getDefaultModuleConfiguration(ctx, engineClient.Dagger(), true)
if err != nil {
return fmt.Errorf("failed to get configured module: %w", err)
}
var loadedMod *dagger.Module
if modConf.FullyInitialized() {
loadedMod = modConf.Source.AsModule().Initialize()
_, err := loadedMod.Serve(ctx)
if err != nil {
return fmt.Errorf("failed to serve module: %w", err)
}
}
return fn(ctx, engineClient, loadedMod, cmd, cmdArgs)
})
}
}
func loadModTypeDefs(ctx context.Context, dag *dagger.Client, mod *dagger.Module) (*moduleDef, error) {
var res struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | cmd/dagger/module.go | TypeDefs []*modTypeDef
}
const query = `
fragment TypeDefRefParts on TypeDef {
kind
optional
asObject {
name
}
asInterface {
name
}
asInput {
name
}
asList {
elementTypeDef {
kind
asObject {
name
}
asInterface {
name
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | cmd/dagger/module.go | asInput {
name
}
}
}
}
fragment FunctionParts on Function {
name
description
returnType {
...TypeDefRefParts
}
args {
name
description
defaultValue
typeDef {
...TypeDefRefParts
}
}
}
fragment FieldParts on FieldTypeDef {
name
description
typeDef {
...TypeDefRefParts
}
}
query TypeDefs($module: ModuleID!) {
typeDefs: currentTypeDefs { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | cmd/dagger/module.go | kind
optional
asObject {
name
sourceModuleName
constructor {
...FunctionParts
}
functions {
...FunctionParts
}
fields {
...FieldParts
}
}
asInterface {
name
sourceModuleName
functions {
...FunctionParts
}
}
asInput {
name
fields {
...FieldParts
}
}
}
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | cmd/dagger/module.go | `
err := dag.Do(ctx, &dagger.Request{
Query: query,
Variables: map[string]interface{}{
"module": mod,
},
}, &dagger.Response{
Data: &res,
})
if err != nil {
return nil, fmt.Errorf("query module objects: %w", err)
}
name, err := mod.Name(ctx)
if err != nil {
return nil, fmt.Errorf("get module name: %w", err)
}
modDef := &moduleDef{Name: name}
for _, typeDef := range res.TypeDefs {
switch typeDef.Kind {
case dagger.ObjectKind:
modDef.Objects = append(modDef.Objects, typeDef)
case dagger.InterfaceKind:
modDef.Interfaces = append(modDef.Interfaces, typeDef)
case dagger.InputKind:
modDef.Inputs = append(modDef.Inputs, typeDef)
}
}
return modDef, nil
}
type moduleDef struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | cmd/dagger/module.go | Name string
Objects []*modTypeDef
Interfaces []*modTypeDef
Inputs []*modTypeDef
}
func (m *moduleDef) AsFunctionProviders() []functionProvider {
providers := make([]functionProvider, 0, len(m.Objects)+len(m.Interfaces))
for _, obj := range m.AsObjects() {
providers = append(providers, obj)
}
for _, iface := range m.AsInterfaces() {
providers = append(providers, iface)
}
return providers
}
func (m *moduleDef) AsObjects() []*modObject {
var defs []*modObject
for _, typeDef := range m.Objects {
if typeDef.AsObject != nil {
defs = append(defs, typeDef.AsObject)
}
}
return defs
}
func (m *moduleDef) AsInterfaces() []*modInterface {
var defs []*modInterface |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | cmd/dagger/module.go | for _, typeDef := range m.Interfaces {
if typeDef.AsInterface != nil {
defs = append(defs, typeDef.AsInterface)
}
}
return defs
}
func (m *moduleDef) AsInputs() []*modInput {
var defs []*modInput
for _, typeDef := range m.Inputs {
if typeDef.AsInput != nil {
defs = append(defs, typeDef.AsInput)
}
}
return defs
}
func (m *moduleDef) GetObject(name string) *modObject {
for _, obj := range m.AsObjects() {
if gqlObjectName(obj.Name) == gqlObjectName(name) {
return obj
}
}
return nil
}
func (m *moduleDef) GetInterface(name string) *modInterface {
for _, iface := range m.AsInterfaces() {
if gqlObjectName(iface.Name) == gqlObjectName(name) {
return iface |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | cmd/dagger/module.go | }
}
return nil
}
func (m *moduleDef) GetFunctionProvider(name string) functionProvider {
if obj := m.GetObject(name); obj != nil {
return obj
}
if iface := m.GetInterface(name); iface != nil {
return iface
}
return nil
}
func (m *moduleDef) GetInput(name string) *modInput {
for _, input := range m.AsInputs() {
if gqlObjectName(input.Name) == gqlObjectName(name) {
return input
}
}
return nil
}
func (m *moduleDef) GetMainObject() *modObject {
return m.GetObject(m.Name)
}
func (m *moduleDef) LoadTypeDef(typeDef *modTypeDef) {
if typeDef.AsObject != nil && typeDef.AsObject.Functions == nil && typeDef.AsObject.Fields == nil {
obj := m.GetObject(typeDef.AsObject.Name)
if obj != nil {
typeDef.AsObject = obj |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | cmd/dagger/module.go | }
}
if typeDef.AsInterface != nil && typeDef.AsInterface.Functions == nil {
iface := m.GetInterface(typeDef.AsInterface.Name)
if iface != nil {
typeDef.AsInterface = iface
}
}
if typeDef.AsInput != nil && typeDef.AsInput.Fields == nil {
input := m.GetInput(typeDef.AsInput.Name)
if input != nil {
typeDef.AsInput = input
}
}
if typeDef.AsList != nil {
m.LoadTypeDef(typeDef.AsList.ElementTypeDef)
}
}
type modTypeDef struct {
Kind dagger.TypeDefKind
Optional bool
AsObject *modObject
AsInterface *modInterface
AsInput *modInput
AsList *modList
}
type functionProvider interface {
ProviderName() string
GetFunctions() []*modFunction
GetFunction(name string) (*modFunction, error) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | cmd/dagger/module.go | }
func (t *modTypeDef) Name() string {
if t.AsObject != nil {
return t.AsObject.Name
}
if t.AsInterface != nil {
return t.AsInterface.Name
}
return ""
}
func (t *modTypeDef) AsFunctionProvider() functionProvider {
if t.AsObject != nil {
return t.AsObject
}
if t.AsInterface != nil {
return t.AsInterface
}
return nil
}
type modObject struct {
Name string
Functions []*modFunction
Fields []*modField
Constructor *modFunction
SourceModuleName string
}
var _ functionProvider = (*modObject)(nil)
func (o *modObject) ProviderName() string {
return o.Name
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | cmd/dagger/module.go | func (o *modObject) GetFunctions() []*modFunction {
fns := make([]*modFunction, 0, len(o.Functions)+len(o.Fields))
for _, f := range o.Fields {
fns = append(fns, &modFunction{
Name: f.Name,
Description: f.Description,
ReturnType: f.TypeDef,
})
}
fns = append(fns, o.Functions...)
return fns
}
func (o *modObject) GetFunction(name string) (*modFunction, error) {
for _, fn := range o.Functions {
if fn.Name == name || cliName(fn.Name) == name {
return fn, nil
}
}
for _, f := range o.Fields {
if f.Name == name || cliName(f.Name) == name {
return &modFunction{
Name: f.Name,
Description: f.Description,
ReturnType: f.TypeDef,
}, nil
}
}
return nil, fmt.Errorf("no function '%s' in object type '%s'", name, o.Name)
}
type modInterface struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | cmd/dagger/module.go | Name string
Functions []*modFunction
}
var _ functionProvider = (*modInterface)(nil)
func (o *modInterface) ProviderName() string {
return o.Name
}
func (o *modInterface) GetFunctions() []*modFunction {
fns := make([]*modFunction, 0, len(o.Functions))
fns = append(fns, o.Functions...)
return fns
}
func (o *modInterface) GetFunction(name string) (*modFunction, error) {
for _, fn := range o.Functions {
if fn.Name == name || cliName(fn.Name) == name {
return fn, nil
}
}
return nil, fmt.Errorf("no function '%s' in interface type '%s'", name, o.Name)
}
type modInput struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | cmd/dagger/module.go | Name string
Fields []*modField
}
type modList struct {
ElementTypeDef *modTypeDef
}
type modField struct {
Name string
Description string
TypeDef *modTypeDef
}
type modFunction struct {
Name string
Description string
ReturnType *modTypeDef
Args []*modFunctionArg
}
type modFunctionArg struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | cmd/dagger/module.go | Name string
Description string
TypeDef *modTypeDef
DefaultValue dagger.JSON
flagName string
}
func (r *modFunctionArg) FlagName() string {
if r.flagName == "" {
r.flagName = cliName(r.Name)
}
return r.flagName
}
func getDefaultValue[T any](r *modFunctionArg) (T, error) {
var val T
err := json.Unmarshal([]byte(r.DefaultValue), &val)
return val, err
}
func gqlObjectName(name string) string {
return strcase.ToCamel(name)
}
func gqlFieldName(name string) string {
return strcase.ToLowerCamel(name)
}
func gqlArgName(name string) string {
return strcase.ToLowerCamel(name)
}
func cliName(name string) string {
return strcase.ToKebab(name)
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | core/integration/module_config_test.go | package core
import (
"encoding/json"
"strings"
"testing"
"dagger.io/dagger"
"github.com/dagger/dagger/core/modules"
"github.com/stretchr/testify/require"
)
func TestModuleConfigs(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | core/integration/module_config_test.go | t.Parallel()
t.Run("upgrade from old config", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
baseWithOldConfig := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work/foo").
With(daggerExec("init", "--source=.", "--name=dep", "--sdk=go")).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=test", "--sdk=go")).
WithNewFile("/work/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
type Test struct {}
func (m *Test) Fn() string { return "wowzas" }
`,
}).
WithNewFile("/work/dagger.json", dagger.ContainerWithNewFileOpts{
Contents: `{"name": "test", "sdk": "go", "include": ["foo"], "exclude": ["blah"], "dependencies": ["foo"]}`,
})
baseWithNewConfig := baseWithOldConfig.With(daggerExec("develop"))
confContents, err := baseWithNewConfig.File("dagger.json").Contents(ctx)
require.NoError(t, err) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | core/integration/module_config_test.go | var modCfg modules.ModuleConfig
require.NoError(t, json.Unmarshal([]byte(confContents), &modCfg))
require.Equal(t, "test", modCfg.Name)
require.Equal(t, "go", modCfg.SDK)
require.Equal(t, []string{"foo"}, modCfg.Include)
require.Equal(t, []string{"blah"}, modCfg.Exclude)
require.Len(t, modCfg.Dependencies, 1)
require.Equal(t, "foo", modCfg.Dependencies[0].Source)
require.Equal(t, "dep", modCfg.Dependencies[0].Name)
require.Equal(t, ".", modCfg.Source)
require.NotEmpty(t, modCfg.EngineVersion)
out, err := baseWithNewConfig.With(daggerCall("fn")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "wowzas", strings.TrimSpace(out))
out, err = baseWithOldConfig.With(daggerCall("fn")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "wowzas", strings.TrimSpace(out))
})
t.Run("dep has separate config", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
base := goGitBase(t, c).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work/subdir/dep").
With(daggerExec("init", "--source=.", "--name=dep", "--sdk=go")).
WithNewFile("/work/subdir/dep/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | core/integration/module_config_test.go | import "context"
type Dep struct {}
func (m *Dep) DepFn(ctx context.Context, str string) string { return str }
`,
}).
WithWorkdir("/work").
With(daggerExec("init", "--source=test", "--name=test", "--sdk=go", "test")).
With(daggerExec("install", "-m=test", "./subdir/dep")).
WithNewFile("/work/test/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
type Test struct {}
func (m *Test) Fn(ctx context.Context) (string, error) { return dag.Dep().DepFn(ctx, "hi dep") }
`,
})
t.Run("from src dir", func(t *testing.T) {
t.Parallel()
out, err := base.WithWorkdir("test").With(daggerCall("fn")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "hi dep", strings.TrimSpace(out))
})
t.Run("from src root", func(t *testing.T) {
t.Parallel()
out, err := base.With(daggerCallAt("test", "fn")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "hi dep", strings.TrimSpace(out))
})
t.Run("from root", func(t *testing.T) {
t.Parallel() |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | core/integration/module_config_test.go | out, err := base.WithWorkdir("/").With(daggerCallAt("work/test", "fn")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "hi dep", strings.TrimSpace(out))
})
t.Run("from dep parent", func(t *testing.T) {
t.Parallel()
out, err := base.WithWorkdir("/work/subdir").With(daggerCallAt("../test", "fn")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "hi dep", strings.TrimSpace(out))
})
t.Run("from dep dir", func(t *testing.T) {
t.Parallel()
out, err := base.WithWorkdir("/work/subdir/dep").With(daggerCallAt("../../test", "fn")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "hi dep", strings.TrimSpace(out))
})
})
t.Run("install dep from weird places", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
base := goGitBase(t, c).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--source=subdir/dep", "--name=dep", "--sdk=go", "subdir/dep")).
WithNewFile("/work/subdir/dep/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
type Dep struct {}
func (m *Dep) DepFn(ctx context.Context, str string) string { return str }
`, |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | core/integration/module_config_test.go | }).
With(daggerExec("init", "--source=test", "--name=test", "--sdk=go", "test")).
WithNewFile("/work/test/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
type Test struct {}
func (m *Test) Fn(ctx context.Context) (string, error) { return dag.Dep().DepFn(ctx, "hi dep") }
`,
})
t.Run("from src dir", func(t *testing.T) {
t.Parallel()
out, err := base.
WithWorkdir("/work/test").
With(daggerExec("install", "../subdir/dep")).
With(daggerCall("fn")).
Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "hi dep", strings.TrimSpace(out))
})
t.Run("from root", func(t *testing.T) {
t.Parallel()
out, err := base.
WithWorkdir("/").
With(daggerExec("install", "-m=./work/test", "./work/subdir/dep")).
WithWorkdir("/work/test").
With(daggerCall("fn")).
Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "hi dep", strings.TrimSpace(out)) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | core/integration/module_config_test.go | })
t.Run("from dep", func(t *testing.T) {
t.Parallel()
out, err := base.
WithWorkdir("/work/subdir/dep").
With(daggerExec("install", "-m=../../test", ".")).
WithWorkdir("/work/test").
With(daggerCall("fn")).
Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "hi dep", strings.TrimSpace(out))
})
t.Run("from random place", func(t *testing.T) {
t.Parallel()
out, err := base.
WithWorkdir("/var").
With(daggerExec("install", "-m=../work/test", "../work/subdir/dep")).
WithWorkdir("/work/test").
With(daggerCall("fn")).
Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "hi dep", strings.TrimSpace(out))
})
})
t.Run("install out of tree dep fails", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
base := goGitBase(t, c).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/play/dep"). |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | core/integration/module_config_test.go | With(daggerExec("init", "--name=dep", "--sdk=go")).
WithWorkdir("/work/test").
With(daggerExec("init", "--name=test", "--sdk=go"))
t.Run("from src dir", func(t *testing.T) {
t.Parallel()
_, err := base.
WithWorkdir("/work/test").
With(daggerExec("install", "../../play/dep")).
Sync(ctx)
require.ErrorContains(t, err, `local module dep source path "../play/dep" escapes context "/work"`)
})
t.Run("from dep dir", func(t *testing.T) {
t.Parallel()
_, err := base.
WithWorkdir("/play/dep").
With(daggerExec("install", "-m=../../work/test", ".")).
Sync(ctx)
require.ErrorContains(t, err, `module dep source path "../play/dep" escapes context "/work"`)
})
t.Run("from root", func(t *testing.T) {
t.Parallel()
_, err := base.
WithWorkdir("/").
With(daggerExec("install", "-m=work/test", "play/dep")).
Sync(ctx)
require.ErrorContains(t, err, `module dep source path "../play/dep" escapes context "/work"`)
})
})
t.Run("malicious config", func(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | core/integration/module_config_test.go | t.Parallel()
c, ctx := connect(t)
base := goGitBase(t, c).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work/dep").
With(daggerExec("init", "--source=.", "--name=dep", "--sdk=go")).
WithNewFile("/work/dep/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
type Dep struct {}
func (m *Dep) GetSource(ctx context.Context) *Directory {
return dag.CurrentModule().Source()
}
`,
}).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=test", "--sdk=go"))
t.Run("source points out of root", func(t *testing.T) {
t.Parallel()
base := base.
With(configFile(".", &modules.ModuleConfig{
Name: "evil",
SDK: "go",
Source: "..",
}))
_, err := base.With(daggerCall("container-echo", "--string-arg", "plz fail")).Sync(ctx)
require.ErrorContains(t, err, `local module source path ".." escapes context "/work"`)
_, err = base.With(daggerExec("develop")).Sync(ctx)
require.ErrorContains(t, err, `local module source path ".." escapes context "/work"`)
_, err = base.With(daggerExec("install", "./dep")).Sync(ctx) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | core/integration/module_config_test.go | require.ErrorContains(t, err, `local module source path ".." escapes context "/work"`)
})
t.Run("dep points out of root", func(t *testing.T) {
t.Parallel()
base := base.
With(configFile(".", &modules.ModuleConfig{
Name: "evil",
SDK: "go",
Dependencies: []*modules.ModuleConfigDependency{{
Name: "escape",
Source: "..",
}},
}))
_, err := base.With(daggerCall("container-echo", "--string-arg", "plz fail")).Sync(ctx)
require.ErrorContains(t, err, `local module dep source path ".." escapes context "/work"`)
_, err = base.With(daggerExec("develop")).Sync(ctx)
require.ErrorContains(t, err, `local module dep source path ".." escapes context "/work"`)
_, err = base.With(daggerExec("install", "./dep")).Sync(ctx)
require.ErrorContains(t, err, `local module dep source path ".." escapes context "/work"`)
})
})
}
func TestModuleCustomDepNames(t *testing.T) {
t.Parallel()
t.Run("basic", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
ctr := goGitBase(t, c).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work/dep"). |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | core/integration/module_config_test.go | With(daggerExec("init", "--source=.", "--name=dep", "--sdk=go")).
WithNewFile("/work/dep/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
type Dep struct {}
func (m *Dep) DepFn(ctx context.Context) string {
return "hi from dep"
}
func (m *Dep) GetDepObj(ctx context.Context) *DepObj {
return &DepObj{Str: "yo from dep"}
}
type DepObj struct {
Str string
}
func (m *Dep) GetOtherObj(ctx context.Context) *OtherObj {
return &OtherObj{Str: "hey from dep"}
}
type OtherObj struct {
Str string
}
`,
}).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=test", "--sdk=go")).
With(daggerExec("install", "--name", "foo", "./dep")).
WithNewFile("/work/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
type Test struct {}
func (m *Test) Fn(ctx context.Context) (string, error) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | core/integration/module_config_test.go | return dag.Foo().DepFn(ctx)
}
func (m *Test) GetObj(ctx context.Context) (string, error) {
var obj *FooObj
obj = dag.Foo().GetDepObj()
return obj.Str(ctx)
}
func (m *Test) GetOtherObj(ctx context.Context) (string, error) {
var obj *FooOtherObj
obj = dag.Foo().GetOtherObj()
return obj.Str(ctx)
}
func (m *Test) GetConflictNameObj(ctx context.Context) *Dep {
return &Dep{Str: "it worked?"}
}
// should not be any name conflict with dep
type Dep struct {
Str string
}
`,
})
out, err := ctr.With(daggerCall("fn")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "hi from dep", strings.TrimSpace(out))
out, err = ctr.With(daggerCall("get-obj")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "yo from dep", strings.TrimSpace(out))
out, err = ctr.With(daggerCall("get-other-obj")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "hey from dep", strings.TrimSpace(out)) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | core/integration/module_config_test.go | out, err = ctr.With(daggerCall("get-conflict-name-obj", "str")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "it worked?", strings.TrimSpace(out))
})
t.Run("same mod name as dep", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
ctr := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work/dep").
With(daggerExec("init", "--source=.", "--name=test", "--sdk=go")).
WithNewFile("/work/dep/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
type Test struct {}
func (m *Test) Fn(ctx context.Context) string {
return "hi from dep"
}
`,
}).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=test", "--sdk=go")).
With(daggerExec("install", "--name", "foo", "./dep")).
WithNewFile("/work/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
type Test struct {}
func (m *Test) Fn(ctx context.Context) (string, error) {
return dag.Foo().Fn(ctx)
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | core/integration/module_config_test.go | `,
})
out, err := ctr.With(daggerCall("fn")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "hi from dep", strings.TrimSpace(out))
})
t.Run("two deps with same name", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
ctr := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work/dep1").
With(daggerExec("init", "--source=.", "--name=dep", "--sdk=go")).
WithNewFile("/work/dep1/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
type Dep struct {}
func (m *Dep) Fn(ctx context.Context) string {
return "hi from dep1"
}
`,
}).
WithWorkdir("/work/dep2").
With(daggerExec("init", "--source=.", "--name=dep", "--sdk=go")).
WithNewFile("/work/dep2/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
type Dep struct {}
func (m *Dep) Fn(ctx context.Context) string {
return "hi from dep2" |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | core/integration/module_config_test.go | }
`,
}).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=test", "--sdk=go")).
With(daggerExec("install", "--name", "foo", "./dep1")).
With(daggerExec("install", "--name", "bar", "./dep2")).
WithNewFile("/work/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
type Test struct {}
func (m *Test) Fn(ctx context.Context) (string, error) {
dep1, err := dag.Foo().Fn(ctx)
if err != nil {
return "", err
}
dep2, err := dag.Bar().Fn(ctx)
if err != nil {
return "", err
}
return dep1 + " " + dep2, nil
}
`,
})
out, err := ctr.With(daggerCall("fn")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "hi from dep1 hi from dep2", strings.TrimSpace(out))
})
}
func TestModuleDaggerInit(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | core/integration/module_config_test.go | t.Parallel()
t.Run("name defaults to source root dir name", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
out, err := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--source=coolmod", "--sdk=go", "coolmod")).
WithNewFile("/work/coolmod/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
type Coolmod struct {}
func (m *Coolmod) Fn(ctx context.Context) (string, error) {
return dag.CurrentModule().Name(ctx)
}
`,
}).
With(daggerCallAt("coolmod", "fn")).
Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "coolmod", strings.TrimSpace(out))
})
t.Run("source dir default", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
ctr := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work")
for _, tc := range []struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | core/integration/module_config_test.go | sdk string
sourceDirEnt string
}{
{
sdk: "go",
sourceDirEnt: "main.go",
},
{
sdk: "python",
sourceDirEnt: "src",
},
{
sdk: "typescript",
sourceDirEnt: "src",
},
} {
tc := tc
t.Run(tc.sdk, func(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | core/integration/module_config_test.go | t.Parallel()
srcRootDir := ctr.
With(daggerExec("init", "--name=test", "--sdk="+tc.sdk)).
Directory(".")
srcRootEnts, err := srcRootDir.Entries(ctx)
require.NoError(t, err)
require.Contains(t, srcRootEnts, "dagger.json")
require.NotContains(t, srcRootEnts, tc.sourceDirEnt)
srcDirEnts, err := srcRootDir.Directory("dagger").Entries(ctx)
require.NoError(t, err)
require.Contains(t, srcDirEnts, tc.sourceDirEnt)
})
}
})
t.Run("source is made rel to source root by engine", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
ctr := goGitBase(t, c).
WithWorkdir("/var").
With(daggerExec("init", "--source=../work/some/subdir", "--name=test", "--sdk=go", "../work")).
With(daggerCallAt("../work", "container-echo", "--string-arg", "yo", "stdout"))
out, err := ctr.Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "yo", strings.TrimSpace(out))
ents, err := ctr.Directory("/work/some/subdir").Entries(ctx)
require.NoError(t, err)
require.Contains(t, ents, "main.go")
})
}
func TestModuleDaggerDevelop(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | core/integration/module_config_test.go | t.Parallel()
t.Run("name and sdk", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
ctr := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work/dep").
With(daggerExec("init", "--source=.", "--name=dep", "--sdk=go")).
WithNewFile("/work/dep/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
type Dep struct {}
func (m *Dep) Fn(ctx context.Context) string {
return "hi from dep"
}
`,
}).
WithWorkdir("/work").
With(daggerExec("init")). |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | core/integration/module_config_test.go | With(daggerExec("install", "./dep"))
out, err := ctr.With(daggerCallAt("dep", "fn")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "hi from dep", strings.TrimSpace(out))
ctr = ctr.
With(daggerExec("develop", "--sdk", "go", "--source", "cool/subdir")).
WithNewFile("/work/cool/subdir/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
type Work struct {}
func (m *Work) Fn(ctx context.Context) (string, error) {
depStr, err := dag.Dep().Fn(ctx)
if err != nil {
return "", err
}
return "hi from work " + depStr, nil
}
`,
})
out, err = ctr.With(daggerCall("fn")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "hi from work hi from dep", strings.TrimSpace(out))
_, err = ctr.With(daggerExec("develop", "--sdk", "python")).Sync(ctx)
require.ErrorContains(t, err, `cannot update module SDK that has already been set to "go"`)
_, err = ctr.With(daggerExec("develop", "--source", "blahblahblaha/blah")).Sync(ctx)
require.ErrorContains(t, err, `cannot update module source path that has already been set to "cool/subdir"`) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | core/integration/module_config_test.go | })
t.Run("source is made rel to source root by engine", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
ctr := goGitBase(t, c).
WithWorkdir("/work/dep").
With(daggerExec("init", "--source=.", "--name=dep", "--sdk=go")).
WithNewFile("/work/dep/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
type Dep struct {}
func (m *Dep) Fn(ctx context.Context) string {
return "hi from dep"
}
`,
}).
WithWorkdir("/work").
With(daggerExec("init")).
With(daggerExec("install", "./dep")).
WithWorkdir("/var").
With(daggerExec("develop", "-m", "../work", "--source=../work/some/subdir", "--sdk=go")).
WithNewFile("/work/some/subdir/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
type Work struct {}
func (m *Work) Fn(ctx context.Context) (string, error) {
depStr, err := dag.Dep().Fn(ctx)
if err != nil {
return "", err
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | core/integration/module_config_test.go | return "hi from work " + depStr, nil
}
`,
})
out, err := ctr.With(daggerCallAt("../work", "fn")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "hi from work hi from dep", strings.TrimSpace(out))
ents, err := ctr.Directory("/work/some/subdir").Entries(ctx)
require.NoError(t, err)
require.Contains(t, ents, "main.go")
})
}
func TestModuleDaggerConfig(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
out, err := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=test", "--sdk=go", "test")).
With(daggerExec("config", "-m", "test")).
Stdout(ctx)
require.NoError(t, err)
require.Regexp(t, `Name:\s+test`, out)
require.Regexp(t, `SDK:\s+go`, out)
require.Regexp(t, `Root Directory:\s+/work`, out)
require.Regexp(t, `Source Directory:\s+/work/test`, out)
}
func TestModuleIncludeExclude(t *testing.T) {
t.Parallel()
for _, tc := range []struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | core/integration/module_config_test.go | sdk string
mainSource string
customSDKSource string
customSDKUnderlyingSDK string
}{
{
sdk: "go",
mainSource: `package main
type Test struct {}
func (m *Test) Fn() *Directory {
return dag.CurrentModule().Source()
}
`,
},
{
sdk: "python", |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | core/integration/module_config_test.go | mainSource: `import dagger
from dagger import dag, function, object_type
@object_type
class Test:
@function
def fn(self) -> dagger.Directory:
return dag.current_module().source()
`,
},
{
sdk: "typescript",
mainSource: `
import { dag, Directory, object, func } from "@dagger.io/dagger"
@object()
class Test {
@func()
fn(): Directory {
return dag.currentModule().source()
}
}`,
},
{
sdk: "coolsdk",
mainSource: `package main
type Test struct {}
func (m *Test) Fn() *Directory {
return dag.CurrentModule().Source()
}
`,
customSDKUnderlyingSDK: "go", |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | core/integration/module_config_test.go | customSDKSource: `package main
type Coolsdk struct {}
func (m *Coolsdk) ModuleRuntime(modSource *ModuleSource, introspectionJson string) *Container {
return modSource.WithSDK("go").AsModule().Runtime().WithEnvVariable("COOL", "true")
}
func (m *Coolsdk) Codegen(modSource *ModuleSource, introspectionJson string) *GeneratedCode {
return dag.GeneratedCode(modSource.WithSDK("go").AsModule().GeneratedContextDirectory())
}
func (m *Coolsdk) RequiredPaths() []string {
return []string{
"**/go.mod",
"**/go.sum",
"**/go.work",
"**/go.work.sum",
"**/vendor/",
"**/*.go",
}
}
`,
},
} {
tc := tc
t.Run(tc.sdk, func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
ctr := goGitBase(t, c).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work")
if tc.customSDKSource != "" { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | core/integration/module_config_test.go | ctr = ctr.
WithWorkdir("/work/" + tc.sdk).
With(daggerExec("init", "--name="+tc.sdk, "--sdk="+tc.customSDKUnderlyingSDK)).
With(sdkSource(tc.customSDKUnderlyingSDK, tc.customSDKSource)).
WithWorkdir("/work")
}
ctr = ctr.With(daggerExec("init", "--name=test", "--sdk="+tc.sdk))
if tc.customSDKSource != "" {
ctr = ctr.WithNewFile("dagger/main.go", dagger.ContainerWithNewFileOpts{
Contents: tc.mainSource,
})
} else {
ctr = ctr.With(sdkSource(tc.sdk, tc.mainSource))
}
ctr = ctr.
With(configFile(".", &modules.ModuleConfig{
Name: "test",
SDK: tc.sdk,
Include: []string{"dagger/subdir/keepdir"},
Exclude: []string{"dagger/subdir/keepdir/rmdir"},
Source: "dagger",
})).
WithDirectory("dagger/subdir/keepdir/rmdir", c.Directory())
out, err := ctr.
With(daggerCall("fn", "directory", "--path", "subdir", "entries")).
Stdout(ctx) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | core/integration/module_config_test.go | require.NoError(t, err)
require.Equal(t, "keepdir", strings.TrimSpace(out))
out, err = ctr.
With(daggerCall("fn", "directory", "--path", "subdir/keepdir", "entries")).
Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "", strings.TrimSpace(out))
out, err = ctr.
WithWorkdir("/mnt").
With(daggerCallAt("../work", "fn", "directory", "--path", "subdir", "entries")).
Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "keepdir", strings.TrimSpace(out))
ctr = ctr.With(daggerExec("develop"))
out, err = ctr.
With(daggerCall("fn", "directory", "--path", "subdir", "entries")).
Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "keepdir", strings.TrimSpace(out))
out, err = ctr.
With(daggerCall("fn", "directory", "--path", "subdir/keepdir", "entries")).
Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "", strings.TrimSpace(out))
})
}
}
func TestModuleContextDefaultsToSourceRoot(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | core/integration/module_config_test.go | t.Parallel()
c, ctx := connect(t)
ctr := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work/coolsdk").
With(daggerExec("init", "--source=.", "--name=cool-sdk", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
type CoolSdk struct {}
func (m *CoolSdk) ModuleRuntime(modSource *ModuleSource, introspectionJson string) *Container {
return modSource.WithSDK("go").AsModule().Runtime().
WithMountedDirectory("/da-context", modSource.ContextDirectory())
}
func (m *CoolSdk) Codegen(modSource *ModuleSource, introspectionJson string) *GeneratedCode {
return dag.GeneratedCode(modSource.WithSDK("go").AsModule().GeneratedContextDirectory())
}
func (m *CoolSdk) RequiredPaths() []string {
return []string{
"**/go.mod",
"**/go.sum",
"**/go.work",
"**/go.work.sum",
"**/vendor/",
"**/*.go",
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | core/integration/module_config_test.go | }
`,
}).
WithWorkdir("/work").
WithNewFile("random-file").
With(daggerExec("init", "--source=.", "--name=test", "--sdk=coolsdk")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "os"
type Test struct {}
func (m *Test) Fn() ([]string, error) {
ents, err := os.ReadDir("/da-context")
if err != nil {
return nil, err
}
var names []string
for _, ent := range ents {
names = append(names, ent.Name())
}
return names, nil
}
`,
})
out, err := ctr.
With(daggerCall("fn")).
Stdout(ctx)
require.NoError(t, err)
require.Contains(t, strings.TrimSpace(out), "random-file")
}
func TestModuleDaggerInstallGit(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | core/integration/module_config_test.go | /*
TODO: this is a stopgap test to get some basic coverage of installing modules
from git refs. Ideally it would rely on our own repo for of test fixtures but
those have not been setup yet: https://github.com/dagger/dagger/issues/6623
*/
t.Parallel()
c, ctx := connect(t)
_, err := goGitBase(t, c).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=test", "--sdk=go")).
With(daggerExec("install", "github.com/sagikazarmark/daggerverse/archivist@bedfa0c8bdba7192c65c21b5e88a48b600666fcc")).
Sync(ctx)
require.NoError(t, err)
c.ModuleSource("github.com/sagikazarmark/daggerverse/archivist@bedfa0c8bdba7192c65c21b5e88a48b600666fcc").
AsGitSource().
HTMLURL(ctx)
}
func TestModuleDaggerGitRefs(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,664 | Unable to reference remote modules by short name | Version: 0.9.10
What I expect to work:
```sh
dagger init
dagger install github.com/shykes/daggerverse/hello
dagger -m hello functions
```
What I get:
`Error: failed to get configured module: failed to get local root path: input: resolve: moduleSource: resolveContextPathFromCaller: cannot resolve non-local module source from caller`
Additionally, when I run `dagger -m hello functions`, I get local files created mimicking the module's remote ref:
```sh
$ tree github.com
github.com
βββ shykes
βββ daggerverse
βββ hello@ac880927d5368eaf2e5d94450e587732753df1a6
3 directories, 0 files
``` | https://github.com/dagger/dagger/issues/6664 | https://github.com/dagger/dagger/pull/6668 | 430ea3a7fec9f4e88584e1aa352a7e43c083e518 | 41a311347e4d8539b2206903a5e93acaf1108d34 | 2024-02-13T17:43:20Z | go | 2024-02-19T17:06:53Z | core/integration/module_config_test.go | /*
TODO: this is a stopgap test to get some basic coverage of installing modules
from git refs. Ideally it would rely on our own repo for of test fixtures but
those have not been setup yet: https://github.com/dagger/dagger/issues/6623
*/
t.Parallel()
c, ctx := connect(t)
htmlURL, err := c.ModuleSource("github.com/sagikazarmark/daggerverse/archivist@bedfa0c8bdba7192c65c21b5e88a48b600666fcc").
AsGitSource().
HTMLURL(ctx)
require.NoError(t, err)
require.Equal(t, "https://github.com/sagikazarmark/daggerverse/tree/bedfa0c8bdba7192c65c21b5e88a48b600666fcc/archivist", htmlURL)
} |
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/integration/module_call_test.go | package core
import (
"fmt"
"strings"
"testing"
"dagger.io/dagger"
"github.com/moby/buildkit/identity"
"github.com/stretchr/testify/require"
)
func TestModuleDaggerCallArgTypes(t *testing.T) { |
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/integration/module_call_test.go | t.Parallel()
t.Run("service args", func(t *testing.T) {
t.Parallel()
t.Run("used as service binding", 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", "--source=.", "--name=test", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import (
"context"
)
type Test struct {}
func (m *Test) Fn(ctx context.Context, svc *Service) (string, error) {
return dag.Container().From("alpine:3.18").WithExec([]string{"apk", "add", "curl"}).
WithServiceBinding("daserver", svc).
WithExec([]string{"curl", "http://daserver:8000"}).
Stdout(ctx) |
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/integration/module_call_test.go | }
`,
})
logGen(ctx, t, modGen.Directory("."))
httpServer, _ := httpService(ctx, t, c, "im up")
endpoint, err := httpServer.Endpoint(ctx)
require.NoError(t, err)
out, err := modGen.
WithServiceBinding("testserver", httpServer).
With(daggerCall("fn", "--svc", "tcp://"+endpoint)).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "im up", out)
})
t.Run("used directly", 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", "--source=.", "--name=test", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import (
"context"
"fmt"
"strings"
)
type Test struct {}
func (m *Test) Fn(ctx context.Context, svc *Service) (string, error) {
ports, err := svc.Ports(ctx) |
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/integration/module_call_test.go | if err != nil {
return "", err
}
var out []string
out = append(out, fmt.Sprintf("%d exposed ports:", len(ports)))
for _, port := range ports {
number, err := port.Port(ctx)
if err != nil {
return "", err
}
out = append(out, fmt.Sprintf("- TCP/%d", number))
}
return strings.Join(out, "\n"), nil
}
`,
})
logGen(ctx, t, modGen.Directory("."))
httpServer, _ := httpService(ctx, t, c, "im up")
endpoint, err := httpServer.Endpoint(ctx)
require.NoError(t, err)
out, err := modGen.
WithServiceBinding("testserver", httpServer).
With(daggerCall("fn", "--svc", "tcp://"+endpoint)).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "1 exposed ports:\n- TCP/8000", out)
})
})
t.Run("list args", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t) |
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/integration/module_call_test.go | modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=minimal", "--sdk=go")).
WithNewFile("foo.txt", dagger.ContainerWithNewFileOpts{
Contents: "bar",
}).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import (
"context"
"strings"
)
type Minimal struct {}
func (m *Minimal) Hello(msgs []string) string {
return strings.Join(msgs, "+")
}
func (m *Minimal) Reads(ctx context.Context, files []File) (string, error) {
var contents []string
for _, f := range files {
content, err := f.Contents(ctx)
if err != nil {
return "", err
}
contents = append(contents, content)
}
return strings.Join(contents, "+"), 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/integration/module_call_test.go | logGen(ctx, t, modGen.Directory("."))
out, err := modGen.With(daggerCall("hello", "--msgs", "yo", "--msgs", "my", "--msgs", "friend")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "yo+my+friend", out)
out, err = modGen.With(daggerCall("reads", "--files=foo.txt", "--files=foo.txt")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "bar+bar", out)
})
t.Run("directory arg inputs", func(t *testing.T) {
t.Parallel()
t.Run("local dir", 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", "--source=.", "--name=test", "--sdk=go")).
WithNewFile("/dir/subdir/foo.txt", dagger.ContainerWithNewFileOpts{
Contents: "foo",
}).
WithNewFile("/dir/subdir/bar.txt", dagger.ContainerWithNewFileOpts{
Contents: "bar",
}).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
type Test struct {}
func (m *Test) Fn(dir *Directory) *Directory {
return dir
}
`, |
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/integration/module_call_test.go | })
out, err := modGen.With(daggerCall("fn", "--dir", "/dir/subdir", "entries")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "bar.txt\nfoo.txt\n", out)
out, err = modGen.With(daggerCall("fn", "--dir", "file:///dir/subdir", "entries")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "bar.txt\nfoo.txt\n", out)
})
t.Run("git dir", 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", "--source=.", "--name=test", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
type Test struct {}
func (m *Test) Fn(
dir *Directory,
subpath string, // +optional
) *Directory {
if subpath == "" {
subpath = "."
}
return dir.Directory(subpath)
}
`,
})
for _, tc := range []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/integration/module_call_test.go | baseURL string
subpath string
}{
{
baseURL: "https://github.com/dagger/dagger",
},
{
baseURL: "https://github.com/dagger/dagger",
subpath: ".changes",
},
{
baseURL: "https://github.com/dagger/dagger.git",
},
{
baseURL: "https://github.com/dagger/dagger.git",
subpath: ".changes",
},
} { |
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/integration/module_call_test.go | tc := tc
t.Run(fmt.Sprintf("%s:%s", tc.baseURL, tc.subpath), func(t *testing.T) {
url := tc.baseURL + "#v0.9.1"
if tc.subpath != "" {
url += ":" + tc.subpath
}
args := []string{"fn", "--dir", url}
if tc.subpath == "" {
args = append(args, "--subpath", ".changes")
}
args = append(args, "entries")
out, err := modGen.With(daggerCall(args...)).Stdout(ctx)
require.NoError(t, err)
require.Contains(t, out, "v0.9.1.md")
require.NotContains(t, out, "v0.9.2.md")
})
}
})
})
t.Run("secret args", 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", "--source=.", "--name=test", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
type Test 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/integration/module_call_test.go | func (m *Test) Insecure(ctx context.Context, token *Secret) (string, error) {
return token.Plaintext(ctx)
}
`,
}).
WithEnvVariable("TOPSECRET", "shhh").
WithNewFile("/mysupersecret", dagger.ContainerWithNewFileOpts{Contents: "file shhh"})
t.Run("explicit env", func(t *testing.T) {
t.Run("happy", func(t *testing.T) {
out, err := modGen.With(daggerCall("insecure", "--token", "env:TOPSECRET")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "shhh", out)
})
t.Run("sad", func(t *testing.T) {
_, err := modGen.With(daggerCall("insecure", "--token", "env:NOWHERETOBEFOUND")).Stdout(ctx)
require.ErrorContains(t, err, `secret env var not found: "NOW..."`)
})
})
t.Run("implicit env", func(t *testing.T) {
t.Parallel()
t.Run("happy", func(t *testing.T) {
out, err := modGen.With(daggerCall("insecure", "--token", "TOPSECRET")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "shhh", out)
})
t.Run("sad", func(t *testing.T) {
_, err := modGen.With(daggerCall("insecure", "--token", "NOWHERETOBEFOUND")).Stdout(ctx)
require.ErrorContains(t, err, `secret env var not found: "NOW..."`)
})
}) |
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/integration/module_call_test.go | t.Run("file", func(t *testing.T) {
t.Run("happy", func(t *testing.T) {
out, err := modGen.With(daggerCall("insecure", "--token", "file:/mysupersecret")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "file shhh", out)
})
t.Run("sad", func(t *testing.T) {
_, err := modGen.With(daggerCall("insecure", "--token", "file:/nowheretobefound")).Stdout(ctx)
require.ErrorContains(t, err, `failed to read secret file "/nowheretobefound": open /nowheretobefound: no such file or directory`)
})
})
t.Run("cmd", func(t *testing.T) {
t.Run("happy", func(t *testing.T) {
out, err := modGen.With(daggerCall("insecure", "--token", "cmd:echo -n cmd shhh")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "cmd shhh", out)
})
t.Run("sad", func(t *testing.T) {
_, err := modGen.With(daggerCall("insecure", "--token", "cmd:exit 1")).Stdout(ctx)
require.ErrorContains(t, err, `failed to run secret command "exit 1": exit status 1`)
})
})
t.Run("invalid source", func(t *testing.T) {
_, err := modGen.With(daggerCall("insecure", "--token", "wtf:HUH")).Stdout(ctx)
require.ErrorContains(t, err, `unsupported secret arg source: "wtf"`)
})
})
t.Run("cache volume args", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t) |
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/integration/module_call_test.go | volName := identity.NewID()
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=test", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import (
"context"
)
type Test struct {}
func (m *Test) Cacher(ctx context.Context, cache *CacheVolume, val string) (string, error) {
return dag.Container().
From("` + alpineImage + `").
WithMountedCache("/cache", cache).
WithExec([]string{"sh", "-c", "echo $0 >> /cache/vals", val}).
WithExec([]string{"cat", "/cache/vals"}).
Stdout(ctx)
}
`,
})
out, err := modGen.With(daggerCall("cacher", "--cache", volName, "--val", "foo")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "foo\n", out)
out, err = modGen.With(daggerCall("cacher", "--cache", volName, "--val", "bar")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "foo\nbar\n", out)
})
}
func TestModuleDaggerCallReturnTypes(t *testing.T) { |
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/integration/module_call_test.go | t.Parallel()
t.Run("return list objects", 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", "--source=.", "--name=minimal", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
type Minimal struct {}
type Foo struct {
Bar int ` + "`" + `json:"bar"` + "`" + `
}
func (m *Minimal) Fn() []*Foo { |
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/integration/module_call_test.go | var foos []*Foo
for i := 0; i < 3; i++ {
foos = append(foos, &Foo{Bar: i})
}
return foos
}
`,
})
logGen(ctx, t, modGen.Directory("."))
expected := "0\n1\n2\n"
t.Run("print", func(t *testing.T) {
out, err := modGen.With(daggerCall("fn", "bar")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, expected, out)
})
t.Run("output", func(t *testing.T) {
out, err := modGen.
With(daggerCall("fn", "bar", "-o", "./outfile")).
File("./outfile").
Contents(ctx)
require.NoError(t, err)
require.Equal(t, expected, out)
})
t.Run("json", func(t *testing.T) {
out, err := modGen.
With(daggerCall("fn", "bar", "--json")).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `[{"bar": 0}, {"bar": 1}, {"bar": 2}]`, out)
}) |
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/integration/module_call_test.go | })
t.Run("return container", 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", "--source=.", "--name=test", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
func New() *Test {
return &Test{Ctr: dag.Container().From("alpine:3.18").WithExec([]string{"echo", "hello", "world"})}
}
type Test struct {
Ctr *Container
}
`,
})
logGen(ctx, t, modGen.Directory("."))
t.Run("default", func(t *testing.T) {
ctr := modGen.With(daggerCall("ctr"))
out, err := ctr.Stdout(ctx)
require.NoError(t, err)
require.Empty(t, out)
out, err = ctr.Stderr(ctx)
require.NoError(t, err)
require.Contains(t, out, "Container evaluated")
})
t.Run("output", func(t *testing.T) {
modGen, err := modGen.With(daggerCall("ctr", "-o", "./container.tar")).Sync(ctx) |
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/integration/module_call_test.go | require.NoError(t, err)
size, err := modGen.File("./container.tar").Size(ctx)
require.NoError(t, err)
require.Greater(t, size, 0)
_, err = modGen.WithExec([]string{"tar", "tf", "./container.tar", "oci-layout"}).Sync(ctx)
require.NoError(t, err)
})
})
t.Run("return directory", 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", "--source=.", "--name=test", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
func New() *Test {
return &Test{
Dir: dag.Directory().WithNewFile("foo.txt", "foo").WithNewFile("bar.txt", "bar"),
}
}
type Test struct {
Dir *Directory
}
`,
})
logGen(ctx, t, modGen.Directory("."))
t.Run("default", func(t *testing.T) {
ctr := modGen.With(daggerCall("dir")) |
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/integration/module_call_test.go | out, err := ctr.Stdout(ctx)
require.NoError(t, err)
require.Empty(t, out)
out, err = ctr.Stderr(ctx)
require.NoError(t, err)
require.Contains(t, out, "Directory evaluated")
})
t.Run("output", func(t *testing.T) {
modGen, err := modGen.With(daggerCall("dir", "-o", "./outdir")).Sync(ctx)
require.NoError(t, err)
entries, err := modGen.Directory("./outdir").Entries(ctx)
require.NoError(t, err)
require.Equal(t, "bar.txt\nfoo.txt", strings.Join(entries, "\n"))
foo, err := modGen.Directory("./outdir").File("foo.txt").Contents(ctx)
require.NoError(t, err)
require.Equal(t, "foo", foo)
bar, err := modGen.Directory("./outdir").File("bar.txt").Contents(ctx)
require.NoError(t, err)
require.Equal(t, "bar", bar)
})
})
t.Run("return file", 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", "--source=.", "--name=test", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main |
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/integration/module_call_test.go | func New() *Test {
return &Test{
File: dag.Directory().WithNewFile("foo.txt", "foo").File("foo.txt"),
}
}
type Test struct {
File *File
}
`,
})
logGen(ctx, t, modGen.Directory("."))
t.Run("default", func(t *testing.T) {
ctr := modGen.With(daggerCall("file"))
out, err := ctr.Stdout(ctx)
require.NoError(t, err)
require.Empty(t, out)
out, err = ctr.Stderr(ctx)
require.NoError(t, err)
require.Contains(t, out, "File evaluated")
})
t.Run("output", func(t *testing.T) {
out, err := modGen.
With(daggerCall("file", "-o", "./outfile")).
File("./outfile").
Contents(ctx)
require.NoError(t, err)
require.Equal(t, "foo", out)
})
})
t.Run("sync", func(t *testing.T) { |
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/integration/module_call_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=test", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
func New() *Test {
return &Test{Ctr: dag.Container().From("alpine:3.18").WithExec([]string{"echo", "hello", "world"})}
}
type Test struct {
Ctr *Container
}
`,
})
_, err := modGen.With(daggerCall("ctr", "sync")).Stdout(ctx)
require.NoError(t, err)
})
}
func TestModuleDaggerCallCoreChaining(t *testing.T) {
t.Parallel()
t.Run("container", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work"). |
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/integration/module_call_test.go | With(daggerExec("init", "--source=.", "--name=test", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
func New() *Test {
return &Test{Ctr: dag.Container().From("alpine:3.18.5")}
}
type Test struct {
Ctr *Container
}
`,
})
t.Run("file", func(t *testing.T) {
out, err := modGen.With(daggerCall("ctr", "file", "--path=/etc/alpine-release", "contents")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "3.18.5\n", out)
})
t.Run("export", func(t *testing.T) {
modGen, err := modGen.With(daggerCall("ctr", "export", "--path=./container.tar.gz")).Sync(ctx)
require.NoError(t, err)
size, err := modGen.File("./container.tar.gz").Size(ctx)
require.NoError(t, err)
require.Greater(t, size, 0)
})
})
t.Run("directory", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work"). |
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/integration/module_call_test.go | With(daggerExec("init", "--source=.", "--name=test", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
func New() *Test {
return &Test{
Dir: dag.Directory().WithNewFile("foo.txt", "foo").WithNewFile("bar.txt", "bar"),
}
}
type Test struct {
Dir *Directory
}
`,
})
t.Run("file", func(t *testing.T) {
out, err := modGen.With(daggerCall("dir", "file", "--path=foo.txt", "contents")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "foo", out)
})
t.Run("export", func(t *testing.T) {
modGen, err := modGen.With(daggerCall("dir", "export", "--path=./outdir")).Sync(ctx)
require.NoError(t, err)
ents, err := modGen.Directory("./outdir").Entries(ctx)
require.NoError(t, err)
require.Equal(t, []string{"bar.txt", "foo.txt"}, ents)
})
})
t.Run("return file", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage). |
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/integration/module_call_test.go | WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=test", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
func New() *Test {
return &Test{
File: dag.Directory().WithNewFile("foo.txt", "foo").File("foo.txt"),
}
}
type Test struct {
File *File
}
`,
})
t.Run("size", func(t *testing.T) {
out, err := modGen.With(daggerCall("file", "size")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "3", out)
})
t.Run("export", func(t *testing.T) {
modGen, err := modGen.With(daggerCall("file", "export", "--path=./outfile")).Sync(ctx)
require.NoError(t, err)
contents, err := modGen.File("./outfile").Contents(ctx)
require.NoError(t, err)
require.Equal(t, "foo", contents)
})
})
}
func TestModuleDaggerCallSaveOutput(t *testing.T) { |
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/integration/module_call_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=test", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
type Test struct {
}
func (t *Test) Hello() string {
return "hello"
}
func (t *Test) File() *File {
return dag.Directory().WithNewFile("foo.txt", "foo").File("foo.txt")
}
`,
})
logGen(ctx, t, modGen.Directory("."))
t.Run("truncate file", func(t *testing.T) {
out, err := modGen.
WithNewFile("foo.txt", dagger.ContainerWithNewFileOpts{
Contents: "foobar",
}).
With(daggerCall("hello", "-o", "foo.txt")).
File("foo.txt").
Contents(ctx)
require.NoError(t, 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/integration/module_call_test.go | require.Equal(t, "hello", out)
})
t.Run("not a file", func(t *testing.T) {
_, err := modGen.With(daggerCall("hello", "-o", ".")).Sync(ctx)
require.ErrorContains(t, err, "is a directory")
})
t.Run("allow dir for file", func(t *testing.T) {
out, err := modGen.
With(daggerCall("file", "-o", ".")).
File("foo.txt").
Contents(ctx)
require.NoError(t, err)
require.Equal(t, "foo", out)
})
t.Run("create parent dirs", func(t *testing.T) {
ctr, err := modGen.With(daggerCall("hello", "-o", "foo/bar.txt")).Sync(ctx)
require.NoError(t, err)
t.Run("print success", func(t *testing.T) {
out, err := ctr.Stderr(ctx)
require.NoError(t, err)
require.Contains(t, out, `Saved output to "/work/foo/bar.txt"`)
})
t.Run("check directory permissions", func(t *testing.T) {
out, err := ctr.WithExec([]string{"stat", "-c", "%a", "foo"}).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "755\n", out)
})
t.Run("check file permissions", func(t *testing.T) {
out, err := ctr.WithExec([]string{"stat", "-c", "%a", "foo/bar.txt"}).Stdout(ctx) |
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/integration/module_call_test.go | require.NoError(t, err)
require.Equal(t, "644\n", out)
})
})
t.Run("check umask", func(t *testing.T) {
ctr, err := modGen.
WithNewFile("/entrypoint.sh", dagger.ContainerWithNewFileOpts{
Contents: `#!/bin/sh
umask 027
exec "$@"
`,
Permissions: 0o750,
}).
WithEntrypoint([]string{"/entrypoint.sh"}).
With(daggerCall("hello", "-o", "/tmp/foo/bar.txt")).
Sync(ctx)
require.NoError(t, err)
t.Run("directory", func(t *testing.T) {
out, err := ctr.WithExec([]string{"stat", "-c", "%a", "/tmp/foo"}).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "750\n", out)
})
t.Run("file", func(t *testing.T) {
out, err := ctr.WithExec([]string{"stat", "-c", "%a", "/tmp/foo/bar.txt"}).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "640\n", out)
})
})
}
func TestModuleCallByName(t *testing.T) { |
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/integration/module_call_test.go | t.Parallel()
c, ctx := connect(t)
ctr := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work/mod-a").
With(daggerExec("init", "--source=.", "--name=mod-a", "--sdk=go")).
WithNewFile("/work/mod-a/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main |
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/integration/module_call_test.go | import "context"
type ModA struct {}
func (m *ModA) Fn(ctx context.Context) string {
return "hi from mod-a"
}
`,
}).
WithWorkdir("/work/mod-b").
With(daggerExec("init", "--source=.", "--name=mod-b", "--sdk=go")).
WithNewFile("/work/mod-b/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
type ModB struct {}
func (m *ModB) Fn(ctx context.Context) string {
return "hi from mod-b"
}
`,
}).
WithWorkdir("/work").
With(daggerExec("init")).
With(daggerExec("install", "--name", "foo", "./mod-a")).
With(daggerExec("install", "--name", "bar", "./mod-b"))
out, err := ctr.With(daggerCallAt("foo", "fn")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "hi from mod-a", strings.TrimSpace(out))
out, err = ctr.With(daggerCallAt("bar", "fn")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "hi from mod-b", strings.TrimSpace(out))
} |
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/integration/module_config_test.go | package core
import (
"encoding/json"
"strings"
"testing"
"dagger.io/dagger"
"github.com/dagger/dagger/core/modules"
"github.com/stretchr/testify/require"
)
func TestModuleConfigs(t *testing.T) { |
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/integration/module_config_test.go | t.Parallel()
t.Run("upgrade from old config", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
baseWithOldConfig := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work/foo").
With(daggerExec("init", "--source=.", "--name=dep", "--sdk=go")).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=test", "--sdk=go")).
WithNewFile("/work/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
type Test struct {}
func (m *Test) Fn() string { return "wowzas" }
`,
}).
WithNewFile("/work/dagger.json", dagger.ContainerWithNewFileOpts{
Contents: `{"name": "test", "sdk": "go", "include": ["foo"], "exclude": ["blah"], "dependencies": ["foo"]}`,
})
baseWithNewConfig := baseWithOldConfig.With(daggerExec("develop"))
confContents, err := baseWithNewConfig.File("dagger.json").Contents(ctx)
require.NoError(t, 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/integration/module_config_test.go | var modCfg modules.ModuleConfig
require.NoError(t, json.Unmarshal([]byte(confContents), &modCfg))
require.Equal(t, "test", modCfg.Name)
require.Equal(t, "go", modCfg.SDK)
require.Equal(t, []string{"foo"}, modCfg.Include)
require.Equal(t, []string{"blah"}, modCfg.Exclude)
require.Len(t, modCfg.Dependencies, 1)
require.Equal(t, "foo", modCfg.Dependencies[0].Source)
require.Equal(t, "dep", modCfg.Dependencies[0].Name)
require.Equal(t, ".", modCfg.Source)
require.NotEmpty(t, modCfg.EngineVersion)
out, err := baseWithNewConfig.With(daggerCall("fn")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "wowzas", strings.TrimSpace(out))
out, err = baseWithOldConfig.With(daggerCall("fn")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "wowzas", strings.TrimSpace(out))
})
t.Run("dep has separate config", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
base := goGitBase(t, c).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work/subdir/dep").
With(daggerExec("init", "--source=.", "--name=dep", "--sdk=go")).
WithNewFile("/work/subdir/dep/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main |
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/integration/module_config_test.go | import "context"
type Dep struct {}
func (m *Dep) DepFn(ctx context.Context, str string) string { return str }
`,
}).
WithWorkdir("/work").
With(daggerExec("init", "--source=test", "--name=test", "--sdk=go", "test")).
With(daggerExec("install", "-m=test", "./subdir/dep")).
WithNewFile("/work/test/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
type Test struct {}
func (m *Test) Fn(ctx context.Context) (string, error) { return dag.Dep().DepFn(ctx, "hi dep") }
`,
})
t.Run("from src dir", func(t *testing.T) {
t.Parallel()
out, err := base.WithWorkdir("test").With(daggerCall("fn")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "hi dep", strings.TrimSpace(out))
})
t.Run("from src root", func(t *testing.T) {
t.Parallel()
out, err := base.With(daggerCallAt("test", "fn")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "hi dep", strings.TrimSpace(out))
})
t.Run("from root", func(t *testing.T) {
t.Parallel() |
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/integration/module_config_test.go | out, err := base.WithWorkdir("/").With(daggerCallAt("work/test", "fn")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "hi dep", strings.TrimSpace(out))
})
t.Run("from dep parent", func(t *testing.T) {
t.Parallel()
out, err := base.WithWorkdir("/work/subdir").With(daggerCallAt("../test", "fn")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "hi dep", strings.TrimSpace(out))
})
t.Run("from dep dir", func(t *testing.T) {
t.Parallel()
out, err := base.WithWorkdir("/work/subdir/dep").With(daggerCallAt("../../test", "fn")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "hi dep", strings.TrimSpace(out))
})
})
t.Run("install dep from weird places", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
base := goGitBase(t, c).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--source=subdir/dep", "--name=dep", "--sdk=go", "subdir/dep")).
WithNewFile("/work/subdir/dep/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
type Dep struct {}
func (m *Dep) DepFn(ctx context.Context, str string) string { return str }
`, |
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/integration/module_config_test.go | }).
With(daggerExec("init", "--source=test", "--name=test", "--sdk=go", "test")).
WithNewFile("/work/test/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
type Test struct {}
func (m *Test) Fn(ctx context.Context) (string, error) { return dag.Dep().DepFn(ctx, "hi dep") }
`,
})
t.Run("from src dir", func(t *testing.T) {
t.Parallel()
out, err := base.
WithWorkdir("/work/test").
With(daggerExec("install", "../subdir/dep")).
With(daggerCall("fn")).
Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "hi dep", strings.TrimSpace(out))
})
t.Run("from root", func(t *testing.T) {
t.Parallel()
out, err := base.
WithWorkdir("/").
With(daggerExec("install", "-m=./work/test", "./work/subdir/dep")).
WithWorkdir("/work/test").
With(daggerCall("fn")).
Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "hi dep", strings.TrimSpace(out)) |
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/integration/module_config_test.go | })
t.Run("from dep", func(t *testing.T) {
t.Parallel()
out, err := base.
WithWorkdir("/work/subdir/dep").
With(daggerExec("install", "-m=../../test", ".")).
WithWorkdir("/work/test").
With(daggerCall("fn")).
Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "hi dep", strings.TrimSpace(out))
})
t.Run("from random place", func(t *testing.T) {
t.Parallel()
out, err := base.
WithWorkdir("/var").
With(daggerExec("install", "-m=../work/test", "../work/subdir/dep")).
WithWorkdir("/work/test").
With(daggerCall("fn")).
Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "hi dep", strings.TrimSpace(out))
})
})
t.Run("install out of tree dep fails", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
base := goGitBase(t, c).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/play/dep"). |
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/integration/module_config_test.go | With(daggerExec("init", "--name=dep", "--sdk=go")).
WithWorkdir("/work/test").
With(daggerExec("init", "--name=test", "--sdk=go"))
t.Run("from src dir", func(t *testing.T) {
t.Parallel()
_, err := base.
WithWorkdir("/work/test").
With(daggerExec("install", "../../play/dep")).
Sync(ctx)
require.ErrorContains(t, err, `local module dep source path "../play/dep" escapes context "/work"`)
})
t.Run("from dep dir", func(t *testing.T) {
t.Parallel()
_, err := base.
WithWorkdir("/play/dep").
With(daggerExec("install", "-m=../../work/test", ".")).
Sync(ctx)
require.ErrorContains(t, err, `module dep source path "../play/dep" escapes context "/work"`)
})
t.Run("from root", func(t *testing.T) {
t.Parallel()
_, err := base.
WithWorkdir("/").
With(daggerExec("install", "-m=work/test", "play/dep")).
Sync(ctx)
require.ErrorContains(t, err, `module dep source path "../play/dep" escapes context "/work"`)
})
})
t.Run("malicious config", func(t *testing.T) { |
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/integration/module_config_test.go | t.Parallel()
c, ctx := connect(t)
base := goGitBase(t, c).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work/dep").
With(daggerExec("init", "--source=.", "--name=dep", "--sdk=go")).
WithNewFile("/work/dep/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
type Dep struct {}
func (m *Dep) GetSource(ctx context.Context) *Directory {
return dag.CurrentModule().Source()
}
`,
}).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=test", "--sdk=go"))
t.Run("source points out of root", func(t *testing.T) {
t.Parallel()
base := base.
With(configFile(".", &modules.ModuleConfig{
Name: "evil",
SDK: "go",
Source: "..",
}))
_, err := base.With(daggerCall("container-echo", "--string-arg", "plz fail")).Sync(ctx)
require.ErrorContains(t, err, `local module source path ".." escapes context "/work"`)
_, err = base.With(daggerExec("develop")).Sync(ctx)
require.ErrorContains(t, err, `local module source path ".." escapes context "/work"`)
_, err = base.With(daggerExec("install", "./dep")).Sync(ctx) |
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/integration/module_config_test.go | require.ErrorContains(t, err, `local module source path ".." escapes context "/work"`)
})
t.Run("dep points out of root", func(t *testing.T) {
t.Parallel()
base := base.
With(configFile(".", &modules.ModuleConfig{
Name: "evil",
SDK: "go",
Dependencies: []*modules.ModuleConfigDependency{{
Name: "escape",
Source: "..",
}},
}))
_, err := base.With(daggerCall("container-echo", "--string-arg", "plz fail")).Sync(ctx)
require.ErrorContains(t, err, `local module dep source path ".." escapes context "/work"`)
_, err = base.With(daggerExec("develop")).Sync(ctx)
require.ErrorContains(t, err, `local module dep source path ".." escapes context "/work"`)
_, err = base.With(daggerExec("install", "./dep")).Sync(ctx)
require.ErrorContains(t, err, `local module dep source path ".." escapes context "/work"`)
})
})
}
func TestModuleCustomDepNames(t *testing.T) {
t.Parallel()
t.Run("basic", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
ctr := goGitBase(t, c).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work/dep"). |
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/integration/module_config_test.go | With(daggerExec("init", "--source=.", "--name=dep", "--sdk=go")).
WithNewFile("/work/dep/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
type Dep struct {}
func (m *Dep) DepFn(ctx context.Context) string {
return "hi from dep"
}
func (m *Dep) GetDepObj(ctx context.Context) *DepObj {
return &DepObj{Str: "yo from dep"}
}
type DepObj struct {
Str string
}
func (m *Dep) GetOtherObj(ctx context.Context) *OtherObj {
return &OtherObj{Str: "hey from dep"}
}
type OtherObj struct {
Str string
}
`,
}).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=test", "--sdk=go")).
With(daggerExec("install", "--name", "foo", "./dep")).
WithNewFile("/work/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
type Test struct {}
func (m *Test) Fn(ctx context.Context) (string, error) { |
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/integration/module_config_test.go | return dag.Foo().DepFn(ctx)
}
func (m *Test) GetObj(ctx context.Context) (string, error) {
var obj *FooObj
obj = dag.Foo().GetDepObj()
return obj.Str(ctx)
}
func (m *Test) GetOtherObj(ctx context.Context) (string, error) {
var obj *FooOtherObj
obj = dag.Foo().GetOtherObj()
return obj.Str(ctx)
}
func (m *Test) GetConflictNameObj(ctx context.Context) *Dep {
return &Dep{Str: "it worked?"}
}
// should not be any name conflict with dep
type Dep struct {
Str string
}
`,
})
out, err := ctr.With(daggerCall("fn")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "hi from dep", strings.TrimSpace(out))
out, err = ctr.With(daggerCall("get-obj")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "yo from dep", strings.TrimSpace(out))
out, err = ctr.With(daggerCall("get-other-obj")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "hey from dep", strings.TrimSpace(out)) |
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/integration/module_config_test.go | out, err = ctr.With(daggerCall("get-conflict-name-obj", "str")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "it worked?", strings.TrimSpace(out))
})
t.Run("same mod name as dep", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
ctr := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work/dep").
With(daggerExec("init", "--source=.", "--name=test", "--sdk=go")).
WithNewFile("/work/dep/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
type Test struct {}
func (m *Test) Fn(ctx context.Context) string {
return "hi from dep"
}
`,
}).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=test", "--sdk=go")).
With(daggerExec("install", "--name", "foo", "./dep")).
WithNewFile("/work/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
type Test struct {}
func (m *Test) Fn(ctx context.Context) (string, error) {
return dag.Foo().Fn(ctx)
} |
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/integration/module_config_test.go | `,
})
out, err := ctr.With(daggerCall("fn")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "hi from dep", strings.TrimSpace(out))
})
t.Run("two deps with same name", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
ctr := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work/dep1").
With(daggerExec("init", "--source=.", "--name=dep", "--sdk=go")).
WithNewFile("/work/dep1/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
type Dep struct {}
func (m *Dep) Fn(ctx context.Context) string {
return "hi from dep1"
}
`,
}).
WithWorkdir("/work/dep2").
With(daggerExec("init", "--source=.", "--name=dep", "--sdk=go")).
WithNewFile("/work/dep2/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
type Dep struct {}
func (m *Dep) Fn(ctx context.Context) string {
return "hi from dep2" |
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/integration/module_config_test.go | }
`,
}).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=test", "--sdk=go")).
With(daggerExec("install", "--name", "foo", "./dep1")).
With(daggerExec("install", "--name", "bar", "./dep2")).
WithNewFile("/work/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
type Test struct {}
func (m *Test) Fn(ctx context.Context) (string, error) {
dep1, err := dag.Foo().Fn(ctx)
if err != nil {
return "", err
}
dep2, err := dag.Bar().Fn(ctx)
if err != nil {
return "", err
}
return dep1 + " " + dep2, nil
}
`,
})
out, err := ctr.With(daggerCall("fn")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "hi from dep1 hi from dep2", strings.TrimSpace(out))
})
}
func TestModuleDaggerInit(t *testing.T) { |
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/integration/module_config_test.go | t.Parallel()
t.Run("name defaults to source root dir name", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
out, err := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--source=coolmod", "--sdk=go", "coolmod")).
WithNewFile("/work/coolmod/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
type Coolmod struct {}
func (m *Coolmod) Fn(ctx context.Context) (string, error) {
return dag.CurrentModule().Name(ctx)
}
`,
}).
With(daggerCallAt("coolmod", "fn")).
Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "coolmod", strings.TrimSpace(out))
})
t.Run("source dir default", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
ctr := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work")
for _, tc := range []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/integration/module_config_test.go | sdk string
sourceDirEnt string
}{
{
sdk: "go",
sourceDirEnt: "main.go",
},
{
sdk: "python",
sourceDirEnt: "src",
},
{
sdk: "typescript",
sourceDirEnt: "src",
},
} {
tc := tc
t.Run(tc.sdk, func(t *testing.T) { |
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/integration/module_config_test.go | t.Parallel()
srcRootDir := ctr.
With(daggerExec("init", "--name=test", "--sdk="+tc.sdk)).
Directory(".")
srcRootEnts, err := srcRootDir.Entries(ctx)
require.NoError(t, err)
require.Contains(t, srcRootEnts, "dagger.json")
require.NotContains(t, srcRootEnts, tc.sourceDirEnt)
srcDirEnts, err := srcRootDir.Directory("dagger").Entries(ctx)
require.NoError(t, err)
require.Contains(t, srcDirEnts, tc.sourceDirEnt)
})
}
})
t.Run("source is made rel to source root by engine", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
ctr := goGitBase(t, c).
WithWorkdir("/var").
With(daggerExec("init", "--source=../work/some/subdir", "--name=test", "--sdk=go", "../work")).
With(daggerCallAt("../work", "container-echo", "--string-arg", "yo", "stdout"))
out, err := ctr.Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "yo", strings.TrimSpace(out))
ents, err := ctr.Directory("/work/some/subdir").Entries(ctx)
require.NoError(t, err)
require.Contains(t, ents, "main.go")
})
}
func TestModuleDaggerDevelop(t *testing.T) { |
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/integration/module_config_test.go | t.Parallel()
t.Run("name and sdk", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
ctr := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work/dep").
With(daggerExec("init", "--source=.", "--name=dep", "--sdk=go")).
WithNewFile("/work/dep/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
type Dep struct {}
func (m *Dep) Fn(ctx context.Context) string {
return "hi from dep"
}
`,
}).
WithWorkdir("/work").
With(daggerExec("init")). |
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/integration/module_config_test.go | With(daggerExec("install", "./dep"))
out, err := ctr.With(daggerCallAt("dep", "fn")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "hi from dep", strings.TrimSpace(out))
ctr = ctr.
With(daggerExec("develop", "--sdk", "go", "--source", "cool/subdir")).
WithNewFile("/work/cool/subdir/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
type Work struct {}
func (m *Work) Fn(ctx context.Context) (string, error) {
depStr, err := dag.Dep().Fn(ctx)
if err != nil {
return "", err
}
return "hi from work " + depStr, nil
}
`,
})
out, err = ctr.With(daggerCall("fn")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "hi from work hi from dep", strings.TrimSpace(out))
_, err = ctr.With(daggerExec("develop", "--sdk", "python")).Sync(ctx)
require.ErrorContains(t, err, `cannot update module SDK that has already been set to "go"`)
_, err = ctr.With(daggerExec("develop", "--source", "blahblahblaha/blah")).Sync(ctx)
require.ErrorContains(t, err, `cannot update module source path that has already been set to "cool/subdir"`) |
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/integration/module_config_test.go | })
t.Run("source is made rel to source root by engine", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
ctr := goGitBase(t, c).
WithWorkdir("/work/dep").
With(daggerExec("init", "--source=.", "--name=dep", "--sdk=go")).
WithNewFile("/work/dep/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
type Dep struct {}
func (m *Dep) Fn(ctx context.Context) string {
return "hi from dep"
}
`,
}).
WithWorkdir("/work").
With(daggerExec("init")).
With(daggerExec("install", "./dep")).
WithWorkdir("/var").
With(daggerExec("develop", "-m", "../work", "--source=../work/some/subdir", "--sdk=go")).
WithNewFile("/work/some/subdir/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
type Work struct {}
func (m *Work) Fn(ctx context.Context) (string, error) {
depStr, err := dag.Dep().Fn(ctx)
if err != nil {
return "", 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/integration/module_config_test.go | return "hi from work " + depStr, nil
}
`,
})
out, err := ctr.With(daggerCallAt("../work", "fn")).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "hi from work hi from dep", strings.TrimSpace(out))
ents, err := ctr.Directory("/work/some/subdir").Entries(ctx)
require.NoError(t, err)
require.Contains(t, ents, "main.go")
})
}
func TestModuleDaggerConfig(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
out, err := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=test", "--sdk=go", "test")).
With(daggerExec("config", "-m", "test")).
Stdout(ctx)
require.NoError(t, err)
require.Regexp(t, `Name:\s+test`, out)
require.Regexp(t, `SDK:\s+go`, out)
require.Regexp(t, `Root Directory:\s+/work`, out)
require.Regexp(t, `Source Directory:\s+/work/test`, out)
}
func TestModuleIncludeExclude(t *testing.T) {
t.Parallel()
for _, tc := range []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/integration/module_config_test.go | sdk string
mainSource string
customSDKSource string
customSDKUnderlyingSDK string
}{
{
sdk: "go",
mainSource: `package main
type Test struct {}
func (m *Test) Fn() *Directory {
return dag.CurrentModule().Source()
}
`,
},
{
sdk: "python", |
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/integration/module_config_test.go | mainSource: `import dagger
from dagger import dag, function, object_type
@object_type
class Test:
@function
def fn(self) -> dagger.Directory:
return dag.current_module().source()
`,
},
{
sdk: "typescript",
mainSource: `
import { dag, Directory, object, func } from "@dagger.io/dagger"
@object()
class Test {
@func()
fn(): Directory {
return dag.currentModule().source()
}
}`,
},
{
sdk: "coolsdk",
mainSource: `package main
type Test struct {}
func (m *Test) Fn() *Directory {
return dag.CurrentModule().Source()
}
`,
customSDKUnderlyingSDK: "go", |
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/integration/module_config_test.go | customSDKSource: `package main
type Coolsdk struct {}
func (m *Coolsdk) ModuleRuntime(modSource *ModuleSource, introspectionJson string) *Container {
return modSource.WithSDK("go").AsModule().Runtime().WithEnvVariable("COOL", "true")
}
func (m *Coolsdk) Codegen(modSource *ModuleSource, introspectionJson string) *GeneratedCode {
return dag.GeneratedCode(modSource.WithSDK("go").AsModule().GeneratedContextDirectory())
}
func (m *Coolsdk) RequiredPaths() []string {
return []string{
"**/go.mod",
"**/go.sum",
"**/go.work",
"**/go.work.sum",
"**/vendor/",
"**/*.go",
}
}
`,
},
} {
tc := tc
t.Run(tc.sdk, func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
ctr := goGitBase(t, c).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work")
if tc.customSDKSource != "" { |
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/integration/module_config_test.go | ctr = ctr.
WithWorkdir("/work/" + tc.sdk).
With(daggerExec("init", "--name="+tc.sdk, "--sdk="+tc.customSDKUnderlyingSDK)).
With(sdkSource(tc.customSDKUnderlyingSDK, tc.customSDKSource)).
WithWorkdir("/work")
}
ctr = ctr.With(daggerExec("init", "--name=test", "--sdk="+tc.sdk))
if tc.customSDKSource != "" {
ctr = ctr.WithNewFile("dagger/main.go", dagger.ContainerWithNewFileOpts{
Contents: tc.mainSource,
})
} else {
ctr = ctr.With(sdkSource(tc.sdk, tc.mainSource))
}
ctr = ctr.
With(configFile(".", &modules.ModuleConfig{
Name: "test",
SDK: tc.sdk,
Include: []string{"dagger/subdir/keepdir"},
Exclude: []string{"dagger/subdir/keepdir/rmdir"},
Source: "dagger",
})).
WithDirectory("dagger/subdir/keepdir/rmdir", c.Directory())
out, err := ctr.
With(daggerCall("fn", "directory", "--path", "subdir", "entries")).
Stdout(ctx) |
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/integration/module_config_test.go | require.NoError(t, err)
require.Equal(t, "keepdir", strings.TrimSpace(out))
out, err = ctr.
With(daggerCall("fn", "directory", "--path", "subdir/keepdir", "entries")).
Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "", strings.TrimSpace(out))
out, err = ctr.
WithWorkdir("/mnt").
With(daggerCallAt("../work", "fn", "directory", "--path", "subdir", "entries")).
Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "keepdir", strings.TrimSpace(out))
ctr = ctr.With(daggerExec("develop"))
out, err = ctr.
With(daggerCall("fn", "directory", "--path", "subdir", "entries")).
Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "keepdir", strings.TrimSpace(out))
out, err = ctr.
With(daggerCall("fn", "directory", "--path", "subdir/keepdir", "entries")).
Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "", strings.TrimSpace(out))
})
}
}
func TestModuleContextDefaultsToSourceRoot(t *testing.T) { |
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/integration/module_config_test.go | t.Parallel()
c, ctx := connect(t)
ctr := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work/coolsdk").
With(daggerExec("init", "--source=.", "--name=cool-sdk", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
type CoolSdk struct {}
func (m *CoolSdk) ModuleRuntime(modSource *ModuleSource, introspectionJson string) *Container {
return modSource.WithSDK("go").AsModule().Runtime().
WithMountedDirectory("/da-context", modSource.ContextDirectory())
}
func (m *CoolSdk) Codegen(modSource *ModuleSource, introspectionJson string) *GeneratedCode {
return dag.GeneratedCode(modSource.WithSDK("go").AsModule().GeneratedContextDirectory())
}
func (m *CoolSdk) RequiredPaths() []string {
return []string{
"**/go.mod",
"**/go.sum",
"**/go.work",
"**/go.work.sum",
"**/vendor/",
"**/*.go",
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.