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,630 | `slice bounds out of range [1:0]` panic in shim secret scrubbing | Hit this while testing publish things in my fork: https://github.com/sipsma/dagger/actions/runs/7837271347/job/21386972933#step:4:2866
Stack:
```
62: [0.09s] panic: runtime error: slice bounds out of range [1:0] goroutine 1 [running, locked to thread]:
62: [0.09s] runtime/debug.Stack()
62: [0.09s] /usr/local/go/src/runtime/debug/stack.go:24 +0x5e
62: [0.09s] main.main.func1()
62: [0.09s] /app/cmd/shim/main.go:63 +0x38
62: [0.09s] panic({0x1105620?, 0xc000044c78?})
62: [0.09s] /usr/local/go/src/runtime/panic.go:914 +0x21f
62: [0.09s] main.(*Trie).Insert(0xc00008b020?, {0xc0001a2b90, 0x4e, 0x50}, {0x1b18a8e, 0x3, 0x3})
62: [0.09s] /app/cmd/shim/secret_scrub.go:230 +0x351
62: [0.09s] main.NewSecretScrubReader({0x13307a0?, 0xc000126938}, {0x1329160, 0x1}, {0x1330820, 0xc0005a2780}, {0xc0003a28c0?, 0x2?, 0x2?}, {{0xc0005b7500, ...}, ...})
62: [0.09s] /app/cmd/shim/secret_scrub.go:39 +0x345
62: [0.09s] main.shim()
62: [0.09s] /app/cmd/shim/main.go:259 +0xc52
62: [0.09s] main.main()
62: [0.09s] /app/cmd/shim/main.go:76 +0x74
62: [0.09s]
```
[Relevant line of code](https://github.com/sipsma/dagger/blob/d71867c127f6970113221c57fc03d2c8084b6c0a/cmd/shim/secret_scrub.go#L230-L230)
Not 100% sure but suspect I may have somehow set a secret value to `""`? That seems like a plausible explanation, but haven't looked at this in depth.
cc @jedevc | https://github.com/dagger/dagger/issues/6630 | https://github.com/dagger/dagger/pull/6641 | 794e3b3d298c7ca77dfedf5bf3d98d143ed05095 | 0c0de6b23b0151a9d1debfa8cbc879fd30391ab5 | 2024-02-08T23:51:48Z | go | 2024-02-12T14:41:35Z | cmd/shim/secret_scrub.go | secrets := []string{}
for _, envKV := range env {
envName, envValue, ok := strings.Cut(envKV, "=")
if !ok {
continue
}
for _, envToScrub := range secretsToScrub {
if envName == envToScrub {
secrets = append(secrets, envValue)
}
}
}
return secrets
}
func loadSecretsToScrubFromFiles(currentDirPathAbs string, fsys fs.FS, secretFilePathsToScrub []string) ([]string, error) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,630 | `slice bounds out of range [1:0]` panic in shim secret scrubbing | Hit this while testing publish things in my fork: https://github.com/sipsma/dagger/actions/runs/7837271347/job/21386972933#step:4:2866
Stack:
```
62: [0.09s] panic: runtime error: slice bounds out of range [1:0] goroutine 1 [running, locked to thread]:
62: [0.09s] runtime/debug.Stack()
62: [0.09s] /usr/local/go/src/runtime/debug/stack.go:24 +0x5e
62: [0.09s] main.main.func1()
62: [0.09s] /app/cmd/shim/main.go:63 +0x38
62: [0.09s] panic({0x1105620?, 0xc000044c78?})
62: [0.09s] /usr/local/go/src/runtime/panic.go:914 +0x21f
62: [0.09s] main.(*Trie).Insert(0xc00008b020?, {0xc0001a2b90, 0x4e, 0x50}, {0x1b18a8e, 0x3, 0x3})
62: [0.09s] /app/cmd/shim/secret_scrub.go:230 +0x351
62: [0.09s] main.NewSecretScrubReader({0x13307a0?, 0xc000126938}, {0x1329160, 0x1}, {0x1330820, 0xc0005a2780}, {0xc0003a28c0?, 0x2?, 0x2?}, {{0xc0005b7500, ...}, ...})
62: [0.09s] /app/cmd/shim/secret_scrub.go:39 +0x345
62: [0.09s] main.shim()
62: [0.09s] /app/cmd/shim/main.go:259 +0xc52
62: [0.09s] main.main()
62: [0.09s] /app/cmd/shim/main.go:76 +0x74
62: [0.09s]
```
[Relevant line of code](https://github.com/sipsma/dagger/blob/d71867c127f6970113221c57fc03d2c8084b6c0a/cmd/shim/secret_scrub.go#L230-L230)
Not 100% sure but suspect I may have somehow set a secret value to `""`? That seems like a plausible explanation, but haven't looked at this in depth.
cc @jedevc | https://github.com/dagger/dagger/issues/6630 | https://github.com/dagger/dagger/pull/6641 | 794e3b3d298c7ca77dfedf5bf3d98d143ed05095 | 0c0de6b23b0151a9d1debfa8cbc879fd30391ab5 | 2024-02-08T23:51:48Z | go | 2024-02-12T14:41:35Z | cmd/shim/secret_scrub.go | secrets := make([]string, 0, len(secretFilePathsToScrub))
for _, fileToScrub := range secretFilePathsToScrub {
absFileToScrub := fileToScrub
if !filepath.IsAbs(fileToScrub) {
absFileToScrub = filepath.Join("/", fileToScrub)
}
if strings.HasPrefix(fileToScrub, currentDirPathAbs) || strings.HasPrefix(fileToScrub, currentDirPathAbs[1:]) {
absFileToScrub = strings.TrimPrefix(fileToScrub, currentDirPathAbs)
absFileToScrub = filepath.Join("/", absFileToScrub)
}
secret, err := fs.ReadFile(fsys, absFileToScrub[1:])
if err != nil {
return nil, fmt.Errorf("secret value not available for: %w", err)
}
secrets = append(secrets, string(secret))
}
return secrets, nil
}
type censor struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,630 | `slice bounds out of range [1:0]` panic in shim secret scrubbing | Hit this while testing publish things in my fork: https://github.com/sipsma/dagger/actions/runs/7837271347/job/21386972933#step:4:2866
Stack:
```
62: [0.09s] panic: runtime error: slice bounds out of range [1:0] goroutine 1 [running, locked to thread]:
62: [0.09s] runtime/debug.Stack()
62: [0.09s] /usr/local/go/src/runtime/debug/stack.go:24 +0x5e
62: [0.09s] main.main.func1()
62: [0.09s] /app/cmd/shim/main.go:63 +0x38
62: [0.09s] panic({0x1105620?, 0xc000044c78?})
62: [0.09s] /usr/local/go/src/runtime/panic.go:914 +0x21f
62: [0.09s] main.(*Trie).Insert(0xc00008b020?, {0xc0001a2b90, 0x4e, 0x50}, {0x1b18a8e, 0x3, 0x3})
62: [0.09s] /app/cmd/shim/secret_scrub.go:230 +0x351
62: [0.09s] main.NewSecretScrubReader({0x13307a0?, 0xc000126938}, {0x1329160, 0x1}, {0x1330820, 0xc0005a2780}, {0xc0003a28c0?, 0x2?, 0x2?}, {{0xc0005b7500, ...}, ...})
62: [0.09s] /app/cmd/shim/secret_scrub.go:39 +0x345
62: [0.09s] main.shim()
62: [0.09s] /app/cmd/shim/main.go:259 +0xc52
62: [0.09s] main.main()
62: [0.09s] /app/cmd/shim/main.go:76 +0x74
62: [0.09s]
```
[Relevant line of code](https://github.com/sipsma/dagger/blob/d71867c127f6970113221c57fc03d2c8084b6c0a/cmd/shim/secret_scrub.go#L230-L230)
Not 100% sure but suspect I may have somehow set a secret value to `""`? That seems like a plausible explanation, but haven't looked at this in depth.
cc @jedevc | https://github.com/dagger/dagger/issues/6630 | https://github.com/dagger/dagger/pull/6641 | 794e3b3d298c7ca77dfedf5bf3d98d143ed05095 | 0c0de6b23b0151a9d1debfa8cbc879fd30391ab5 | 2024-02-08T23:51:48Z | go | 2024-02-12T14:41:35Z | cmd/shim/secret_scrub.go | trieRoot *Trie
trie *Trie
srcBuf []byte
dstBuf []byte
}
func (c *censor) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) {
for {
k := copy(dst[nDst:], c.dstBuf)
nDst += k
if nDst == len(dst) {
c.dstBuf = c.dstBuf[k:]
return nDst, nSrc, transform.ErrShortDst
}
c.dstBuf = c.dstBuf[:0]
if !atEOF && nSrc == len(src) {
return nDst, nSrc, nil
}
if atEOF && nSrc == len(src) && len(c.srcBuf) == 0 { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,630 | `slice bounds out of range [1:0]` panic in shim secret scrubbing | Hit this while testing publish things in my fork: https://github.com/sipsma/dagger/actions/runs/7837271347/job/21386972933#step:4:2866
Stack:
```
62: [0.09s] panic: runtime error: slice bounds out of range [1:0] goroutine 1 [running, locked to thread]:
62: [0.09s] runtime/debug.Stack()
62: [0.09s] /usr/local/go/src/runtime/debug/stack.go:24 +0x5e
62: [0.09s] main.main.func1()
62: [0.09s] /app/cmd/shim/main.go:63 +0x38
62: [0.09s] panic({0x1105620?, 0xc000044c78?})
62: [0.09s] /usr/local/go/src/runtime/panic.go:914 +0x21f
62: [0.09s] main.(*Trie).Insert(0xc00008b020?, {0xc0001a2b90, 0x4e, 0x50}, {0x1b18a8e, 0x3, 0x3})
62: [0.09s] /app/cmd/shim/secret_scrub.go:230 +0x351
62: [0.09s] main.NewSecretScrubReader({0x13307a0?, 0xc000126938}, {0x1329160, 0x1}, {0x1330820, 0xc0005a2780}, {0xc0003a28c0?, 0x2?, 0x2?}, {{0xc0005b7500, ...}, ...})
62: [0.09s] /app/cmd/shim/secret_scrub.go:39 +0x345
62: [0.09s] main.shim()
62: [0.09s] /app/cmd/shim/main.go:259 +0xc52
62: [0.09s] main.main()
62: [0.09s] /app/cmd/shim/main.go:76 +0x74
62: [0.09s]
```
[Relevant line of code](https://github.com/sipsma/dagger/blob/d71867c127f6970113221c57fc03d2c8084b6c0a/cmd/shim/secret_scrub.go#L230-L230)
Not 100% sure but suspect I may have somehow set a secret value to `""`? That seems like a plausible explanation, but haven't looked at this in depth.
cc @jedevc | https://github.com/dagger/dagger/issues/6630 | https://github.com/dagger/dagger/pull/6641 | 794e3b3d298c7ca77dfedf5bf3d98d143ed05095 | 0c0de6b23b0151a9d1debfa8cbc879fd30391ab5 | 2024-02-08T23:51:48Z | go | 2024-02-12T14:41:35Z | cmd/shim/secret_scrub.go | return nDst, nSrc, nil
}
for ; nSrc < len(src) && nDst+len(c.dstBuf) < len(dst); nSrc++ {
ch := src[nSrc]
c.trie = c.trie.Step(ch)
if c.trie == nil {
if len(c.srcBuf) != 0 {
c.trie = c.trieRoot
c.dstBuf = append(c.dstBuf, c.srcBuf...)
c.srcBuf = c.srcBuf[:0]
nSrc--
continue
}
c.trie = c.trieRoot.Step(ch)
if c.trie == nil {
c.trie = c.trieRoot
c.dstBuf = append(c.dstBuf, ch) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,630 | `slice bounds out of range [1:0]` panic in shim secret scrubbing | Hit this while testing publish things in my fork: https://github.com/sipsma/dagger/actions/runs/7837271347/job/21386972933#step:4:2866
Stack:
```
62: [0.09s] panic: runtime error: slice bounds out of range [1:0] goroutine 1 [running, locked to thread]:
62: [0.09s] runtime/debug.Stack()
62: [0.09s] /usr/local/go/src/runtime/debug/stack.go:24 +0x5e
62: [0.09s] main.main.func1()
62: [0.09s] /app/cmd/shim/main.go:63 +0x38
62: [0.09s] panic({0x1105620?, 0xc000044c78?})
62: [0.09s] /usr/local/go/src/runtime/panic.go:914 +0x21f
62: [0.09s] main.(*Trie).Insert(0xc00008b020?, {0xc0001a2b90, 0x4e, 0x50}, {0x1b18a8e, 0x3, 0x3})
62: [0.09s] /app/cmd/shim/secret_scrub.go:230 +0x351
62: [0.09s] main.NewSecretScrubReader({0x13307a0?, 0xc000126938}, {0x1329160, 0x1}, {0x1330820, 0xc0005a2780}, {0xc0003a28c0?, 0x2?, 0x2?}, {{0xc0005b7500, ...}, ...})
62: [0.09s] /app/cmd/shim/secret_scrub.go:39 +0x345
62: [0.09s] main.shim()
62: [0.09s] /app/cmd/shim/main.go:259 +0xc52
62: [0.09s] main.main()
62: [0.09s] /app/cmd/shim/main.go:76 +0x74
62: [0.09s]
```
[Relevant line of code](https://github.com/sipsma/dagger/blob/d71867c127f6970113221c57fc03d2c8084b6c0a/cmd/shim/secret_scrub.go#L230-L230)
Not 100% sure but suspect I may have somehow set a secret value to `""`? That seems like a plausible explanation, but haven't looked at this in depth.
cc @jedevc | https://github.com/dagger/dagger/issues/6630 | https://github.com/dagger/dagger/pull/6641 | 794e3b3d298c7ca77dfedf5bf3d98d143ed05095 | 0c0de6b23b0151a9d1debfa8cbc879fd30391ab5 | 2024-02-08T23:51:48Z | go | 2024-02-12T14:41:35Z | cmd/shim/secret_scrub.go | } else if replace := c.trie.Value(); replace != nil {
c.trie = c.trieRoot
c.dstBuf = append(c.dstBuf, replace...)
} else {
c.srcBuf = append(c.srcBuf, ch)
}
} else if replace := c.trie.Value(); replace != nil {
c.trie = c.trieRoot
c.dstBuf = append(c.dstBuf, replace...)
c.srcBuf = c.srcBuf[:0]
} else {
c.srcBuf = append(c.srcBuf, ch)
}
}
if atEOF {
c.dstBuf = append(c.dstBuf, c.srcBuf...)
c.srcBuf = c.srcBuf[:0]
}
}
}
func (c *censor) Reset() {
c.trie = c.trieRoot
c.srcBuf = c.srcBuf[:0]
c.dstBuf = c.dstBuf[:0]
}
type Trie struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,630 | `slice bounds out of range [1:0]` panic in shim secret scrubbing | Hit this while testing publish things in my fork: https://github.com/sipsma/dagger/actions/runs/7837271347/job/21386972933#step:4:2866
Stack:
```
62: [0.09s] panic: runtime error: slice bounds out of range [1:0] goroutine 1 [running, locked to thread]:
62: [0.09s] runtime/debug.Stack()
62: [0.09s] /usr/local/go/src/runtime/debug/stack.go:24 +0x5e
62: [0.09s] main.main.func1()
62: [0.09s] /app/cmd/shim/main.go:63 +0x38
62: [0.09s] panic({0x1105620?, 0xc000044c78?})
62: [0.09s] /usr/local/go/src/runtime/panic.go:914 +0x21f
62: [0.09s] main.(*Trie).Insert(0xc00008b020?, {0xc0001a2b90, 0x4e, 0x50}, {0x1b18a8e, 0x3, 0x3})
62: [0.09s] /app/cmd/shim/secret_scrub.go:230 +0x351
62: [0.09s] main.NewSecretScrubReader({0x13307a0?, 0xc000126938}, {0x1329160, 0x1}, {0x1330820, 0xc0005a2780}, {0xc0003a28c0?, 0x2?, 0x2?}, {{0xc0005b7500, ...}, ...})
62: [0.09s] /app/cmd/shim/secret_scrub.go:39 +0x345
62: [0.09s] main.shim()
62: [0.09s] /app/cmd/shim/main.go:259 +0xc52
62: [0.09s] main.main()
62: [0.09s] /app/cmd/shim/main.go:76 +0x74
62: [0.09s]
```
[Relevant line of code](https://github.com/sipsma/dagger/blob/d71867c127f6970113221c57fc03d2c8084b6c0a/cmd/shim/secret_scrub.go#L230-L230)
Not 100% sure but suspect I may have somehow set a secret value to `""`? That seems like a plausible explanation, but haven't looked at this in depth.
cc @jedevc | https://github.com/dagger/dagger/issues/6630 | https://github.com/dagger/dagger/pull/6641 | 794e3b3d298c7ca77dfedf5bf3d98d143ed05095 | 0c0de6b23b0151a9d1debfa8cbc879fd30391ab5 | 2024-02-08T23:51:48Z | go | 2024-02-12T14:41:35Z | cmd/shim/secret_scrub.go | Children []*Trie
Direct []byte
value []byte
}
func (t *Trie) Insert(key []byte, value []byte) {
node := t
for i, ch := range key {
if node.Children == nil {
if len(node.Direct) == 0 {
node.Direct = key[i:]
break
}
node.Children = make([]*Trie, 256)
node.Children[node.Direct[0]] = &Trie{
Direct: node.Direct[1:],
value: node.value, |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,630 | `slice bounds out of range [1:0]` panic in shim secret scrubbing | Hit this while testing publish things in my fork: https://github.com/sipsma/dagger/actions/runs/7837271347/job/21386972933#step:4:2866
Stack:
```
62: [0.09s] panic: runtime error: slice bounds out of range [1:0] goroutine 1 [running, locked to thread]:
62: [0.09s] runtime/debug.Stack()
62: [0.09s] /usr/local/go/src/runtime/debug/stack.go:24 +0x5e
62: [0.09s] main.main.func1()
62: [0.09s] /app/cmd/shim/main.go:63 +0x38
62: [0.09s] panic({0x1105620?, 0xc000044c78?})
62: [0.09s] /usr/local/go/src/runtime/panic.go:914 +0x21f
62: [0.09s] main.(*Trie).Insert(0xc00008b020?, {0xc0001a2b90, 0x4e, 0x50}, {0x1b18a8e, 0x3, 0x3})
62: [0.09s] /app/cmd/shim/secret_scrub.go:230 +0x351
62: [0.09s] main.NewSecretScrubReader({0x13307a0?, 0xc000126938}, {0x1329160, 0x1}, {0x1330820, 0xc0005a2780}, {0xc0003a28c0?, 0x2?, 0x2?}, {{0xc0005b7500, ...}, ...})
62: [0.09s] /app/cmd/shim/secret_scrub.go:39 +0x345
62: [0.09s] main.shim()
62: [0.09s] /app/cmd/shim/main.go:259 +0xc52
62: [0.09s] main.main()
62: [0.09s] /app/cmd/shim/main.go:76 +0x74
62: [0.09s]
```
[Relevant line of code](https://github.com/sipsma/dagger/blob/d71867c127f6970113221c57fc03d2c8084b6c0a/cmd/shim/secret_scrub.go#L230-L230)
Not 100% sure but suspect I may have somehow set a secret value to `""`? That seems like a plausible explanation, but haven't looked at this in depth.
cc @jedevc | https://github.com/dagger/dagger/issues/6630 | https://github.com/dagger/dagger/pull/6641 | 794e3b3d298c7ca77dfedf5bf3d98d143ed05095 | 0c0de6b23b0151a9d1debfa8cbc879fd30391ab5 | 2024-02-08T23:51:48Z | go | 2024-02-12T14:41:35Z | cmd/shim/secret_scrub.go | }
node.Direct = nil
node.value = nil
}
if node.Children[ch] == nil {
node.Children[ch] = &Trie{}
}
node = node.Children[ch]
}
node.value = value
}
func (t *Trie) Step(ch byte) *Trie {
if t.Children != nil {
return t.Children[ch]
}
if len(t.Direct) > 0 && t.Direct[0] == ch {
return &Trie{
Direct: t.Direct[1:],
value: t.value,
}
}
return nil
}
func (t *Trie) Value() []byte {
if len(t.Direct) == 0 {
return t.value
}
return nil
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,630 | `slice bounds out of range [1:0]` panic in shim secret scrubbing | Hit this while testing publish things in my fork: https://github.com/sipsma/dagger/actions/runs/7837271347/job/21386972933#step:4:2866
Stack:
```
62: [0.09s] panic: runtime error: slice bounds out of range [1:0] goroutine 1 [running, locked to thread]:
62: [0.09s] runtime/debug.Stack()
62: [0.09s] /usr/local/go/src/runtime/debug/stack.go:24 +0x5e
62: [0.09s] main.main.func1()
62: [0.09s] /app/cmd/shim/main.go:63 +0x38
62: [0.09s] panic({0x1105620?, 0xc000044c78?})
62: [0.09s] /usr/local/go/src/runtime/panic.go:914 +0x21f
62: [0.09s] main.(*Trie).Insert(0xc00008b020?, {0xc0001a2b90, 0x4e, 0x50}, {0x1b18a8e, 0x3, 0x3})
62: [0.09s] /app/cmd/shim/secret_scrub.go:230 +0x351
62: [0.09s] main.NewSecretScrubReader({0x13307a0?, 0xc000126938}, {0x1329160, 0x1}, {0x1330820, 0xc0005a2780}, {0xc0003a28c0?, 0x2?, 0x2?}, {{0xc0005b7500, ...}, ...})
62: [0.09s] /app/cmd/shim/secret_scrub.go:39 +0x345
62: [0.09s] main.shim()
62: [0.09s] /app/cmd/shim/main.go:259 +0xc52
62: [0.09s] main.main()
62: [0.09s] /app/cmd/shim/main.go:76 +0x74
62: [0.09s]
```
[Relevant line of code](https://github.com/sipsma/dagger/blob/d71867c127f6970113221c57fc03d2c8084b6c0a/cmd/shim/secret_scrub.go#L230-L230)
Not 100% sure but suspect I may have somehow set a secret value to `""`? That seems like a plausible explanation, but haven't looked at this in depth.
cc @jedevc | https://github.com/dagger/dagger/issues/6630 | https://github.com/dagger/dagger/pull/6641 | 794e3b3d298c7ca77dfedf5bf3d98d143ed05095 | 0c0de6b23b0151a9d1debfa8cbc879fd30391ab5 | 2024-02-08T23:51:48Z | go | 2024-02-12T14:41:35Z | cmd/shim/secret_scrub_test.go | package main
import (
"bufio"
"bytes"
_ "embed"
"fmt"
"io"
"math/rand"
"strings"
"sync"
"testing"
"testing/fstest"
"github.com/stretchr/testify/require"
"github.com/dagger/dagger/core"
)
var (
sshSecretKey string
sshPublicKey string
)
func TestSecretScrubWriterWrite(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,630 | `slice bounds out of range [1:0]` panic in shim secret scrubbing | Hit this while testing publish things in my fork: https://github.com/sipsma/dagger/actions/runs/7837271347/job/21386972933#step:4:2866
Stack:
```
62: [0.09s] panic: runtime error: slice bounds out of range [1:0] goroutine 1 [running, locked to thread]:
62: [0.09s] runtime/debug.Stack()
62: [0.09s] /usr/local/go/src/runtime/debug/stack.go:24 +0x5e
62: [0.09s] main.main.func1()
62: [0.09s] /app/cmd/shim/main.go:63 +0x38
62: [0.09s] panic({0x1105620?, 0xc000044c78?})
62: [0.09s] /usr/local/go/src/runtime/panic.go:914 +0x21f
62: [0.09s] main.(*Trie).Insert(0xc00008b020?, {0xc0001a2b90, 0x4e, 0x50}, {0x1b18a8e, 0x3, 0x3})
62: [0.09s] /app/cmd/shim/secret_scrub.go:230 +0x351
62: [0.09s] main.NewSecretScrubReader({0x13307a0?, 0xc000126938}, {0x1329160, 0x1}, {0x1330820, 0xc0005a2780}, {0xc0003a28c0?, 0x2?, 0x2?}, {{0xc0005b7500, ...}, ...})
62: [0.09s] /app/cmd/shim/secret_scrub.go:39 +0x345
62: [0.09s] main.shim()
62: [0.09s] /app/cmd/shim/main.go:259 +0xc52
62: [0.09s] main.main()
62: [0.09s] /app/cmd/shim/main.go:76 +0x74
62: [0.09s]
```
[Relevant line of code](https://github.com/sipsma/dagger/blob/d71867c127f6970113221c57fc03d2c8084b6c0a/cmd/shim/secret_scrub.go#L230-L230)
Not 100% sure but suspect I may have somehow set a secret value to `""`? That seems like a plausible explanation, but haven't looked at this in depth.
cc @jedevc | https://github.com/dagger/dagger/issues/6630 | https://github.com/dagger/dagger/pull/6641 | 794e3b3d298c7ca77dfedf5bf3d98d143ed05095 | 0c0de6b23b0151a9d1debfa8cbc879fd30391ab5 | 2024-02-08T23:51:48Z | go | 2024-02-12T14:41:35Z | cmd/shim/secret_scrub_test.go | t.Parallel()
fsys := fstest.MapFS{
"mysecret": &fstest.MapFile{
Data: []byte("my secret file"),
},
"subdir/alsosecret": &fstest.MapFile{
Data: []byte("a subdir secret file \nwith line feed"),
},
}
env := []string{
"MY_SECRET_ID=my secret value",
}
t.Run("scrub files and env", func(t *testing.T) {
var buf bytes.Buffer
buf.WriteString("I love to share my secret value to my close ones. But I keep my secret file to myself. As well as a subdir secret file \nwith line feed.")
currentDirPath := "/"
r, err := NewSecretScrubReader(&buf, currentDirPath, fsys, env, core.SecretToScrubInfo{
Envs: []string{"MY_SECRET_ID"}, |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,630 | `slice bounds out of range [1:0]` panic in shim secret scrubbing | Hit this while testing publish things in my fork: https://github.com/sipsma/dagger/actions/runs/7837271347/job/21386972933#step:4:2866
Stack:
```
62: [0.09s] panic: runtime error: slice bounds out of range [1:0] goroutine 1 [running, locked to thread]:
62: [0.09s] runtime/debug.Stack()
62: [0.09s] /usr/local/go/src/runtime/debug/stack.go:24 +0x5e
62: [0.09s] main.main.func1()
62: [0.09s] /app/cmd/shim/main.go:63 +0x38
62: [0.09s] panic({0x1105620?, 0xc000044c78?})
62: [0.09s] /usr/local/go/src/runtime/panic.go:914 +0x21f
62: [0.09s] main.(*Trie).Insert(0xc00008b020?, {0xc0001a2b90, 0x4e, 0x50}, {0x1b18a8e, 0x3, 0x3})
62: [0.09s] /app/cmd/shim/secret_scrub.go:230 +0x351
62: [0.09s] main.NewSecretScrubReader({0x13307a0?, 0xc000126938}, {0x1329160, 0x1}, {0x1330820, 0xc0005a2780}, {0xc0003a28c0?, 0x2?, 0x2?}, {{0xc0005b7500, ...}, ...})
62: [0.09s] /app/cmd/shim/secret_scrub.go:39 +0x345
62: [0.09s] main.shim()
62: [0.09s] /app/cmd/shim/main.go:259 +0xc52
62: [0.09s] main.main()
62: [0.09s] /app/cmd/shim/main.go:76 +0x74
62: [0.09s]
```
[Relevant line of code](https://github.com/sipsma/dagger/blob/d71867c127f6970113221c57fc03d2c8084b6c0a/cmd/shim/secret_scrub.go#L230-L230)
Not 100% sure but suspect I may have somehow set a secret value to `""`? That seems like a plausible explanation, but haven't looked at this in depth.
cc @jedevc | https://github.com/dagger/dagger/issues/6630 | https://github.com/dagger/dagger/pull/6641 | 794e3b3d298c7ca77dfedf5bf3d98d143ed05095 | 0c0de6b23b0151a9d1debfa8cbc879fd30391ab5 | 2024-02-08T23:51:48Z | go | 2024-02-12T14:41:35Z | cmd/shim/secret_scrub_test.go | Files: []string{"/mysecret", "/subdir/alsosecret"},
})
require.NoError(t, err)
out, err := io.ReadAll(r)
require.NoError(t, err)
want := "I love to share *** to my close ones. But I keep *** to myself. As well as ***."
require.Equal(t, want, string(out))
})
t.Run("do not scrub empty env", func(t *testing.T) {
env := append(env, "EMPTY_SECRET_ID=")
currentDirPath := "/"
fsys := fstest.MapFS{
"emptysecret": &fstest.MapFile{
Data: []byte(""),
},
}
var buf bytes.Buffer
buf.WriteString("I love to share my secret value to my close ones. But I keep my secret file to myself.")
r, err := NewSecretScrubReader(&buf, currentDirPath, fsys, env, core.SecretToScrubInfo{
Envs: []string{"EMPTY_SECRET_ID"},
Files: []string{"/emptysecret"},
})
require.NoError(t, err)
out, err := io.ReadAll(r)
require.NoError(t, err)
want := "I love to share my secret value to my close ones. But I keep my secret file to myself."
require.Equal(t, want, string(out))
})
}
func TestLoadSecretsToScrubFromEnv(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,630 | `slice bounds out of range [1:0]` panic in shim secret scrubbing | Hit this while testing publish things in my fork: https://github.com/sipsma/dagger/actions/runs/7837271347/job/21386972933#step:4:2866
Stack:
```
62: [0.09s] panic: runtime error: slice bounds out of range [1:0] goroutine 1 [running, locked to thread]:
62: [0.09s] runtime/debug.Stack()
62: [0.09s] /usr/local/go/src/runtime/debug/stack.go:24 +0x5e
62: [0.09s] main.main.func1()
62: [0.09s] /app/cmd/shim/main.go:63 +0x38
62: [0.09s] panic({0x1105620?, 0xc000044c78?})
62: [0.09s] /usr/local/go/src/runtime/panic.go:914 +0x21f
62: [0.09s] main.(*Trie).Insert(0xc00008b020?, {0xc0001a2b90, 0x4e, 0x50}, {0x1b18a8e, 0x3, 0x3})
62: [0.09s] /app/cmd/shim/secret_scrub.go:230 +0x351
62: [0.09s] main.NewSecretScrubReader({0x13307a0?, 0xc000126938}, {0x1329160, 0x1}, {0x1330820, 0xc0005a2780}, {0xc0003a28c0?, 0x2?, 0x2?}, {{0xc0005b7500, ...}, ...})
62: [0.09s] /app/cmd/shim/secret_scrub.go:39 +0x345
62: [0.09s] main.shim()
62: [0.09s] /app/cmd/shim/main.go:259 +0xc52
62: [0.09s] main.main()
62: [0.09s] /app/cmd/shim/main.go:76 +0x74
62: [0.09s]
```
[Relevant line of code](https://github.com/sipsma/dagger/blob/d71867c127f6970113221c57fc03d2c8084b6c0a/cmd/shim/secret_scrub.go#L230-L230)
Not 100% sure but suspect I may have somehow set a secret value to `""`? That seems like a plausible explanation, but haven't looked at this in depth.
cc @jedevc | https://github.com/dagger/dagger/issues/6630 | https://github.com/dagger/dagger/pull/6641 | 794e3b3d298c7ca77dfedf5bf3d98d143ed05095 | 0c0de6b23b0151a9d1debfa8cbc879fd30391ab5 | 2024-02-08T23:51:48Z | go | 2024-02-12T14:41:35Z | cmd/shim/secret_scrub_test.go | t.Parallel()
secretValue := "my secret value"
env := []string{
fmt.Sprintf("MY_SECRET_ID=%s", secretValue),
"PUBLIC_STUFF=so public",
}
secretToScrub := core.SecretToScrubInfo{
Envs: []string{
"MY_SECRET_ID",
},
}
secrets := loadSecretsToScrubFromEnv(env, secretToScrub.Envs)
require.NotContains(t, secrets, "PUBLIC_STUFF")
require.Contains(t, secrets, secretValue)
}
func TestLoadSecretsToScrubFromFiles(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,630 | `slice bounds out of range [1:0]` panic in shim secret scrubbing | Hit this while testing publish things in my fork: https://github.com/sipsma/dagger/actions/runs/7837271347/job/21386972933#step:4:2866
Stack:
```
62: [0.09s] panic: runtime error: slice bounds out of range [1:0] goroutine 1 [running, locked to thread]:
62: [0.09s] runtime/debug.Stack()
62: [0.09s] /usr/local/go/src/runtime/debug/stack.go:24 +0x5e
62: [0.09s] main.main.func1()
62: [0.09s] /app/cmd/shim/main.go:63 +0x38
62: [0.09s] panic({0x1105620?, 0xc000044c78?})
62: [0.09s] /usr/local/go/src/runtime/panic.go:914 +0x21f
62: [0.09s] main.(*Trie).Insert(0xc00008b020?, {0xc0001a2b90, 0x4e, 0x50}, {0x1b18a8e, 0x3, 0x3})
62: [0.09s] /app/cmd/shim/secret_scrub.go:230 +0x351
62: [0.09s] main.NewSecretScrubReader({0x13307a0?, 0xc000126938}, {0x1329160, 0x1}, {0x1330820, 0xc0005a2780}, {0xc0003a28c0?, 0x2?, 0x2?}, {{0xc0005b7500, ...}, ...})
62: [0.09s] /app/cmd/shim/secret_scrub.go:39 +0x345
62: [0.09s] main.shim()
62: [0.09s] /app/cmd/shim/main.go:259 +0xc52
62: [0.09s] main.main()
62: [0.09s] /app/cmd/shim/main.go:76 +0x74
62: [0.09s]
```
[Relevant line of code](https://github.com/sipsma/dagger/blob/d71867c127f6970113221c57fc03d2c8084b6c0a/cmd/shim/secret_scrub.go#L230-L230)
Not 100% sure but suspect I may have somehow set a secret value to `""`? That seems like a plausible explanation, but haven't looked at this in depth.
cc @jedevc | https://github.com/dagger/dagger/issues/6630 | https://github.com/dagger/dagger/pull/6641 | 794e3b3d298c7ca77dfedf5bf3d98d143ed05095 | 0c0de6b23b0151a9d1debfa8cbc879fd30391ab5 | 2024-02-08T23:51:48Z | go | 2024-02-12T14:41:35Z | cmd/shim/secret_scrub_test.go | t.Parallel()
const currentDirPath = "/mnt"
t.Run("/mnt, fs relative, secret absolute", func(t *testing.T) {
fsys := fstest.MapFS{
"mysecret": &fstest.MapFile{
Data: []byte("my secret file"),
},
"subdir/alsosecret": &fstest.MapFile{
Data: []byte("a subdir secret file"),
},
}
secretFilePathsToScrub := []string{"/mnt/mysecret", "/mnt/subdir/alsosecret"}
secrets, err := loadSecretsToScrubFromFiles(currentDirPath, fsys, secretFilePathsToScrub)
require.NoError(t, err)
require.Contains(t, secrets, "my secret file")
require.Contains(t, secrets, "a subdir secret file")
})
t.Run("/mnt, fs relative, secret relative", func(t *testing.T) {
fsys := fstest.MapFS{ |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,630 | `slice bounds out of range [1:0]` panic in shim secret scrubbing | Hit this while testing publish things in my fork: https://github.com/sipsma/dagger/actions/runs/7837271347/job/21386972933#step:4:2866
Stack:
```
62: [0.09s] panic: runtime error: slice bounds out of range [1:0] goroutine 1 [running, locked to thread]:
62: [0.09s] runtime/debug.Stack()
62: [0.09s] /usr/local/go/src/runtime/debug/stack.go:24 +0x5e
62: [0.09s] main.main.func1()
62: [0.09s] /app/cmd/shim/main.go:63 +0x38
62: [0.09s] panic({0x1105620?, 0xc000044c78?})
62: [0.09s] /usr/local/go/src/runtime/panic.go:914 +0x21f
62: [0.09s] main.(*Trie).Insert(0xc00008b020?, {0xc0001a2b90, 0x4e, 0x50}, {0x1b18a8e, 0x3, 0x3})
62: [0.09s] /app/cmd/shim/secret_scrub.go:230 +0x351
62: [0.09s] main.NewSecretScrubReader({0x13307a0?, 0xc000126938}, {0x1329160, 0x1}, {0x1330820, 0xc0005a2780}, {0xc0003a28c0?, 0x2?, 0x2?}, {{0xc0005b7500, ...}, ...})
62: [0.09s] /app/cmd/shim/secret_scrub.go:39 +0x345
62: [0.09s] main.shim()
62: [0.09s] /app/cmd/shim/main.go:259 +0xc52
62: [0.09s] main.main()
62: [0.09s] /app/cmd/shim/main.go:76 +0x74
62: [0.09s]
```
[Relevant line of code](https://github.com/sipsma/dagger/blob/d71867c127f6970113221c57fc03d2c8084b6c0a/cmd/shim/secret_scrub.go#L230-L230)
Not 100% sure but suspect I may have somehow set a secret value to `""`? That seems like a plausible explanation, but haven't looked at this in depth.
cc @jedevc | https://github.com/dagger/dagger/issues/6630 | https://github.com/dagger/dagger/pull/6641 | 794e3b3d298c7ca77dfedf5bf3d98d143ed05095 | 0c0de6b23b0151a9d1debfa8cbc879fd30391ab5 | 2024-02-08T23:51:48Z | go | 2024-02-12T14:41:35Z | cmd/shim/secret_scrub_test.go | "mysecret": &fstest.MapFile{
Data: []byte("my secret file"),
},
"subdir/alsosecret": &fstest.MapFile{
Data: []byte("a subdir secret file"),
},
}
secretFilePathsToScrub := []string{"mysecret", "subdir/alsosecret"}
secrets, err := loadSecretsToScrubFromFiles(currentDirPath, fsys, secretFilePathsToScrub)
require.NoError(t, err)
require.Contains(t, secrets, "my secret file")
require.Contains(t, secrets, "a subdir secret file")
})
t.Run("/mnt, fs absolute, secret relative", func(t *testing.T) {
fsys := fstest.MapFS{
"mnt/mysecret": &fstest.MapFile{
Data: []byte("my secret file"),
},
"mnt/subdir/alsosecret": &fstest.MapFile{
Data: []byte("a subdir secret file"),
},
}
secretFilePathsToScrub := []string{"mnt/mysecret", "mnt/subdir/alsosecret"}
secrets, err := loadSecretsToScrubFromFiles(currentDirPath, fsys, secretFilePathsToScrub)
require.NoError(t, err)
require.Contains(t, secrets, "my secret file")
require.Contains(t, secrets, "a subdir secret file")
})
}
func TestScrubSecretWrite(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,630 | `slice bounds out of range [1:0]` panic in shim secret scrubbing | Hit this while testing publish things in my fork: https://github.com/sipsma/dagger/actions/runs/7837271347/job/21386972933#step:4:2866
Stack:
```
62: [0.09s] panic: runtime error: slice bounds out of range [1:0] goroutine 1 [running, locked to thread]:
62: [0.09s] runtime/debug.Stack()
62: [0.09s] /usr/local/go/src/runtime/debug/stack.go:24 +0x5e
62: [0.09s] main.main.func1()
62: [0.09s] /app/cmd/shim/main.go:63 +0x38
62: [0.09s] panic({0x1105620?, 0xc000044c78?})
62: [0.09s] /usr/local/go/src/runtime/panic.go:914 +0x21f
62: [0.09s] main.(*Trie).Insert(0xc00008b020?, {0xc0001a2b90, 0x4e, 0x50}, {0x1b18a8e, 0x3, 0x3})
62: [0.09s] /app/cmd/shim/secret_scrub.go:230 +0x351
62: [0.09s] main.NewSecretScrubReader({0x13307a0?, 0xc000126938}, {0x1329160, 0x1}, {0x1330820, 0xc0005a2780}, {0xc0003a28c0?, 0x2?, 0x2?}, {{0xc0005b7500, ...}, ...})
62: [0.09s] /app/cmd/shim/secret_scrub.go:39 +0x345
62: [0.09s] main.shim()
62: [0.09s] /app/cmd/shim/main.go:259 +0xc52
62: [0.09s] main.main()
62: [0.09s] /app/cmd/shim/main.go:76 +0x74
62: [0.09s]
```
[Relevant line of code](https://github.com/sipsma/dagger/blob/d71867c127f6970113221c57fc03d2c8084b6c0a/cmd/shim/secret_scrub.go#L230-L230)
Not 100% sure but suspect I may have somehow set a secret value to `""`? That seems like a plausible explanation, but haven't looked at this in depth.
cc @jedevc | https://github.com/dagger/dagger/issues/6630 | https://github.com/dagger/dagger/pull/6641 | 794e3b3d298c7ca77dfedf5bf3d98d143ed05095 | 0c0de6b23b0151a9d1debfa8cbc879fd30391ab5 | 2024-02-08T23:51:48Z | go | 2024-02-12T14:41:35Z | cmd/shim/secret_scrub_test.go | t.Parallel()
envMap := map[string]string{
"secret1": "secret1 value",
"secret2": "secret2",
"sshSecretKey": sshSecretKey,
"sshPublicKey": sshPublicKey,
}
env := []string{}
for k, v := range envMap {
env = append(env, fmt.Sprintf("%s=%s", k, v))
}
envNames := []string{
"secret1",
"secret2",
"sshSecretKey",
"sshPublicKey",
}
secretToScrubInfo := core.SecretToScrubInfo{
Envs: envNames,
Files: []string{},
}
t.Run("multiline secret", func(t *testing.T) {
for input, expectedOutput := range map[string]string{
"aaa\n" + sshSecretKey + "\nbbb\nccc": "aaa\n***\nbbb\nccc",
"aaa" + sshSecretKey + "bbb\nccc": "aaa***bbb\nccc",
sshSecretKey: "***",
} {
var buf bytes.Buffer |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,630 | `slice bounds out of range [1:0]` panic in shim secret scrubbing | Hit this while testing publish things in my fork: https://github.com/sipsma/dagger/actions/runs/7837271347/job/21386972933#step:4:2866
Stack:
```
62: [0.09s] panic: runtime error: slice bounds out of range [1:0] goroutine 1 [running, locked to thread]:
62: [0.09s] runtime/debug.Stack()
62: [0.09s] /usr/local/go/src/runtime/debug/stack.go:24 +0x5e
62: [0.09s] main.main.func1()
62: [0.09s] /app/cmd/shim/main.go:63 +0x38
62: [0.09s] panic({0x1105620?, 0xc000044c78?})
62: [0.09s] /usr/local/go/src/runtime/panic.go:914 +0x21f
62: [0.09s] main.(*Trie).Insert(0xc00008b020?, {0xc0001a2b90, 0x4e, 0x50}, {0x1b18a8e, 0x3, 0x3})
62: [0.09s] /app/cmd/shim/secret_scrub.go:230 +0x351
62: [0.09s] main.NewSecretScrubReader({0x13307a0?, 0xc000126938}, {0x1329160, 0x1}, {0x1330820, 0xc0005a2780}, {0xc0003a28c0?, 0x2?, 0x2?}, {{0xc0005b7500, ...}, ...})
62: [0.09s] /app/cmd/shim/secret_scrub.go:39 +0x345
62: [0.09s] main.shim()
62: [0.09s] /app/cmd/shim/main.go:259 +0xc52
62: [0.09s] main.main()
62: [0.09s] /app/cmd/shim/main.go:76 +0x74
62: [0.09s]
```
[Relevant line of code](https://github.com/sipsma/dagger/blob/d71867c127f6970113221c57fc03d2c8084b6c0a/cmd/shim/secret_scrub.go#L230-L230)
Not 100% sure but suspect I may have somehow set a secret value to `""`? That seems like a plausible explanation, but haven't looked at this in depth.
cc @jedevc | https://github.com/dagger/dagger/issues/6630 | https://github.com/dagger/dagger/pull/6641 | 794e3b3d298c7ca77dfedf5bf3d98d143ed05095 | 0c0de6b23b0151a9d1debfa8cbc879fd30391ab5 | 2024-02-08T23:51:48Z | go | 2024-02-12T14:41:35Z | cmd/shim/secret_scrub_test.go | r, err := NewSecretScrubReader(&buf, "/", fstest.MapFS{}, env, secretToScrubInfo)
require.NoError(t, err)
_, err = buf.WriteString(input)
require.NoError(t, err)
out, err := io.ReadAll(r)
require.NoError(t, err)
require.Equal(t, expectedOutput, string(out))
}
})
t.Run("single line secret", func(t *testing.T) {
var buf bytes.Buffer
r, err := NewSecretScrubReader(&buf, "/", fstest.MapFS{}, env, secretToScrubInfo)
require.NoError(t, err)
input := "aaa\nsecret1 value\nno secret\n"
_, err = buf.WriteString(input)
require.NoError(t, err)
out, err := io.ReadAll(r)
require.NoError(t, err)
require.Equal(t, "aaa\n***\nno secret\n", string(out))
})
t.Run("multi write", func(t *testing.T) {
var buf bytes.Buffer
r, err := NewSecretScrubReader(&buf, "/", fstest.MapFS{}, env, secretToScrubInfo)
require.NoError(t, err)
inputLines := []string{
"secret1 value",
"secret2",
"nonsecret",
}
outputLines := []string{ |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,630 | `slice bounds out of range [1:0]` panic in shim secret scrubbing | Hit this while testing publish things in my fork: https://github.com/sipsma/dagger/actions/runs/7837271347/job/21386972933#step:4:2866
Stack:
```
62: [0.09s] panic: runtime error: slice bounds out of range [1:0] goroutine 1 [running, locked to thread]:
62: [0.09s] runtime/debug.Stack()
62: [0.09s] /usr/local/go/src/runtime/debug/stack.go:24 +0x5e
62: [0.09s] main.main.func1()
62: [0.09s] /app/cmd/shim/main.go:63 +0x38
62: [0.09s] panic({0x1105620?, 0xc000044c78?})
62: [0.09s] /usr/local/go/src/runtime/panic.go:914 +0x21f
62: [0.09s] main.(*Trie).Insert(0xc00008b020?, {0xc0001a2b90, 0x4e, 0x50}, {0x1b18a8e, 0x3, 0x3})
62: [0.09s] /app/cmd/shim/secret_scrub.go:230 +0x351
62: [0.09s] main.NewSecretScrubReader({0x13307a0?, 0xc000126938}, {0x1329160, 0x1}, {0x1330820, 0xc0005a2780}, {0xc0003a28c0?, 0x2?, 0x2?}, {{0xc0005b7500, ...}, ...})
62: [0.09s] /app/cmd/shim/secret_scrub.go:39 +0x345
62: [0.09s] main.shim()
62: [0.09s] /app/cmd/shim/main.go:259 +0xc52
62: [0.09s] main.main()
62: [0.09s] /app/cmd/shim/main.go:76 +0x74
62: [0.09s]
```
[Relevant line of code](https://github.com/sipsma/dagger/blob/d71867c127f6970113221c57fc03d2c8084b6c0a/cmd/shim/secret_scrub.go#L230-L230)
Not 100% sure but suspect I may have somehow set a secret value to `""`? That seems like a plausible explanation, but haven't looked at this in depth.
cc @jedevc | https://github.com/dagger/dagger/issues/6630 | https://github.com/dagger/dagger/pull/6641 | 794e3b3d298c7ca77dfedf5bf3d98d143ed05095 | 0c0de6b23b0151a9d1debfa8cbc879fd30391ab5 | 2024-02-08T23:51:48Z | go | 2024-02-12T14:41:35Z | cmd/shim/secret_scrub_test.go | "***",
"***",
"nonsecret",
}
for _, s := range inputLines {
buf.WriteString(s)
buf.WriteRune('\n')
}
scanner := bufio.NewScanner(r)
var i int
for scanner.Scan() {
out := scanner.Text()
expected := outputLines[i]
require.Equal(t, expected, out)
i++
}
require.Equal(t, len(outputLines), i)
})
}
func TestScrubSecretLogLatency(t *testing.T) {
t.Parallel()
envMap := map[string]string{
"foo": "TOP_SECRET",
"bar": strings.Repeat("a", 10_000),
"baz": "x",
"qux": "yyy",
}
env := []string{} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,630 | `slice bounds out of range [1:0]` panic in shim secret scrubbing | Hit this while testing publish things in my fork: https://github.com/sipsma/dagger/actions/runs/7837271347/job/21386972933#step:4:2866
Stack:
```
62: [0.09s] panic: runtime error: slice bounds out of range [1:0] goroutine 1 [running, locked to thread]:
62: [0.09s] runtime/debug.Stack()
62: [0.09s] /usr/local/go/src/runtime/debug/stack.go:24 +0x5e
62: [0.09s] main.main.func1()
62: [0.09s] /app/cmd/shim/main.go:63 +0x38
62: [0.09s] panic({0x1105620?, 0xc000044c78?})
62: [0.09s] /usr/local/go/src/runtime/panic.go:914 +0x21f
62: [0.09s] main.(*Trie).Insert(0xc00008b020?, {0xc0001a2b90, 0x4e, 0x50}, {0x1b18a8e, 0x3, 0x3})
62: [0.09s] /app/cmd/shim/secret_scrub.go:230 +0x351
62: [0.09s] main.NewSecretScrubReader({0x13307a0?, 0xc000126938}, {0x1329160, 0x1}, {0x1330820, 0xc0005a2780}, {0xc0003a28c0?, 0x2?, 0x2?}, {{0xc0005b7500, ...}, ...})
62: [0.09s] /app/cmd/shim/secret_scrub.go:39 +0x345
62: [0.09s] main.shim()
62: [0.09s] /app/cmd/shim/main.go:259 +0xc52
62: [0.09s] main.main()
62: [0.09s] /app/cmd/shim/main.go:76 +0x74
62: [0.09s]
```
[Relevant line of code](https://github.com/sipsma/dagger/blob/d71867c127f6970113221c57fc03d2c8084b6c0a/cmd/shim/secret_scrub.go#L230-L230)
Not 100% sure but suspect I may have somehow set a secret value to `""`? That seems like a plausible explanation, but haven't looked at this in depth.
cc @jedevc | https://github.com/dagger/dagger/issues/6630 | https://github.com/dagger/dagger/pull/6641 | 794e3b3d298c7ca77dfedf5bf3d98d143ed05095 | 0c0de6b23b0151a9d1debfa8cbc879fd30391ab5 | 2024-02-08T23:51:48Z | go | 2024-02-12T14:41:35Z | cmd/shim/secret_scrub_test.go | envNames := []string{}
for k, v := range envMap {
env = append(env, fmt.Sprintf("%s=%s", k, v))
envNames = append(envNames, k)
}
secretToScrubInfo := core.SecretToScrubInfo{
Envs: envNames,
Files: []string{},
}
t.Run("plain", func(t *testing.T) {
in, out := io.Pipe()
r, err := NewSecretScrubReader(in, "/", fstest.MapFS{}, env, secretToScrubInfo)
require.NoError(t, err)
wg := sync.WaitGroup{}
wg.Add(2)
go func() {
_, err := out.Write([]byte("hello world\n"))
require.NoError(t, err)
wg.Done()
}()
go func() {
buf := make([]byte, 1024)
n, err := r.Read(buf)
require.NoError(t, err)
require.Equal(t, "hello world\n", string(buf[:n]))
wg.Done()
}()
wg.Wait()
})
t.Run("secret", func(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,630 | `slice bounds out of range [1:0]` panic in shim secret scrubbing | Hit this while testing publish things in my fork: https://github.com/sipsma/dagger/actions/runs/7837271347/job/21386972933#step:4:2866
Stack:
```
62: [0.09s] panic: runtime error: slice bounds out of range [1:0] goroutine 1 [running, locked to thread]:
62: [0.09s] runtime/debug.Stack()
62: [0.09s] /usr/local/go/src/runtime/debug/stack.go:24 +0x5e
62: [0.09s] main.main.func1()
62: [0.09s] /app/cmd/shim/main.go:63 +0x38
62: [0.09s] panic({0x1105620?, 0xc000044c78?})
62: [0.09s] /usr/local/go/src/runtime/panic.go:914 +0x21f
62: [0.09s] main.(*Trie).Insert(0xc00008b020?, {0xc0001a2b90, 0x4e, 0x50}, {0x1b18a8e, 0x3, 0x3})
62: [0.09s] /app/cmd/shim/secret_scrub.go:230 +0x351
62: [0.09s] main.NewSecretScrubReader({0x13307a0?, 0xc000126938}, {0x1329160, 0x1}, {0x1330820, 0xc0005a2780}, {0xc0003a28c0?, 0x2?, 0x2?}, {{0xc0005b7500, ...}, ...})
62: [0.09s] /app/cmd/shim/secret_scrub.go:39 +0x345
62: [0.09s] main.shim()
62: [0.09s] /app/cmd/shim/main.go:259 +0xc52
62: [0.09s] main.main()
62: [0.09s] /app/cmd/shim/main.go:76 +0x74
62: [0.09s]
```
[Relevant line of code](https://github.com/sipsma/dagger/blob/d71867c127f6970113221c57fc03d2c8084b6c0a/cmd/shim/secret_scrub.go#L230-L230)
Not 100% sure but suspect I may have somehow set a secret value to `""`? That seems like a plausible explanation, but haven't looked at this in depth.
cc @jedevc | https://github.com/dagger/dagger/issues/6630 | https://github.com/dagger/dagger/pull/6641 | 794e3b3d298c7ca77dfedf5bf3d98d143ed05095 | 0c0de6b23b0151a9d1debfa8cbc879fd30391ab5 | 2024-02-08T23:51:48Z | go | 2024-02-12T14:41:35Z | cmd/shim/secret_scrub_test.go | in, out := io.Pipe()
r, err := NewSecretScrubReader(in, "/", fstest.MapFS{}, env, secretToScrubInfo)
require.NoError(t, err)
wg := sync.WaitGroup{}
wg.Add(2)
go func() {
_, err := out.Write([]byte("hello TOP_SECRET\n"))
require.NoError(t, err)
wg.Done()
}()
go func() {
buf := make([]byte, 1024)
n, err := r.Read(buf)
require.NoError(t, err)
require.Equal(t, "hello ***\n", string(buf[:n]))
wg.Done()
}()
wg.Wait()
})
t.Run("secret double", func(t *testing.T) {
in, out := io.Pipe()
r, err := NewSecretScrubReader(in, "/", fstest.MapFS{}, env, secretToScrubInfo)
require.NoError(t, err)
wg := sync.WaitGroup{}
wg.Add(2)
go func() {
_, err := out.Write([]byte("hello TOP_TOP_SECRETTOP_SECRETTOP_\n"))
require.NoError(t, err)
wg.Done()
}() |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,630 | `slice bounds out of range [1:0]` panic in shim secret scrubbing | Hit this while testing publish things in my fork: https://github.com/sipsma/dagger/actions/runs/7837271347/job/21386972933#step:4:2866
Stack:
```
62: [0.09s] panic: runtime error: slice bounds out of range [1:0] goroutine 1 [running, locked to thread]:
62: [0.09s] runtime/debug.Stack()
62: [0.09s] /usr/local/go/src/runtime/debug/stack.go:24 +0x5e
62: [0.09s] main.main.func1()
62: [0.09s] /app/cmd/shim/main.go:63 +0x38
62: [0.09s] panic({0x1105620?, 0xc000044c78?})
62: [0.09s] /usr/local/go/src/runtime/panic.go:914 +0x21f
62: [0.09s] main.(*Trie).Insert(0xc00008b020?, {0xc0001a2b90, 0x4e, 0x50}, {0x1b18a8e, 0x3, 0x3})
62: [0.09s] /app/cmd/shim/secret_scrub.go:230 +0x351
62: [0.09s] main.NewSecretScrubReader({0x13307a0?, 0xc000126938}, {0x1329160, 0x1}, {0x1330820, 0xc0005a2780}, {0xc0003a28c0?, 0x2?, 0x2?}, {{0xc0005b7500, ...}, ...})
62: [0.09s] /app/cmd/shim/secret_scrub.go:39 +0x345
62: [0.09s] main.shim()
62: [0.09s] /app/cmd/shim/main.go:259 +0xc52
62: [0.09s] main.main()
62: [0.09s] /app/cmd/shim/main.go:76 +0x74
62: [0.09s]
```
[Relevant line of code](https://github.com/sipsma/dagger/blob/d71867c127f6970113221c57fc03d2c8084b6c0a/cmd/shim/secret_scrub.go#L230-L230)
Not 100% sure but suspect I may have somehow set a secret value to `""`? That seems like a plausible explanation, but haven't looked at this in depth.
cc @jedevc | https://github.com/dagger/dagger/issues/6630 | https://github.com/dagger/dagger/pull/6641 | 794e3b3d298c7ca77dfedf5bf3d98d143ed05095 | 0c0de6b23b0151a9d1debfa8cbc879fd30391ab5 | 2024-02-08T23:51:48Z | go | 2024-02-12T14:41:35Z | cmd/shim/secret_scrub_test.go | go func() {
buf := make([]byte, 1024)
n, err := r.Read(buf)
require.NoError(t, err)
require.Equal(t, "hello TOP_******TOP_\n", string(buf[:n]))
wg.Done()
}()
wg.Wait()
})
t.Run("secret one byte", func(t *testing.T) {
in, out := io.Pipe()
r, err := NewSecretScrubReader(in, "/", fstest.MapFS{}, env, secretToScrubInfo)
require.NoError(t, err)
wg := sync.WaitGroup{}
wg.Add(2)
go func() {
_, err := out.Write([]byte("yyx\n"))
require.NoError(t, err)
wg.Done()
}()
go func() {
buf := make([]byte, 1024)
n, err := r.Read(buf)
require.NoError(t, err)
require.Equal(t, "yy***\n", string(buf[:n]))
wg.Done()
}()
wg.Wait()
})
t.Run("secret half", func(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,630 | `slice bounds out of range [1:0]` panic in shim secret scrubbing | Hit this while testing publish things in my fork: https://github.com/sipsma/dagger/actions/runs/7837271347/job/21386972933#step:4:2866
Stack:
```
62: [0.09s] panic: runtime error: slice bounds out of range [1:0] goroutine 1 [running, locked to thread]:
62: [0.09s] runtime/debug.Stack()
62: [0.09s] /usr/local/go/src/runtime/debug/stack.go:24 +0x5e
62: [0.09s] main.main.func1()
62: [0.09s] /app/cmd/shim/main.go:63 +0x38
62: [0.09s] panic({0x1105620?, 0xc000044c78?})
62: [0.09s] /usr/local/go/src/runtime/panic.go:914 +0x21f
62: [0.09s] main.(*Trie).Insert(0xc00008b020?, {0xc0001a2b90, 0x4e, 0x50}, {0x1b18a8e, 0x3, 0x3})
62: [0.09s] /app/cmd/shim/secret_scrub.go:230 +0x351
62: [0.09s] main.NewSecretScrubReader({0x13307a0?, 0xc000126938}, {0x1329160, 0x1}, {0x1330820, 0xc0005a2780}, {0xc0003a28c0?, 0x2?, 0x2?}, {{0xc0005b7500, ...}, ...})
62: [0.09s] /app/cmd/shim/secret_scrub.go:39 +0x345
62: [0.09s] main.shim()
62: [0.09s] /app/cmd/shim/main.go:259 +0xc52
62: [0.09s] main.main()
62: [0.09s] /app/cmd/shim/main.go:76 +0x74
62: [0.09s]
```
[Relevant line of code](https://github.com/sipsma/dagger/blob/d71867c127f6970113221c57fc03d2c8084b6c0a/cmd/shim/secret_scrub.go#L230-L230)
Not 100% sure but suspect I may have somehow set a secret value to `""`? That seems like a plausible explanation, but haven't looked at this in depth.
cc @jedevc | https://github.com/dagger/dagger/issues/6630 | https://github.com/dagger/dagger/pull/6641 | 794e3b3d298c7ca77dfedf5bf3d98d143ed05095 | 0c0de6b23b0151a9d1debfa8cbc879fd30391ab5 | 2024-02-08T23:51:48Z | go | 2024-02-12T14:41:35Z | cmd/shim/secret_scrub_test.go | in, out := io.Pipe()
r, err := NewSecretScrubReader(in, "/", fstest.MapFS{}, env, secretToScrubInfo)
require.NoError(t, err)
wg := sync.WaitGroup{}
wg.Add(2)
go func() {
_, err := out.Write([]byte("hello TOP_"))
require.NoError(t, err)
_, err = out.Write([]byte("SECRET!\n"))
require.NoError(t, err)
wg.Done()
}()
go func() {
buf := make([]byte, 1024)
n, err := r.Read(buf)
require.NoError(t, err)
require.Equal(t, "hello ", string(buf[:n]))
n, err = r.Read(buf)
require.NoError(t, err)
require.Equal(t, "***!\n", string(buf[:n]))
wg.Done()
}()
wg.Wait()
})
t.Run("eof", func(t *testing.T) {
in, out := io.Pipe()
r, err := NewSecretScrubReader(in, "/", fstest.MapFS{}, env, secretToScrubInfo)
require.NoError(t, err)
wg := sync.WaitGroup{}
wg.Add(2) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,630 | `slice bounds out of range [1:0]` panic in shim secret scrubbing | Hit this while testing publish things in my fork: https://github.com/sipsma/dagger/actions/runs/7837271347/job/21386972933#step:4:2866
Stack:
```
62: [0.09s] panic: runtime error: slice bounds out of range [1:0] goroutine 1 [running, locked to thread]:
62: [0.09s] runtime/debug.Stack()
62: [0.09s] /usr/local/go/src/runtime/debug/stack.go:24 +0x5e
62: [0.09s] main.main.func1()
62: [0.09s] /app/cmd/shim/main.go:63 +0x38
62: [0.09s] panic({0x1105620?, 0xc000044c78?})
62: [0.09s] /usr/local/go/src/runtime/panic.go:914 +0x21f
62: [0.09s] main.(*Trie).Insert(0xc00008b020?, {0xc0001a2b90, 0x4e, 0x50}, {0x1b18a8e, 0x3, 0x3})
62: [0.09s] /app/cmd/shim/secret_scrub.go:230 +0x351
62: [0.09s] main.NewSecretScrubReader({0x13307a0?, 0xc000126938}, {0x1329160, 0x1}, {0x1330820, 0xc0005a2780}, {0xc0003a28c0?, 0x2?, 0x2?}, {{0xc0005b7500, ...}, ...})
62: [0.09s] /app/cmd/shim/secret_scrub.go:39 +0x345
62: [0.09s] main.shim()
62: [0.09s] /app/cmd/shim/main.go:259 +0xc52
62: [0.09s] main.main()
62: [0.09s] /app/cmd/shim/main.go:76 +0x74
62: [0.09s]
```
[Relevant line of code](https://github.com/sipsma/dagger/blob/d71867c127f6970113221c57fc03d2c8084b6c0a/cmd/shim/secret_scrub.go#L230-L230)
Not 100% sure but suspect I may have somehow set a secret value to `""`? That seems like a plausible explanation, but haven't looked at this in depth.
cc @jedevc | https://github.com/dagger/dagger/issues/6630 | https://github.com/dagger/dagger/pull/6641 | 794e3b3d298c7ca77dfedf5bf3d98d143ed05095 | 0c0de6b23b0151a9d1debfa8cbc879fd30391ab5 | 2024-02-08T23:51:48Z | go | 2024-02-12T14:41:35Z | cmd/shim/secret_scrub_test.go | go func() {
_, err := out.Write([]byte("hello TOP_"))
require.NoError(t, err)
err = out.Close()
require.NoError(t, err)
wg.Done()
}()
go func() {
buf := make([]byte, 1024)
n, err := r.Read(buf)
require.NoError(t, err)
require.Equal(t, "hello ", string(buf[:n]))
n, err = r.Read(buf)
require.ErrorIs(t, err, io.EOF)
require.Equal(t, "TOP_", string(buf[:n]))
wg.Done()
}()
wg.Wait()
})
t.Run("massive", func(t *testing.T) {
in, out := io.Pipe()
r, err := NewSecretScrubReader(in, "/", fstest.MapFS{}, env, secretToScrubInfo)
require.NoError(t, err)
wg := sync.WaitGroup{}
wg.Add(2)
go func() {
_, err := out.Write([]byte("hello\n" + strings.Repeat("a", 7000)))
require.NoError(t, err)
_, err = out.Write([]byte(strings.Repeat("a", 3001) + "\n"))
require.NoError(t, err) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,630 | `slice bounds out of range [1:0]` panic in shim secret scrubbing | Hit this while testing publish things in my fork: https://github.com/sipsma/dagger/actions/runs/7837271347/job/21386972933#step:4:2866
Stack:
```
62: [0.09s] panic: runtime error: slice bounds out of range [1:0] goroutine 1 [running, locked to thread]:
62: [0.09s] runtime/debug.Stack()
62: [0.09s] /usr/local/go/src/runtime/debug/stack.go:24 +0x5e
62: [0.09s] main.main.func1()
62: [0.09s] /app/cmd/shim/main.go:63 +0x38
62: [0.09s] panic({0x1105620?, 0xc000044c78?})
62: [0.09s] /usr/local/go/src/runtime/panic.go:914 +0x21f
62: [0.09s] main.(*Trie).Insert(0xc00008b020?, {0xc0001a2b90, 0x4e, 0x50}, {0x1b18a8e, 0x3, 0x3})
62: [0.09s] /app/cmd/shim/secret_scrub.go:230 +0x351
62: [0.09s] main.NewSecretScrubReader({0x13307a0?, 0xc000126938}, {0x1329160, 0x1}, {0x1330820, 0xc0005a2780}, {0xc0003a28c0?, 0x2?, 0x2?}, {{0xc0005b7500, ...}, ...})
62: [0.09s] /app/cmd/shim/secret_scrub.go:39 +0x345
62: [0.09s] main.shim()
62: [0.09s] /app/cmd/shim/main.go:259 +0xc52
62: [0.09s] main.main()
62: [0.09s] /app/cmd/shim/main.go:76 +0x74
62: [0.09s]
```
[Relevant line of code](https://github.com/sipsma/dagger/blob/d71867c127f6970113221c57fc03d2c8084b6c0a/cmd/shim/secret_scrub.go#L230-L230)
Not 100% sure but suspect I may have somehow set a secret value to `""`? That seems like a plausible explanation, but haven't looked at this in depth.
cc @jedevc | https://github.com/dagger/dagger/issues/6630 | https://github.com/dagger/dagger/pull/6641 | 794e3b3d298c7ca77dfedf5bf3d98d143ed05095 | 0c0de6b23b0151a9d1debfa8cbc879fd30391ab5 | 2024-02-08T23:51:48Z | go | 2024-02-12T14:41:35Z | cmd/shim/secret_scrub_test.go | _, err = out.Write([]byte("hello\n" + strings.Repeat("a", 7000)))
require.NoError(t, err)
_, err = out.Write([]byte(strings.Repeat("a", 2999) + "\n"))
require.NoError(t, err)
wg.Done()
}()
go func() {
buf := make([]byte, 4096)
n, err := r.Read(buf)
require.NoError(t, err)
require.Equal(t, "hello\n", string(buf[:n]))
n, err = r.Read(buf)
require.NoError(t, err)
require.Equal(t, "***a\n", string(buf[:n]))
n, err = r.Read(buf)
require.NoError(t, err)
require.Equal(t, "hello\n", string(buf[:n]))
n, err = r.Read(buf)
require.NoError(t, err)
require.Equal(t, strings.Repeat("a", 4096), string(buf[:n]))
n, err = r.Read(buf)
require.NoError(t, err)
require.Equal(t, strings.Repeat("a", 4096), string(buf[:n]))
n, err = r.Read(buf)
require.NoError(t, err)
require.Equal(t, strings.Repeat("a", 1807)+"\n", string(buf[:n]))
wg.Done()
}()
wg.Wait()
}) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,630 | `slice bounds out of range [1:0]` panic in shim secret scrubbing | Hit this while testing publish things in my fork: https://github.com/sipsma/dagger/actions/runs/7837271347/job/21386972933#step:4:2866
Stack:
```
62: [0.09s] panic: runtime error: slice bounds out of range [1:0] goroutine 1 [running, locked to thread]:
62: [0.09s] runtime/debug.Stack()
62: [0.09s] /usr/local/go/src/runtime/debug/stack.go:24 +0x5e
62: [0.09s] main.main.func1()
62: [0.09s] /app/cmd/shim/main.go:63 +0x38
62: [0.09s] panic({0x1105620?, 0xc000044c78?})
62: [0.09s] /usr/local/go/src/runtime/panic.go:914 +0x21f
62: [0.09s] main.(*Trie).Insert(0xc00008b020?, {0xc0001a2b90, 0x4e, 0x50}, {0x1b18a8e, 0x3, 0x3})
62: [0.09s] /app/cmd/shim/secret_scrub.go:230 +0x351
62: [0.09s] main.NewSecretScrubReader({0x13307a0?, 0xc000126938}, {0x1329160, 0x1}, {0x1330820, 0xc0005a2780}, {0xc0003a28c0?, 0x2?, 0x2?}, {{0xc0005b7500, ...}, ...})
62: [0.09s] /app/cmd/shim/secret_scrub.go:39 +0x345
62: [0.09s] main.shim()
62: [0.09s] /app/cmd/shim/main.go:259 +0xc52
62: [0.09s] main.main()
62: [0.09s] /app/cmd/shim/main.go:76 +0x74
62: [0.09s]
```
[Relevant line of code](https://github.com/sipsma/dagger/blob/d71867c127f6970113221c57fc03d2c8084b6c0a/cmd/shim/secret_scrub.go#L230-L230)
Not 100% sure but suspect I may have somehow set a secret value to `""`? That seems like a plausible explanation, but haven't looked at this in depth.
cc @jedevc | https://github.com/dagger/dagger/issues/6630 | https://github.com/dagger/dagger/pull/6641 | 794e3b3d298c7ca77dfedf5bf3d98d143ed05095 | 0c0de6b23b0151a9d1debfa8cbc879fd30391ab5 | 2024-02-08T23:51:48Z | go | 2024-02-12T14:41:35Z | cmd/shim/secret_scrub_test.go | t.Run("massive_eof", func(t *testing.T) {
in, out := io.Pipe()
r, err := NewSecretScrubReader(in, "/", fstest.MapFS{}, env, secretToScrubInfo)
require.NoError(t, err)
wg := sync.WaitGroup{}
wg.Add(2)
go func() {
_, err := out.Write([]byte(strings.Repeat("a", 9999)))
require.NoError(t, err)
err = out.Close()
require.NoError(t, err)
wg.Done()
}()
go func() {
buf := make([]byte, 4096)
n, err := r.Read(buf)
require.NoError(t, err)
require.Equal(t, strings.Repeat("a", 4096), string(buf[:n]))
n, err = r.Read(buf)
require.NoError(t, err)
require.Equal(t, strings.Repeat("a", 4096), string(buf[:n]))
n, err = r.Read(buf)
require.ErrorIs(t, err, io.EOF)
require.Equal(t, strings.Repeat("a", 1807), string(buf[:n]))
wg.Done()
}()
wg.Wait()
})
}
func BenchmarkScrubSecret(b *testing.B) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,630 | `slice bounds out of range [1:0]` panic in shim secret scrubbing | Hit this while testing publish things in my fork: https://github.com/sipsma/dagger/actions/runs/7837271347/job/21386972933#step:4:2866
Stack:
```
62: [0.09s] panic: runtime error: slice bounds out of range [1:0] goroutine 1 [running, locked to thread]:
62: [0.09s] runtime/debug.Stack()
62: [0.09s] /usr/local/go/src/runtime/debug/stack.go:24 +0x5e
62: [0.09s] main.main.func1()
62: [0.09s] /app/cmd/shim/main.go:63 +0x38
62: [0.09s] panic({0x1105620?, 0xc000044c78?})
62: [0.09s] /usr/local/go/src/runtime/panic.go:914 +0x21f
62: [0.09s] main.(*Trie).Insert(0xc00008b020?, {0xc0001a2b90, 0x4e, 0x50}, {0x1b18a8e, 0x3, 0x3})
62: [0.09s] /app/cmd/shim/secret_scrub.go:230 +0x351
62: [0.09s] main.NewSecretScrubReader({0x13307a0?, 0xc000126938}, {0x1329160, 0x1}, {0x1330820, 0xc0005a2780}, {0xc0003a28c0?, 0x2?, 0x2?}, {{0xc0005b7500, ...}, ...})
62: [0.09s] /app/cmd/shim/secret_scrub.go:39 +0x345
62: [0.09s] main.shim()
62: [0.09s] /app/cmd/shim/main.go:259 +0xc52
62: [0.09s] main.main()
62: [0.09s] /app/cmd/shim/main.go:76 +0x74
62: [0.09s]
```
[Relevant line of code](https://github.com/sipsma/dagger/blob/d71867c127f6970113221c57fc03d2c8084b6c0a/cmd/shim/secret_scrub.go#L230-L230)
Not 100% sure but suspect I may have somehow set a secret value to `""`? That seems like a plausible explanation, but haven't looked at this in depth.
cc @jedevc | https://github.com/dagger/dagger/issues/6630 | https://github.com/dagger/dagger/pull/6641 | 794e3b3d298c7ca77dfedf5bf3d98d143ed05095 | 0c0de6b23b0151a9d1debfa8cbc879fd30391ab5 | 2024-02-08T23:51:48Z | go | 2024-02-12T14:41:35Z | cmd/shim/secret_scrub_test.go | envMap := map[string]string{
"foo": strings.Repeat("a", 50),
"bar": strings.Repeat("b", 50),
"baz": strings.Repeat("c", 50),
"qux": strings.Repeat("d", 50),
"quu": strings.Repeat("e", 50),
"quv": strings.Repeat("f", 50),
"quw": strings.Repeat("g", 50),
"quy": strings.Repeat("i", 50),
"quz": strings.Repeat("j", 50),
}
env := []string{}
envNames := []string{}
for k, v := range envMap {
env = append(env, fmt.Sprintf("%s=%s", k, v))
envNames = append(envNames, k)
}
secretToScrubInfo := core.SecretToScrubInfo{
Envs: envNames,
Files: []string{},
}
in, out := io.Pipe()
r, err := NewSecretScrubReader(in, "/", fstest.MapFS{}, env, secretToScrubInfo)
require.NoError(b, err)
wg := sync.WaitGroup{} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,630 | `slice bounds out of range [1:0]` panic in shim secret scrubbing | Hit this while testing publish things in my fork: https://github.com/sipsma/dagger/actions/runs/7837271347/job/21386972933#step:4:2866
Stack:
```
62: [0.09s] panic: runtime error: slice bounds out of range [1:0] goroutine 1 [running, locked to thread]:
62: [0.09s] runtime/debug.Stack()
62: [0.09s] /usr/local/go/src/runtime/debug/stack.go:24 +0x5e
62: [0.09s] main.main.func1()
62: [0.09s] /app/cmd/shim/main.go:63 +0x38
62: [0.09s] panic({0x1105620?, 0xc000044c78?})
62: [0.09s] /usr/local/go/src/runtime/panic.go:914 +0x21f
62: [0.09s] main.(*Trie).Insert(0xc00008b020?, {0xc0001a2b90, 0x4e, 0x50}, {0x1b18a8e, 0x3, 0x3})
62: [0.09s] /app/cmd/shim/secret_scrub.go:230 +0x351
62: [0.09s] main.NewSecretScrubReader({0x13307a0?, 0xc000126938}, {0x1329160, 0x1}, {0x1330820, 0xc0005a2780}, {0xc0003a28c0?, 0x2?, 0x2?}, {{0xc0005b7500, ...}, ...})
62: [0.09s] /app/cmd/shim/secret_scrub.go:39 +0x345
62: [0.09s] main.shim()
62: [0.09s] /app/cmd/shim/main.go:259 +0xc52
62: [0.09s] main.main()
62: [0.09s] /app/cmd/shim/main.go:76 +0x74
62: [0.09s]
```
[Relevant line of code](https://github.com/sipsma/dagger/blob/d71867c127f6970113221c57fc03d2c8084b6c0a/cmd/shim/secret_scrub.go#L230-L230)
Not 100% sure but suspect I may have somehow set a secret value to `""`? That seems like a plausible explanation, but haven't looked at this in depth.
cc @jedevc | https://github.com/dagger/dagger/issues/6630 | https://github.com/dagger/dagger/pull/6641 | 794e3b3d298c7ca77dfedf5bf3d98d143ed05095 | 0c0de6b23b0151a9d1debfa8cbc879fd30391ab5 | 2024-02-08T23:51:48Z | go | 2024-02-12T14:41:35Z | cmd/shim/secret_scrub_test.go | wg.Add(2)
go func() {
for i := 0; i < b.N; i++ {
data := make([]byte, 4096)
for i := range data {
data[i] = byte(rand.Intn(256))
}
secret := []byte(strings.Repeat("a", rand.Intn(50)+25))
idx := rand.Intn(len(data) - len(secret))
copy(data[idx:], secret)
_, err := out.Write(data)
require.NoError(b, err)
}
err := out.Close()
require.NoError(b, err)
wg.Done()
}()
go func() {
data, err := io.ReadAll(r)
require.NoError(b, err)
require.NotContains(b, string(data), strings.Repeat("a", 50))
wg.Done()
}()
wg.Wait()
}
func TestTrie(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,630 | `slice bounds out of range [1:0]` panic in shim secret scrubbing | Hit this while testing publish things in my fork: https://github.com/sipsma/dagger/actions/runs/7837271347/job/21386972933#step:4:2866
Stack:
```
62: [0.09s] panic: runtime error: slice bounds out of range [1:0] goroutine 1 [running, locked to thread]:
62: [0.09s] runtime/debug.Stack()
62: [0.09s] /usr/local/go/src/runtime/debug/stack.go:24 +0x5e
62: [0.09s] main.main.func1()
62: [0.09s] /app/cmd/shim/main.go:63 +0x38
62: [0.09s] panic({0x1105620?, 0xc000044c78?})
62: [0.09s] /usr/local/go/src/runtime/panic.go:914 +0x21f
62: [0.09s] main.(*Trie).Insert(0xc00008b020?, {0xc0001a2b90, 0x4e, 0x50}, {0x1b18a8e, 0x3, 0x3})
62: [0.09s] /app/cmd/shim/secret_scrub.go:230 +0x351
62: [0.09s] main.NewSecretScrubReader({0x13307a0?, 0xc000126938}, {0x1329160, 0x1}, {0x1330820, 0xc0005a2780}, {0xc0003a28c0?, 0x2?, 0x2?}, {{0xc0005b7500, ...}, ...})
62: [0.09s] /app/cmd/shim/secret_scrub.go:39 +0x345
62: [0.09s] main.shim()
62: [0.09s] /app/cmd/shim/main.go:259 +0xc52
62: [0.09s] main.main()
62: [0.09s] /app/cmd/shim/main.go:76 +0x74
62: [0.09s]
```
[Relevant line of code](https://github.com/sipsma/dagger/blob/d71867c127f6970113221c57fc03d2c8084b6c0a/cmd/shim/secret_scrub.go#L230-L230)
Not 100% sure but suspect I may have somehow set a secret value to `""`? That seems like a plausible explanation, but haven't looked at this in depth.
cc @jedevc | https://github.com/dagger/dagger/issues/6630 | https://github.com/dagger/dagger/pull/6641 | 794e3b3d298c7ca77dfedf5bf3d98d143ed05095 | 0c0de6b23b0151a9d1debfa8cbc879fd30391ab5 | 2024-02-08T23:51:48Z | go | 2024-02-12T14:41:35Z | cmd/shim/secret_scrub_test.go | trie := Trie{}
trie.Insert([]byte("foo"), []byte("bar"))
require.Equal(t, []byte("bar"), trie.Step('f').Step('o').Step('o').Value())
require.Nil(t, trie.Step('f').Step('o').Value())
trie.Insert([]byte("fox"), []byte("bax"))
require.Equal(t, []byte("bar"), trie.Step('f').Step('o').Step('o').Value())
require.Equal(t, []byte("bax"), trie.Step('f').Step('o').Step('x').Value())
trie.Insert([]byte("fax"), []byte("brx"))
require.Equal(t, []byte("bar"), trie.Step('f').Step('o').Step('o').Value())
require.Equal(t, []byte("bax"), trie.Step('f').Step('o').Step('x').Value())
require.Equal(t, []byte("brx"), trie.Step('f').Step('a').Step('x').Value())
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | cmd/codegen/generator/go/generator.go | package gogenerator
import (
"bytes"
"context"
"fmt"
"go/format"
"go/token"
"os"
"os/exec"
"path"
"path/filepath"
"text/template"
"github.com/dschmidt/go-layerfs"
"github.com/iancoleman/strcase"
"github.com/psanford/memfs"
"golang.org/x/mod/modfile"
"golang.org/x/tools/go/packages"
"golang.org/x/tools/imports"
"dagger.io/dagger"
"github.com/dagger/dagger/cmd/codegen/generator"
"github.com/dagger/dagger/cmd/codegen/generator/go/templates"
"github.com/dagger/dagger/cmd/codegen/introspection"
)
const (
ClientGenFile = "dagger.gen.go"
StarterTemplateFile = "main.go"
)
type GoGenerator struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | cmd/codegen/generator/go/generator.go | Config generator.Config
}
func (g *GoGenerator) Generate(ctx context.Context, schema *introspection.Schema) (*generator.GeneratedState, error) {
generator.SetSchema(schema)
mfs := memfs.New()
genSt := &generator.GeneratedState{
Overlay: layerfs.New(mfs, dagger.QueryBuilder),
PostCommands: []*exec.Cmd{
exec.Command("go", "mod", "tidy"),
},
}
pkgInfo, partial, err := g.bootstrapMod(ctx, mfs)
if err != nil { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | cmd/codegen/generator/go/generator.go | return nil, fmt.Errorf("bootstrap package: %w", err)
}
outDir := g.Config.OutputDir
initialGoFiles, err := filepath.Glob(filepath.Join(outDir, "*.go"))
if err != nil {
return nil, fmt.Errorf("glob go files: %w", err)
}
genFile := filepath.Join(outDir, ClientGenFile)
if _, err := os.Stat(genFile); err != nil {
pkgInfo.PackageName = "main"
baseCfg := g.Config
baseCfg.ModuleName = ""
if err := generateCode(ctx, baseCfg, schema, mfs, pkgInfo, nil, nil, 0); err != nil {
return nil, fmt.Errorf("generate code: %w", err)
}
partial = true
}
if len(initialGoFiles) == 0 {
if err := mfs.WriteFile(StarterTemplateFile, []byte(g.baseModuleSource()), 0600); err != nil {
return nil, err
}
partial = true
}
if partial {
genSt.NeedRegenerate = true
return genSt, nil |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | cmd/codegen/generator/go/generator.go | }
pkg, fset, err := loadPackage(ctx, outDir)
if err != nil {
return nil, fmt.Errorf("load package %q: %w", outDir, err)
}
pkgInfo.PackageName = pkg.Name
if err := generateCode(ctx, g.Config, schema, mfs, pkgInfo, pkg, fset, 1); err != nil {
return nil, fmt.Errorf("generate code: %w", err)
}
return genSt, nil
}
type PackageInfo struct {
PackageName string
PackageImport string
}
func (g *GoGenerator) bootstrapMod(ctx context.Context, mfs *memfs.FS) (*PackageInfo, bool, error) {
var needsRegen bool
outDir := g.Config.OutputDir
info := &PackageInfo{}
sdkMod, err := modfile.Parse("go.mod", dagger.GoMod, nil)
if err != nil {
return nil, false, fmt.Errorf("parse embedded go.mod: %w", err)
}
newMod := new(modfile.File)
if content, err := os.ReadFile(filepath.Join(outDir, "go.mod")); err == nil {
currentMod, err := modfile.Parse("go.mod", content, nil)
if err != nil { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | cmd/codegen/generator/go/generator.go | return nil, false, fmt.Errorf("parse go.mod: %w", err)
}
newMod = currentMod
for _, req := range sdkMod.Require {
newMod.AddRequire(req.Mod.Path, req.Mod.Version)
}
info.PackageImport = currentMod.Module.Mod.Path
} else {
if g.Config.ModuleName != "" {
outDir, err := filepath.Abs(outDir)
if err != nil {
return nil, false, fmt.Errorf("get absolute path: %w", err)
}
rootDir := g.Config.ModuleContextPath
subdirRelPath, err := filepath.Rel(rootDir, outDir)
if err != nil {
return nil, false, fmt.Errorf("failed to get output dir rel path: %w", err)
}
if pkg, _, err := loadPackage(ctx, rootDir); err == nil {
return &PackageInfo{
PackageImport: path.Join(pkg.Module.Path, subdirRelPath),
}, false, nil
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | cmd/codegen/generator/go/generator.go | newModName := "main"
newMod.AddModuleStmt(newModName)
newMod.SetRequire(sdkMod.Require)
info.PackageImport = newModName
needsRegen = true
} else {
if pkg, _, err := loadPackage(ctx, outDir); err == nil {
return &PackageInfo{
PackageName: pkg.Name,
PackageImport: pkg.Module.Path,
}, false, nil
}
return nil, false, fmt.Errorf("no module name configured and no existing package found")
}
}
modBody, err := newMod.Format()
if err != nil {
return nil, false, fmt.Errorf("format go.mod: %w", err)
}
if err := mfs.WriteFile("go.mod", modBody, 0600); err != nil {
return nil, false, err
}
if err := mfs.WriteFile("go.sum", dagger.GoSum, 0600); err != nil {
return nil, false, err
}
return info, needsRegen, nil
}
func generateCode( |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | cmd/codegen/generator/go/generator.go | ctx context.Context,
cfg generator.Config,
schema *introspection.Schema,
mfs *memfs.FS,
pkgInfo *PackageInfo,
pkg *packages.Package,
fset *token.FileSet,
pass int,
) error {
funcs := templates.GoTemplateFuncs(ctx, schema, cfg.ModuleName, pkg, fset, pass)
tmpls := templates.Templates(funcs)
for k, tmpl := range tmpls {
dt, err := renderFile(ctx, cfg, schema, pkgInfo, tmpl)
if err != nil {
return err
}
if dt == nil {
continue
}
if err := mfs.MkdirAll(filepath.Dir(k), 0o755); err != nil {
return err
}
if err := mfs.WriteFile(k, dt, 0600); err != nil {
return err
}
}
return nil
}
func renderFile( |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | cmd/codegen/generator/go/generator.go | ctx context.Context,
cfg generator.Config,
schema *introspection.Schema,
pkgInfo *PackageInfo,
tmpl *template.Template,
) ([]byte, error) {
data := struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | cmd/codegen/generator/go/generator.go | *PackageInfo
Schema *introspection.Schema
Types []*introspection.Type
}{
PackageInfo: pkgInfo,
Schema: schema,
Types: schema.Visit(),
}
var render bytes.Buffer
if err := tmpl.Execute(&render, data); err != nil {
return nil, err
}
source := render.Bytes()
source = bytes.TrimSpace(source)
if len(source) == 0 {
return nil, nil
}
formatted, err := format.Source(source)
if err != nil {
return nil, fmt.Errorf("error formatting generated code: %T %+v %w\nsource:\n%s", err, err, err, string(source))
}
formatted, err = imports.Process(filepath.Join(cfg.OutputDir, "dummy.go"), formatted, nil)
if err != nil {
return nil, fmt.Errorf("error formatting generated code: %T %+v %w\nsource:\n%s", err, err, err, string(source))
}
return formatted, nil
}
func loadPackage(ctx context.Context, dir string) (*packages.Package, *token.FileSet, error) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | cmd/codegen/generator/go/generator.go | fset := token.NewFileSet()
pkgs, err := packages.Load(&packages.Config{
Context: ctx,
Dir: dir,
Tests: false,
Fset: fset,
Mode: packages.NeedName |
packages.NeedTypes |
packages.NeedSyntax |
packages.NeedTypesInfo |
packages.NeedModule,
}, ".")
if err != nil {
return nil, nil, err
}
switch len(pkgs) {
case 0:
return nil, nil, fmt.Errorf("no packages found in %s", dir)
case 1:
if pkgs[0].Name == "" {
return nil, nil, fmt.Errorf("package name is empty") |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | cmd/codegen/generator/go/generator.go | }
return pkgs[0], fset, nil
default:
return nil, nil, fmt.Errorf("expected 1 package, got %d", len(pkgs))
}
}
func (g *GoGenerator) baseModuleSource() string {
moduleStructName := strcase.ToCamel(g.Config.ModuleName)
return fmt.Sprintf(`package main
import (
"context"
)
type %s struct {}
example usage: "dagger call container-echo --string-arg yo stdout"
func (m *%s) ContainerEcho(stringArg string) *Container {
return dag.Container().From("alpine:latest").WithExec([]string{"echo", stringArg})
}
example usage: "dagger call grep-dir --directory-arg . --pattern GrepDir"
func (m *%s) GrepDir(ctx context.Context, directoryArg *Directory, pattern string) (string, error) {
return dag.Container().
From("alpine:latest").
WithMountedDirectory("/mnt", directoryArg).
WithWorkdir("/mnt").
WithExec([]string{"grep", "-R", pattern, "."}).
Stdout(ctx)
}
`, moduleStructName, moduleStructName, moduleStructName)
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | package core
import (
"context"
_ "embed"
"encoding/json"
"fmt"
"go/format"
"os"
"os/exec"
"path/filepath"
"strings"
"testing"
"time"
"github.com/MakeNowJust/heredoc/v2"
"github.com/dagger/dagger/core/modules"
"github.com/dagger/dagger/dagql/idproto"
"github.com/iancoleman/strcase"
"github.com/moby/buildkit/identity"
"github.com/stretchr/testify/require"
"github.com/tidwall/gjson"
"golang.org/x/sync/errgroup"
"dagger.io/dagger"
"github.com/dagger/dagger/cmd/codegen/introspection"
)
func TestModuleGoInit(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | t.Parallel()
t.Run("from scratch", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=bare", "--sdk=go"))
out, err := modGen.
With(daggerQuery(`{bare{containerEcho(stringArg:"hello"){stdout}}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"bare":{"containerEcho":{"stdout":"hello\n"}}}`, out)
})
t.Run("reserved go.mod name", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=go", "--sdk=go"))
out, err := modGen.
With(daggerQuery(`{go{containerEcho(stringArg:"hello"){stdout}}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"go":{"containerEcho":{"stdout":"hello\n"}}}`, out)
})
t.Run("uses expected Go module name, camel-cases Dagger module name", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=My-Module", "--sdk=go"))
out, err := modGen.
With(daggerQuery(`{myModule{containerEcho(stringArg:"hello"){stdout}}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"myModule":{"containerEcho":{"stdout":"hello\n"}}}`, out)
generated, err := modGen.File("go.mod").Contents(ctx)
require.NoError(t, err)
require.Contains(t, generated, "module main")
})
t.Run("creates go.mod beneath an existing go.mod if context is beneath it", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
WithNewFile("/work/go.mod", dagger.ContainerWithNewFileOpts{
Contents: "module example.com/test\n",
}).
WithNewFile("/work/foo.go", dagger.ContainerWithNewFileOpts{
Contents: "package foo\n",
}).
WithWorkdir("/work/ci").
With(daggerExec("init", "--name=beneathGoMod", "--sdk=go"))
out, err := modGen.
With(daggerQuery(`{beneathGoMod{containerEcho(stringArg:"hello"){stdout}}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"beneathGoMod":{"containerEcho":{"stdout":"hello\n"}}}`, out)
t.Run("names Go module after Dagger module", func(t *testing.T) {
generated, err := modGen.Directory("dagger").File("go.mod").Contents(ctx)
require.NoError(t, err)
require.Contains(t, generated, "module main")
})
})
t.Run("respects existing go.mod", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
WithExec([]string{"go", "mod", "init", "example.com/test"}).
With(daggerExec("init", "--name=hasGoMod", "--sdk=go")) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | out, err := modGen.
With(daggerQuery(`{hasGoMod{containerEcho(stringArg:"hello"){stdout}}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"hasGoMod":{"containerEcho":{"stdout":"hello\n"}}}`, out)
t.Run("preserves module name", func(t *testing.T) {
generated, err := modGen.File("go.mod").Contents(ctx)
require.NoError(t, err)
require.Contains(t, generated, "module example.com/test")
})
})
t.Run("respects parent go.mod if root points to it", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
generated := goGitBase(t, c).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
WithExec([]string{"go", "mod", "init", "example.com/test"}).
WithNewFile("/work/foo.go", dagger.ContainerWithNewFileOpts{
Contents: "package foo\n",
}).
With(daggerExec("init", "--name=child", "--sdk=go", "./child")).
WithWorkdir("/work/child").
With(daggerExec("develop")).
Directory("/work")
parentEntries, err := generated.Entries(ctx)
require.NoError(t, err)
require.Equal(t, []string{".git", "child", "foo.go", "go.mod", "go.sum"}, parentEntries)
childEntries, err := generated.Directory("child").Entries(ctx) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | require.NoError(t, err)
require.NotContains(t, childEntries, "go.mod")
t.Run("preserves parent module name", func(t *testing.T) {
goMod, err := generated.File("go.mod").Contents(ctx)
require.NoError(t, err)
require.Contains(t, goMod, "module example.com/test")
})
})
t.Run("respects existing go.mod even if root points to parent that has go.mod", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
generated := goGitBase(t, c).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
WithExec([]string{"git", "init"}).
WithExec([]string{"go", "mod", "init", "example.com/test"}).
WithNewFile("/work/foo.go", dagger.ContainerWithNewFileOpts{
Contents: "package foo\n",
}).
WithWorkdir("/work/child").
WithExec([]string{"go", "mod", "init", "my-mod"}).
WithWorkdir("/work").
With(daggerExec("init", "--source=./child", "--name=child", "--sdk=go", "./child")).
WithWorkdir("/work/child").
With(daggerExec("develop")).
Directory("/work")
parentEntries, err := generated.Entries(ctx)
require.NoError(t, err) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | require.Equal(t, []string{".git", "child", "foo.go", "go.mod"}, parentEntries)
childEntries, err := generated.Directory("child").Entries(ctx)
require.NoError(t, err)
require.Contains(t, childEntries, "go.mod")
require.Contains(t, childEntries, "go.sum")
})
t.Run("respects existing main.go", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
WithNewFile("/work/main.go", dagger.ContainerWithNewFileOpts{
Contents: `
package main
type HasMainGo struct {}
func (m *HasMainGo) Hello() string { return "Hello, world!" }
`,
}).
With(daggerExec("init", "--name=hasMainGo", "--sdk=go", "--source=."))
out, err := modGen.
With(daggerQuery(`{hasMainGo{hello}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"hasMainGo":{"hello":"Hello, world!"}}`, out)
})
t.Run("respects existing main.go even if it uses types not generated yet", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage). |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
WithNewFile("/work/main.go", dagger.ContainerWithNewFileOpts{
Contents: `
package main
type HasDaggerTypes struct {}
func (m *HasDaggerTypes) Hello() *Container {
return dag.Container().
From("` + alpineImage + `").
WithExec([]string{"echo", "Hello, world!"})
}
`,
}).
With(daggerExec("init", "--source=.", "--name=hasDaggerTypes", "--sdk=go"))
out, err := modGen.
With(daggerQuery(`{hasDaggerTypes{hello{stdout}}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"hasDaggerTypes":{"hello":{"stdout":"Hello, world!\n"}}}`, out)
})
t.Run("respects existing package without creating main.go", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
WithNewFile("/work/notmain.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
type HasNotMainGo struct {}
func (m *HasNotMainGo) Hello() string { return "Hello, world!" } |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | `,
}).
With(daggerExec("init", "--source=.", "--name=hasNotMainGo", "--sdk=go"))
out, err := modGen.
With(daggerQuery(`{hasNotMainGo{hello}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"hasNotMainGo":{"hello":"Hello, world!"}}`, out)
})
t.Run("with source", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=bare", "--sdk=go", "--source=some/subdir"))
out, err := modGen.
With(daggerQuery(`{bare{containerEcho(stringArg:"hello"){stdout}}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"bare":{"containerEcho":{"stdout":"hello\n"}}}`, out)
sourceSubdirEnts, err := modGen.Directory("/work/some/subdir").Entries(ctx)
require.NoError(t, err)
require.Contains(t, sourceSubdirEnts, "main.go")
sourceRootEnts, err := modGen.Directory("/work").Entries(ctx)
require.NoError(t, err)
require.NotContains(t, sourceRootEnts, "main.go")
})
}
func TestModuleInitLICENSE(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | t.Run("bootstraps Apache-2.0 LICENSE file if none found", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=licensed-to-ill", "--sdk=go"))
content, err := modGen.File("LICENSE").Contents(ctx)
require.NoError(t, err)
require.Contains(t, content, "Apache License, Version 2.0")
})
t.Run("creates LICENSE file in the directory specified by arg", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=licensed-to-ill", "--sdk=go", "./mymod"))
content, err := modGen.File("mymod/LICENSE").Contents(ctx)
require.NoError(t, err)
require.Contains(t, content, "Apache License, Version 2.0")
})
t.Run("does not bootstrap LICENSE file if it exists in the parent dir", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
WithNewFile("/work/LICENSE", dagger.ContainerWithNewFileOpts{
Contents: "doesnt matter",
}).
WithWorkdir("/work/sub").
With(daggerExec("init", "--name=licensed-to-ill", "--sdk=go"))
_, err := modGen.File("LICENSE").Contents(ctx)
require.Error(t, err)
})
t.Run("bootstraps a LICENSE file when requested, even if it exists in the parent dir", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
WithNewFile("/work/LICENSE", dagger.ContainerWithNewFileOpts{
Contents: "doesnt matter",
}).
WithWorkdir("/work/sub").
With(daggerExec("init", "--name=licensed-to-ill", "--sdk=go", "--license=MIT"))
content, err := modGen.File("LICENSE").Contents(ctx)
require.NoError(t, err)
require.Contains(t, content, "MIT License")
})
}
func TestModuleGit(t *testing.T) {
t.Parallel()
type testCase struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | sdk string
gitGeneratedFiles []string
gitIgnoredFiles []string
}
for _, tc := range []testCase{
{
sdk: "go",
gitGeneratedFiles: []string{
"/dagger.gen.go",
"/querybuilder/**",
},
},
{
sdk: "python",
gitGeneratedFiles: []string{
"/sdk/**",
},
gitIgnoredFiles: []string{ |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | "/sdk",
},
},
{
sdk: "typescript",
gitGeneratedFiles: []string{
"/sdk/**",
},
gitIgnoredFiles: []string{
"/sdk",
},
},
} {
tc := tc
t.Run(fmt.Sprintf("module %s git", tc.sdk), func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := goGitBase(t, c).
With(daggerExec("init", "--name=bare", "--sdk="+tc.sdk))
out, err := modGen.
With(daggerQuery(`{bare{containerEcho(stringArg:"hello"){stdout}}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"bare":{"containerEcho":{"stdout":"hello\n"}}}`, out)
t.Run("configures .gitattributes", func(t *testing.T) {
ignore, err := modGen.File(".gitattributes").Contents(ctx)
require.NoError(t, err)
for _, fileName := range tc.gitGeneratedFiles {
require.Contains(t, ignore, fmt.Sprintf("%s linguist-generated\n", fileName))
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | })
if len(tc.gitIgnoredFiles) > 0 {
t.Run("configures .gitignore", func(t *testing.T) {
ignore, err := modGen.File(".gitignore").Contents(ctx)
require.NoError(t, err)
for _, fileName := range tc.gitIgnoredFiles {
require.Contains(t, ignore, fileName)
}
})
}
})
}
}
var goSignatures string
func TestModuleGoSignatures(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=minimal", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: goSignatures,
})
t.Run("func Hello() string", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{hello}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"hello":"hello"}}`, out)
})
t.Run("func Echo(string) string", func(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | out, err := modGen.With(daggerQuery(`{minimal{echo(msg: "hello")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echo":"hello...hello...hello..."}}`, out)
})
t.Run("func EchoPointer(*string) string", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{echoPointer(msg: "hello")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoPointer":"hello...hello...hello..."}}`, out)
})
t.Run("func EchoPointerPointer(**string) string", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{echoPointerPointer(msg: "hello")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoPointerPointer":"hello...hello...hello..."}}`, out)
})
t.Run("func EchoOptional(string) string", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{echoOptional(msg: "hello")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptional":"hello...hello...hello..."}}`, out)
out, err = modGen.With(daggerQuery(`{minimal{echoOptional}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptional":"default...default...default..."}}`, out)
})
t.Run("func EchoOptionalPointer(string) string", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{echoOptionalPointer(msg: "hello")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptionalPointer":"hello...hello...hello..."}}`, out)
out, err = modGen.With(daggerQuery(`{minimal{echoOptionalPointer}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptionalPointer":"default...default...default..."}}`, out)
}) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | t.Run("func EchoOptionalSlice([]string) string", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{echoOptionalSlice(msg: ["hello", "there"])}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptionalSlice":"hello+there...hello+there...hello+there..."}}`, out)
out, err = modGen.With(daggerQuery(`{minimal{echoOptionalSlice}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptionalSlice":"foobar...foobar...foobar..."}}`, out)
})
t.Run("func Echoes([]string) []string", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{echoes(msgs: ["hello"])}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoes":["hello...hello...hello..."]}}`, out)
})
t.Run("func EchoesVariadic(...string) string", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{echoesVariadic(msgs: ["hello"])}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoesVariadic":"hello...hello...hello..."}}`, out)
})
t.Run("func HelloContext(context.Context) string", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{helloContext}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"helloContext":"hello context"}}`, out)
})
t.Run("func EchoContext(context.Context, string) string", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{echoContext(msg: "hello")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoContext":"ctx.hello...ctx.hello...ctx.hello..."}}`, out)
})
t.Run("func HelloStringError() (string, error)", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{helloStringError}}`)).Stdout(ctx) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"helloStringError":"hello i worked"}}`, out)
})
t.Run("func HelloVoid()", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{helloVoid}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"helloVoid":null}}`, out)
})
t.Run("func HelloVoidError() error", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{helloVoidError}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"helloVoidError":null}}`, out)
})
t.Run("func EchoOpts(string, string, int) error", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{echoOpts(msg: "hi")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOpts":"hi"}}`, out)
out, err = modGen.With(daggerQuery(`{minimal{echoOpts(msg: "hi", suffix: "!", times: 2)}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOpts":"hi!hi!"}}`, out)
})
t.Run("func EchoOptsInline(struct{string, string, int}) error", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{echoOptsInline(msg: "hi")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptsInline":"hi"}}`, out)
out, err = modGen.With(daggerQuery(`{minimal{echoOptsInline(msg: "hi", suffix: "!", times: 2)}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptsInline":"hi!hi!"}}`, out)
})
t.Run("func EchoOptsInlinePointer(*struct{string, string, int}) error", func(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | out, err := modGen.With(daggerQuery(`{minimal{echoOptsInlinePointer(msg: "hi")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptsInlinePointer":"hi"}}`, out)
out, err = modGen.With(daggerQuery(`{minimal{echoOptsInlinePointer(msg: "hi", suffix: "!", times: 2)}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptsInlinePointer":"hi!hi!"}}`, out)
})
t.Run("func EchoOptsInlineCtx(ctx, struct{string, string, int}) error", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{echoOptsInlineCtx(msg: "hi")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptsInlineCtx":"hi"}}`, out)
out, err = modGen.With(daggerQuery(`{minimal{echoOptsInlineCtx(msg: "hi", suffix: "!", times: 2)}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptsInlineCtx":"hi!hi!"}}`, out)
})
t.Run("func EchoOptsInlineTags(struct{string, string, int}) error", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{echoOptsInlineTags(msg: "hi")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptsInlineTags":"hi"}}`, out)
out, err = modGen.With(daggerQuery(`{minimal{echoOptsInlineTags(msg: "hi", suffix: "!", times: 2)}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptsInlineTags":"hi!hi!"}}`, out)
})
t.Run("func EchoOptsPragmas(string, string, int) error", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{echoOptsPragmas(msg: "hi")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptsPragmas":"hi...hi...hi..."}}`, out)
})
}
func TestModuleGoSignaturesBuiltinTypes(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=minimal", "--sdk=go")).
WithNewFile("dagger/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
type Minimal struct {}
func (m *Minimal) Read(ctx context.Context, dir Directory) (string, error) {
return dir.File("foo").Contents(ctx)
}
func (m *Minimal) ReadPointer(ctx context.Context, dir *Directory) (string, error) {
return dir.File("foo").Contents(ctx)
}
func (m *Minimal) ReadSlice(ctx context.Context, dir []Directory) (string, error) {
return dir[0].File("foo").Contents(ctx)
}
func (m *Minimal) ReadVariadic(ctx context.Context, dir ...Directory) (string, error) {
return dir[0].File("foo").Contents(ctx)
}
func (m *Minimal) ReadOptional(
ctx context.Context, |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | dir *Directory, // +optional
) (string, error) {
if dir != nil {
return dir.File("foo").Contents(ctx)
}
return "", nil
}
`,
})
out, err := modGen.With(daggerQuery(`{directory{withNewFile(path: "foo", contents: "bar"){id}}}`)).Stdout(ctx)
require.NoError(t, err)
dirID := gjson.Get(out, "directory.withNewFile.id").String()
t.Run("func Read(ctx, Directory) (string, error)", func(t *testing.T) {
out, err := modGen.With(daggerQuery(fmt.Sprintf(`{minimal{read(dir: "%s")}}`, dirID))).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"read":"bar"}}`, out)
})
t.Run("func ReadPointer(ctx, *Directory) (string, error)", func(t *testing.T) {
out, err := modGen.With(daggerQuery(fmt.Sprintf(`{minimal{readPointer(dir: "%s")}}`, dirID))).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"readPointer":"bar"}}`, out)
})
t.Run("func ReadSlice(ctx, []Directory) (string, error)", func(t *testing.T) {
out, err := modGen.With(daggerQuery(fmt.Sprintf(`{minimal{readSlice(dir: ["%s"])}}`, dirID))).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"readSlice":"bar"}}`, out)
})
t.Run("func ReadVariadic(ctx, ...Directory) (string, error)", func(t *testing.T) {
out, err := modGen.With(daggerQuery(fmt.Sprintf(`{minimal{readVariadic(dir: ["%s"])}}`, dirID))).Stdout(ctx)
require.NoError(t, err) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | require.JSONEq(t, `{"minimal":{"readVariadic":"bar"}}`, out)
})
t.Run("func ReadOptional(ctx, Optional[Directory]) (string, error)", func(t *testing.T) {
out, err := modGen.With(daggerQuery(fmt.Sprintf(`{minimal{readOptional(dir: "%s")}}`, dirID))).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"readOptional":"bar"}}`, out)
out, err = modGen.With(daggerQuery(`{minimal{readOptional}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"readOptional":""}}`, out)
})
}
func TestModuleGoSignaturesUnexported(t *testing.T) {
t.Parallel()
var logs safeBuffer
c, ctx := connect(t, dagger.WithLogOutput(&logs))
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=minimal", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
type Minimal struct {}
type Foo struct {}
type bar struct {}
func (m *Minimal) Hello(name string) string {
return name
}
func (f *Foo) Hello(name string) string {
return name
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | func (b *bar) Hello(name string) string {
return name
}
`,
})
objs := inspectModuleObjects(ctx, t, modGen)
require.Equal(t, 1, len(objs.Array()))
require.Equal(t, "Minimal", objs.Get("0.name").String())
modGen = c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=minimal", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
type Minimal struct {}
type Foo struct {}
type bar struct {}
func (m *Minimal) Hello(name string) Foo {
return Foo{}
}
func (f *Foo) Hello(name string) string {
return name
}
func (b *bar) Hello(name string) string {
return name
}
`,
})
objs = inspectModuleObjects(ctx, t, modGen)
require.Equal(t, 2, len(objs.Array())) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | require.Equal(t, "Minimal", objs.Get("0.name").String())
require.Equal(t, "MinimalFoo", objs.Get("1.name").String())
modGen = c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=minimal", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
type Minimal struct {}
type Foo struct {
Bar bar
}
type bar struct {}
func (m *Minimal) Hello(name string) Foo {
return Foo{}
}
func (f *Foo) Hello(name string) string {
return name
}
func (b *bar) Hello(name string) string {
return name
}
`,
})
_, err := modGen.With(moduleIntrospection).Stderr(ctx)
require.Error(t, err)
require.NoError(t, c.Close())
require.Contains(t, logs.String(), "cannot code-generate unexported type bar")
}
func TestModuleGoSignaturesMixMatch(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | t.Parallel()
var logs safeBuffer
c, ctx := connect(t, dagger.WithLogOutput(&logs))
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=minimal", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
type Minimal struct {}
func (m *Minimal) Hello(name string, opts struct{}, opts2 struct{}) string {
return name
}
`,
})
_, err := modGen.With(daggerQuery(`{minimal{hello}}`)).Stdout(ctx)
require.Error(t, err)
require.NoError(t, c.Close())
require.Contains(t, logs.String(), "nested structs are not supported")
}
func TestModuleGoSignaturesNameConflict(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | t.Parallel()
var logs safeBuffer
c, ctx := connect(t, dagger.WithLogOutput(&logs))
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=minimal", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
type Minimal struct {
Foo Foo
Bar Bar
Baz Baz
}
type Foo struct {}
type Bar struct {}
type Baz struct {}
func (m *Foo) Hello(name string) string {
return name
}
func (f *Bar) Hello(name string, name2 string) string {
return name + name2
}
func (b *Baz) Hello() (string, error) {
return "", nil
}
`,
}) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | objs := inspectModuleObjects(ctx, t, modGen)
require.Equal(t, 4, len(objs.Array()))
require.Equal(t, "Minimal", objs.Get("0.name").String())
require.Equal(t, "MinimalFoo", objs.Get("1.name").String())
require.Equal(t, "MinimalBar", objs.Get("2.name").String())
require.Equal(t, "MinimalBaz", objs.Get("3.name").String())
}
func TestModuleGoDocs(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=minimal", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: goSignatures,
})
logGen(ctx, t, modGen.Directory("."))
obj := inspectModuleObjects(ctx, t, modGen).Get("0")
require.Equal(t, "Minimal", obj.Get("name").String())
hello := obj.Get(`functions.#(name="hello")`)
require.Equal(t, "hello", hello.Get("name").String())
require.Empty(t, hello.Get("description").String())
require.Empty(t, hello.Get("args").Array())
echoOpts := obj.Get(`functions.#(name="echoOpts")`)
require.Equal(t, "echoOpts", echoOpts.Get("name").String())
require.Equal(t, "EchoOpts does some opts things", echoOpts.Get("description").String())
require.Len(t, echoOpts.Get("args").Array(), 3)
require.Equal(t, "msg", echoOpts.Get("args.0.name").String()) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | require.Equal(t, "the message to echo", echoOpts.Get("args.0.description").String())
require.Equal(t, "suffix", echoOpts.Get("args.1.name").String())
require.Equal(t, "String to append to the echoed message", echoOpts.Get("args.1.description").String())
require.Equal(t, "times", echoOpts.Get("args.2.name").String())
require.Equal(t, "Number of times to repeat the message", echoOpts.Get("args.2.description").String())
echoOpts = obj.Get(`functions.#(name="echoOptsInline")`)
require.Equal(t, "echoOptsInline", echoOpts.Get("name").String())
require.Equal(t, "EchoOptsInline does some opts things", echoOpts.Get("description").String())
require.Len(t, echoOpts.Get("args").Array(), 3)
require.Equal(t, "msg", echoOpts.Get("args.0.name").String())
require.Equal(t, "the message to echo", echoOpts.Get("args.0.description").String())
require.Equal(t, "suffix", echoOpts.Get("args.1.name").String())
require.Equal(t, "String to append to the echoed message", echoOpts.Get("args.1.description").String())
require.Equal(t, "times", echoOpts.Get("args.2.name").String())
require.Equal(t, "Number of times to repeat the message", echoOpts.Get("args.2.description").String())
echoOpts = obj.Get(`functions.#(name="echoOptsPragmas")`)
require.Equal(t, "echoOptsPragmas", echoOpts.Get("name").String())
require.Len(t, echoOpts.Get("args").Array(), 3)
require.Equal(t, "msg", echoOpts.Get("args.0.name").String())
require.Equal(t, "", echoOpts.Get("args.0.defaultValue").String())
require.Equal(t, "suffix", echoOpts.Get("args.1.name").String())
require.Equal(t, "String to append to the echoed message", echoOpts.Get("args.1.description").String())
require.Equal(t, "\"...\"", echoOpts.Get("args.1.defaultValue").String())
require.Equal(t, "times", echoOpts.Get("args.2.name").String())
require.Equal(t, "3", echoOpts.Get("args.2.defaultValue").String())
require.Equal(t, "Number of times to repeat the message", echoOpts.Get("args.2.description").String())
}
func TestModuleGoDocsEdgeCases(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=minimal", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
// Minimal is a thing
type Minimal struct {
// X is this
X, Y string // Y is not this
// +private
Z string
}
// some docs
func (m *Minimal) Hello(foo string, bar string,
// hello
baz string, qux string, x string, // lol
) string {
return foo + bar
}
func (m *Minimal) HelloMore(
// foo here
foo,
// bar here
bar string,
) string {
return foo + bar
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | func (m *Minimal) HelloMoreInline(opts struct{
// foo here
foo, bar string
}) string {
return opts.foo + opts.bar
}
func (m *Minimal) HelloAgain( // docs for helloagain
foo string,
bar string, // docs for bar
baz string,
) string {
return foo + bar
}
func (m *Minimal) HelloFinal(
foo string) string { // woops
return foo
}
`,
})
logGen(ctx, t, modGen.Directory("."))
obj := inspectModuleObjects(ctx, t, modGen).Get("0")
require.Equal(t, "Minimal", obj.Get("name").String())
require.Equal(t, "Minimal is a thing", obj.Get("description").String())
hello := obj.Get(`functions.#(name="hello")`)
require.Equal(t, "hello", hello.Get("name").String())
require.Len(t, hello.Get("args").Array(), 5)
require.Equal(t, "foo", hello.Get("args.0.name").String())
require.Equal(t, "", hello.Get("args.0.description").String())
require.Equal(t, "bar", hello.Get("args.1.name").String())
require.Equal(t, "", hello.Get("args.1.description").String()) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | require.Equal(t, "baz", hello.Get("args.2.name").String())
require.Equal(t, "hello", hello.Get("args.2.description").String())
require.Equal(t, "qux", hello.Get("args.3.name").String())
require.Equal(t, "", hello.Get("args.3.description").String())
require.Equal(t, "x", hello.Get("args.4.name").String())
require.Equal(t, "lol", hello.Get("args.4.description").String())
hello = obj.Get(`functions.#(name="helloMore")`)
require.Equal(t, "helloMore", hello.Get("name").String())
require.Len(t, hello.Get("args").Array(), 2)
require.Equal(t, "foo", hello.Get("args.0.name").String())
require.Equal(t, "foo here", hello.Get("args.0.description").String())
require.Equal(t, "bar", hello.Get("args.1.name").String())
require.Equal(t, "bar here", hello.Get("args.1.description").String())
hello = obj.Get(`functions.#(name="helloMoreInline")`)
require.Equal(t, "helloMoreInline", hello.Get("name").String())
require.Len(t, hello.Get("args").Array(), 2)
require.Equal(t, "foo", hello.Get("args.0.name").String())
require.Equal(t, "foo here", hello.Get("args.0.description").String())
require.Equal(t, "bar", hello.Get("args.1.name").String())
require.Equal(t, "", hello.Get("args.1.description").String())
hello = obj.Get(`functions.#(name="helloAgain")`)
require.Equal(t, "helloAgain", hello.Get("name").String())
require.Len(t, hello.Get("args").Array(), 3)
require.Equal(t, "foo", hello.Get("args.0.name").String())
require.Equal(t, "", hello.Get("args.0.description").String())
require.Equal(t, "bar", hello.Get("args.1.name").String())
require.Equal(t, "docs for bar", hello.Get("args.1.description").String())
require.Equal(t, "baz", hello.Get("args.2.name").String())
require.Equal(t, "", hello.Get("args.2.description").String())
hello = obj.Get(`functions.#(name="helloFinal")`) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | require.Equal(t, "helloFinal", hello.Get("name").String())
require.Len(t, hello.Get("args").Array(), 1)
require.Equal(t, "foo", hello.Get("args.0.name").String())
require.Equal(t, "", hello.Get("args.0.description").String())
require.Len(t, obj.Get(`fields`).Array(), 2)
prop := obj.Get(`fields.#(name="x")`)
require.Equal(t, "x", prop.Get("name").String())
require.Equal(t, "X is this", prop.Get("description").String())
prop = obj.Get(`fields.#(name="y")`)
require.Equal(t, "y", prop.Get("name").String())
require.Equal(t, "", prop.Get("description").String())
}
func TestModuleGoWeirdFields(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=minimal", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
type Z string
type Minimal struct {
// field with single (normal) name
W string
// field with multiple names
X, Y string
// field with no names
Z |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | }
func New() Minimal {
return Minimal{
W: "-",
X: "-",
Y: "-",
Z: Z("-"),
}
}
// struct with no fields
type Bar struct{}
func (m *Minimal) Say(
// field with single (normal) name
a string,
// field with multiple names
b, c string,
// field with no names (not included, mixed names not allowed)
// string
) string {
return a + " " + b + " " + c
}
func (m *Minimal) Hello(
// field with no names
string,
) string {
return "hello"
}
func (m *Minimal) SayOpts(opts struct{
// field with single (normal) name
A string |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | // field with multiple names
B, C string
// field with no names (not included because of above)
// string
}) string {
return opts.A + " " + opts.B + " " + opts.C
}
func (m *Minimal) HelloOpts(opts struct{
// field with no names
string
}) string {
return "hello"
}
`,
})
out, err := modGen.With(daggerQuery(`{minimal{w, x, y, z}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal": {"w": "-", "x": "-", "y": "-", "z": "-"}}`, out)
for _, name := range []string{"say", "sayOpts"} {
out, err := modGen.With(daggerQuery(`{minimal{%s(a: "hello", b: "world", c: "!")}}`, name)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, fmt.Sprintf(`{"minimal": {"%s": "hello world !"}}`, name), out)
}
for _, name := range []string{"hello", "helloOpts"} {
out, err := modGen.With(daggerQuery(`{minimal{%s(string: "")}}`, name)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, fmt.Sprintf(`{"minimal": {"%s": "hello"}}`, name), out)
}
}
func TestModuleGoFieldMustBeNil(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=minimal", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "fmt"
type Minimal struct {
Src *Directory
Name *string
}
func New() *Minimal {
return &Minimal{}
}
func (m *Minimal) IsEmpty() bool {
if m.Name != nil {
panic(fmt.Sprintf("name should be nil but is %v", m.Name))
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | if m.Src != nil {
panic(fmt.Sprintf("src should be nil but is %v", m.Src))
}
return true
}
`,
})
out, err := modGen.With(daggerQuery(`{minimal{isEmpty}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal": {"isEmpty": true}}`, out)
}
func TestModuleDescription(t *testing.T) {
t.Parallel()
type source struct {
file string
contents string
}
for _, tc := range []struct {
sdk string
sources []source
}{
{
sdk: "go",
sources: []source{
{
file: "main.go",
contents: `
// Test module, short description
//
// Long description, with full sentences. |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | package main
// Test object, short description
type Test struct {
// +default="foo"
Foo string
}
`,
},
},
},
{
sdk: "go",
sources: []source{
{
file: "a.go",
contents: `
// First, but not main
package main
type Foo struct {}
`,
},
{
file: "z.go",
contents: `
// Test module, short description
//
// Long description, with full sentences.
package main
// Test object, short description
type Test struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | }
func (*Test) Foo() Foo {
return Foo{}
}
`,
},
},
},
{
sdk: "python",
sources: []source{
{
file: "src/main.py",
contents: `
"""Test module, short description
Long description, with full sentences.
"""
from dagger import field, object_type
@object_type
class Test:
"""Test object, short description"""
foo: str = field(default="foo")
`,
},
},
},
{
sdk: "python",
sources: []source{
{ |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | file: "src/main/foo.py",
contents: `
"""Not the main file"""
from dagger import field, object_type
@object_type
class Foo:
bar: str = field(default="bar")
`,
},
{
file: "src/main/__init__.py",
contents: `
"""Test module, short description
Long description, with full sentences.
"""
from dagger import function, object_type
from .foo import Foo
@object_type
class Test:
"""Test object, short description"""
foo = function(Foo)
`,
},
},
},
{
sdk: "typescript",
sources: []source{
{
file: "src/index.ts", |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | contents: `
/**
* Test module, short description
*
* Long description, with full sentences.
*/
import { object, field } from '@dagger.io/dagger'
/**
* Test object, short description
*/
@object()
class Test {
@field()
foo: string = "foo"
}
`,
},
},
},
{
sdk: "typescript",
sources: []source{
{
file: "src/foo.ts",
contents: `
/**
* Not the main file
*/
import { object, field } from '@dagger.io/dagger'
@object() |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | export class Foo {
@field()
bar = "bar"
}
`,
},
{
file: "src/index.ts",
contents: `
/**
* Test module, short description
*
* Long description, with full sentences.
*/
import { object, field } from '@dagger.io/dagger'
import { Foo } from "./foo"
/**
* Test object, short description
*/
@object()
class Test {
@func()
foo(): Foo {
return new Foo()
}
}
`,
},
},
}, |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | } {
tc := tc
t.Run(fmt.Sprintf("%s with %d files", tc.sdk, len(tc.sources)), func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work")
for _, src := range tc.sources {
src := src
modGen = modGen.WithNewFile(src.file, dagger.ContainerWithNewFileOpts{
Contents: heredoc.Doc(src.contents),
})
}
mod := inspectModule(ctx, t,
modGen.With(daggerExec("init", "--source=.", "--name=test", "--sdk="+tc.sdk)))
require.Equal(t,
"Test module, short description\n\nLong description, with full sentences.",
mod.Get("description").String(),
)
require.Equal(t,
"Test object, short description",
mod.Get("objects.#.asObject|#(name=Test).description").String(),
)
})
}
}
func TestModulePrivateField(t *testing.T) {
t.Parallel()
for _, tc := range []struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | sdk string
source string
}{
{
sdk: "go",
source: `package main
type Minimal struct {
Foo string
Bar string // +private
}
func (m *Minimal) Set(foo string, bar string) *Minimal {
m.Foo = foo
m.Bar = bar
return m
}
func (m *Minimal) Hello() string {
return m.Foo + m.Bar
}
`,
},
{
sdk: "python",
source: `from dagger import field, function, object_type
@object_type
class Minimal:
foo: str = field(default="")
bar: str = ""
@function
def set(self, foo: str, bar: str) -> "Minimal":
self.foo = foo |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | self.bar = bar
return self
@function
def hello(self) -> str:
return self.foo + self.bar
`,
},
{
sdk: "typescript",
source: `
import { object, func, field } from "@dagger.io/dagger"
@object()
class Minimal {
@field()
foo: string
bar?: string
constructor(foo?: string, bar?: string) {
this.foo = foo
this.bar = bar
}
@func()
set(foo: string, bar: string): Minimal {
this.foo = foo
this.bar = bar
return this
}
@func()
hello(): string {
return this.foo + this.bar
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | }
`,
},
} {
tc := tc
t.Run(tc.sdk, func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=minimal", "--sdk="+tc.sdk)).
With(sdkSource(tc.sdk, tc.source))
obj := inspectModuleObjects(ctx, t, modGen).Get("0")
require.Equal(t, "Minimal", obj.Get("name").String())
require.Len(t, obj.Get(`fields`).Array(), 1)
prop := obj.Get(`fields.#(name="foo")`)
require.Equal(t, "foo", prop.Get("name").String())
out, err := modGen.With(daggerQuery(`{minimal{set(foo: "abc", bar: "xyz"){hello}}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"set":{"hello": "abcxyz"}}}`, out)
out, err = modGen.With(daggerQuery(`{minimal{set(foo: "abc", bar: "xyz"){foo}}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"set":{"foo": "abc"}}}`, out)
_, err = modGen.With(daggerQuery(`{minimal{set(foo: "abc", bar: "xyz"){bar}}}`)).Stdout(ctx)
require.ErrorContains(t, err, `Minimal has no such field: "bar"`)
})
}
}
func TestModuleGoExtendCore(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | t.Parallel()
var logs safeBuffer
c, ctx := connect(t, dagger.WithLogOutput(&logs))
_, err := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=container", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
func (c *Container) Echo(ctx context.Context, msg string) (string, error) {
return c.WithExec([]string{"echo", msg}).Stdout(ctx)
}
`,
}).
With(daggerQuery(`{container{from(address:"` + alpineImage + `"){echo(msg:"echo!"){stdout}}}}`)).
Sync(ctx)
require.Error(t, err)
require.NoError(t, c.Close())
t.Log(logs.String())
require.Contains(t, logs.String(), "cannot define methods on objects from outside this module")
}
func TestModuleGoBadCtx(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | t.Parallel()
var logs safeBuffer
c, ctx := connect(t, dagger.WithLogOutput(&logs))
_, err := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--source=.", "--name=foo", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
type Foo struct {}
func (f *Foo) Echo(ctx context.Context, ctx2 context.Context) (string, error) {
return "", nil
}
`,
}).
With(daggerQuery(`{foo{echo}}`)).
Sync(ctx)
require.Error(t, err)
require.NoError(t, c.Close())
t.Log(logs.String())
require.Contains(t, logs.String(), "unexpected context type")
}
func TestModuleCustomTypes(t *testing.T) {
t.Parallel()
type testCase struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | sdk string
source string
}
for _, tc := range []testCase{
{
sdk: "go",
source: `package main
import "strings"
type Test struct{}
func (m *Test) Repeater(msg string, times int) *Repeater {
return &Repeater{
Message: msg,
Times: times,
}
}
type Repeater struct {
Message string
Times int
}
func (t *Repeater) Render() string {
return strings.Repeat(t.Message, t.Times)
}
`,
},
{
sdk: "python",
source: `from dagger import field, function, object_type
@object_type
class Repeater:
message: str = field(default="") |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | times: int = field(default=0)
@function
def render(self) -> str:
return self.message * self.times
@function
def repeater(msg: str, times: int) -> Repeater:
return Repeater(message=msg, times=times)
`,
},
{
sdk: "typescript",
source: `
import { object, func, field } from "@dagger.io/dagger"
@object()
class Repeater {
@field()
message: string
@field()
times: number
constructor(message: string, times: number) {
this.message = message
this.times = times
}
@func()
render(): string {
return this.message.repeat(this.times)
}
}
@object()
class Test { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | @func()
repeater(msg: string, times: number): Repeater {
return new Repeater(msg, times)
}
}
`,
},
} {
tc := tc
t.Run(fmt.Sprintf("custom %s types", tc.sdk), func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
out, err := modInit(ctx, t, c, tc.sdk, tc.source).
With(daggerQuery(`{test{repeater(msg:"echo!", times: 3){render}}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"test":{"repeater":{"render":"echo!echo!echo!"}}}`, out)
})
}
}
func TestModuleReturnTypeDetection(t *testing.T) {
t.Parallel()
type testCase struct {
sdk string
source string
}
for _, tc := range []testCase{
{
sdk: "go",
source: `package main |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | type Foo struct {}
type X struct {
Message string ` + "`json:\"message\"`" + `
}
func (m *Foo) MyFunction() X {
return X{Message: "foo"}
}
`,
},
{
sdk: "python",
source: `from dagger import field, function, object_type
@object_type
class X:
message: str = field(default="")
@function
def my_function() -> X:
return X(message="foo")
`,
},
{
sdk: "typescript",
source: `
import { object, func, field } from "@dagger.io/dagger"
@object()
class X {
@field()
message: string
constructor(message: string) {
this.message = message; |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | }
}
@object()
class Foo {
@func()
myFunction(): X {
return new X("foo");
}
}
`,
},
} {
tc := tc
t.Run(tc.sdk, func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=foo", "--sdk="+tc.sdk)).
With(sdkSource(tc.sdk, tc.source))
out, err := modGen.With(daggerQuery(`{foo{myFunction{message}}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"foo":{"myFunction":{"message":"foo"}}}`, out)
})
}
}
func TestModuleReturnObject(t *testing.T) {
t.Parallel()
type testCase struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | sdk string
source string
}
for _, tc := range []testCase{
{
sdk: "go",
source: `package main
type Foo struct {}
type X struct {
Message string ` + "`json:\"message\"`" + `
When string ` + "`json:\"Timestamp\"`" + `
To string ` + "`json:\"recipient\"`" + `
From string
}
func (m *Foo) MyFunction() X {
return X{Message: "foo", When: "now", To: "user", From: "admin"}
}
`,
},
{
sdk: "python",
source: `from dagger import field, function, object_type
@object_type
class X: |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | message: str = field(default="")
when: str = field(default="", name="Timestamp")
to: str = field(default="", name="recipient")
from_: str = field(default="", name="from")
@object_type
class Foo:
@function
def my_function(self) -> X:
return X(message="foo", when="now", to="user", from_="admin")
`,
},
{
sdk: "typescript",
source: `
import { object, func, field } from "@dagger.io/dagger"
@object()
class X {
@field()
message: string
@field()
timestamp: string
@field()
recipient: string
@field()
from: string
constructor(message: string, timestamp: string, recipient: string, from: string) {
this.message = message;
this.timestamp = timestamp;
this.recipient = recipient;
this.from = from; |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | }
}
@object()
class Foo {
@func()
myFunction(): X {
return new X("foo", "now", "user", "admin");
}
}
`,
},
} {
tc := tc
t.Run(tc.sdk, func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=foo", "--sdk="+tc.sdk)).
With(sdkSource(tc.sdk, tc.source))
out, err := modGen.With(daggerQuery(`{foo{myFunction{message, recipient, from, timestamp}}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"foo":{"myFunction":{"message":"foo", "recipient":"user", "from":"admin", "timestamp":"now"}}}`, out)
})
}
}
func TestModuleReturnNestedObject(t *testing.T) {
t.Parallel()
type testCase struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | sdk string
source string
}
for _, tc := range []testCase{
{
sdk: "go",
source: `package main
type Playground struct{}
type Foo struct {
MsgContainer Bar
}
type Bar struct {
Msg string
}
func (m *Playground) MyFunction() Foo {
return Foo{MsgContainer: Bar{Msg: "hello world"}}
}
`,
},
{
sdk: "python",
source: `from dagger import field, function, object_type
@object_type |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | class Bar:
msg: str = field()
@object_type
class Foo:
msg_container: Bar = field()
@object_type
class Playground:
@function
def my_function(self) -> Foo:
return Foo(msg_container=Bar(msg="hello world"))
`,
},
{
sdk: "typescript",
source: `
import { object, func, field } from "@dagger.io/dagger"
@object()
class Bar {
@field()
msg: string;
constructor(msg: string) {
this.msg = msg;
}
}
@object()
class Foo {
@field()
msgContainer: Bar;
constructor(msgContainer: Bar) {
this.msgContainer = msgContainer; |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | }
}
@object()
class Playground {
@func()
myFunction(): Foo {
return new Foo(new Bar("hello world"));
}
}
`,
},
} {
tc := tc
t.Run(tc.sdk, func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=playground", "--sdk="+tc.sdk)).
With(sdkSource(tc.sdk, tc.source))
out, err := modGen.With(daggerQuery(`{playground{myFunction{msgContainer{msg}}}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"playground":{"myFunction":{"msgContainer":{"msg": "hello world"}}}}`, out)
})
}
}
func TestModuleReturnCompositeCore(t *testing.T) {
t.Parallel()
type testCase struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | sdk string
source string
}
for _, tc := range []testCase{
{
sdk: "go",
source: `package main
type Playground struct{}
func (m *Playground) MySlice() []*Container {
return []*Container{dag.Container().From("` + alpineImage + `").WithExec([]string{"echo", "hello world"})}
}
type Foo struct {
Con *Container
// verify fields can remain nil w/out error too
UnsetFile *File
}
func (m *Playground) MyStruct() *Foo {
return &Foo{Con: dag.Container().From("` + alpineImage + `").WithExec([]string{"echo", "hello world"})}
}
`,
},
{
sdk: "python",
source: `import dagger
from dagger import dag, field, function, object_type
@object_type
class Foo:
con: dagger.Container = field() |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | unset_file: dagger.File | None = field(default=None)
@object_type
class Playground:
@function
def my_slice(self) -> list[dagger.Container]:
return [dag.container().from_("` + alpineImage + `").with_exec(["echo", "hello world"])]
@function
def my_struct(self) -> Foo:
return Foo(con=dag.container().from_("` + alpineImage + `").with_exec(["echo", "hello world"]))
`,
},
{
sdk: "typescript",
source: `
import { dag, Container, File, object, func, field } from "@dagger.io/dagger"
@object()
class Foo {
@field()
con: Container
@field()
unsetFile?: File
constructor(con: Container, usetFile?: File) {
this.con = con
this.usetFile = usetFile
}
}
@object()
class Playground {
@func()
mySlice(): Container[] { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | return [
dag.container().from("` + alpineImage + `").withExec(["echo", "hello world"])
]
}
@func()
myStruct(): Foo {
return new Foo(
dag.container().from("` + alpineImage + `").withExec(["echo", "hello world"])
)
}
}
`,
},
} {
tc := tc
t.Run(tc.sdk, func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=playground", "--sdk="+tc.sdk)).
With(sdkSource(tc.sdk, tc.source))
out, err := modGen.With(daggerQuery(`{playground{mySlice{stdout}}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"playground":{"mySlice":[{"stdout":"hello world\n"}]}}`, out)
out, err = modGen.With(daggerQuery(`{playground{myStruct{con{stdout}}}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"playground":{"myStruct":{"con":{"stdout":"hello world\n"}}}}`, out)
}) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | }
}
func TestModuleReturnComplexThing(t *testing.T) {
t.Parallel()
type testCase struct {
sdk string
source string
}
for _, tc := range []testCase{
{
sdk: "go",
source: `package main
type Playground struct{}
type ScanResult struct {
Containers []*Container ` + "`json:\"targets\"`" + `
Report ScanReport
}
type ScanReport struct {
Contents string ` + "`json:\"contents\"`" + `
Authors []string ` + "`json:\"Authors\"`" + `
}
func (m *Playground) Scan() ScanResult {
return ScanResult{
Containers: []*Container{
dag.Container().From("` + alpineImage + `").WithExec([]string{"echo", "hello world"}),
},
Report: ScanReport{
Contents: "hello world",
Authors: []string{"foo", "bar"},
}, |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | }
}
`,
},
{
sdk: "python",
source: `import dagger
from dagger import dag, field, function, object_type
@object_type
class ScanReport:
contents: str = field()
authors: list[str] = field()
@object_type
class ScanResult:
containers: list[dagger.Container] = field(name="targets")
report: ScanReport = field()
@object_type
class Playground:
@function
def scan(self) -> ScanResult:
return ScanResult(
containers=[
dag.container().from_("` + alpineImage + `").with_exec(["echo", "hello world"]),
],
report=ScanReport(
contents="hello world",
authors=["foo", "bar"],
),
)
`, |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,659 | Error running `dagger init`: `package name is empty` | To reproduce this, try initializing a dagger module in a directory that already contains a `go.work`. For example:
```
$ git clone https://github.com/dagger/dagger.git
$ go work init
$ dagger init --sdk=go
β ModuleSource.asModule: Module! 2.0s
β Module.withSource(
source: β ModuleSource.resolveFromCaller: ModuleSource! 0.0s
): Module! 2.0s
β Container.directory(path: "/src"): Directory! 1.4s
β rm /dagger/dagger.gen.go 0.4s
β exec /usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json 0.9s
β Error: load package ".": package name is empty
β generating go module: dagger 0.4s
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β writing main.go
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name dagger --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stderr:
Error: load package ".": package name is empty
```
Originally reported by @nipuna-perera on discord: <https://discord.com/channels/707636530424053791/1206727343918293042>
(reproduced in dagger v0.9.10) | https://github.com/dagger/dagger/issues/6659 | https://github.com/dagger/dagger/pull/6678 | b1afa431038bc0a96e4783b30d34b5c8f67f6488 | 31ddf2787ec1e05fb4ad00c33df767796063705f | 2024-02-13T13:35:20Z | go | 2024-02-18T23:23:31Z | core/integration/module_test.go | },
{
sdk: "typescript",
source: `
import { dag, Container, object, func, field } from "@dagger.io/dagger"
@object()
class ScanReport {
@field()
contents: string
@field()
authors: string[]
constructor(contents: string, authors: string[]) {
this.contents = contents
this.authors = authors
}
}
@object()
class ScanResult {
@field("targets")
containers: Container[]
@field()
report: ScanReport
constructor(containers: Container[], report: ScanReport) {
this.containers = containers
this.report = report
}
}
@object()
class Playground {
@func() |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.