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,252 | π Module constructor returns pointer for empty object instead of returning nil for *Directory type | ### What is the issue?
When I created a module constructor with `// +optional=true` missing flag returned a pointer of the empty object instead of nil.
Example Code:
```go
package main
func New(
// +optional=true
src *Directory,
) *A {
return &A{Src: src}
}
type A struct {
Src *Directory
}
func (m *A) IsEmpty() bool {
return m.Src == nil
}
```
### Log output
```shell
dagger call is-empty
β dagger call is-empty [1.38s]
β false
β’ Cloud URL: https://dagger.cloud/runs/6ed9327f-a4e3-4257-9864-87733b642a5f
β’ Engine: 64fae4326b32 (version v0.9.4)
β§ 2.79s β 31 β
7
```
### Steps to reproduce
The code from example can be used for reproducing the issue.
### SDK version
GO SDK v0.9.4
### OS version
macOS 14.0
cc: @jedevc | https://github.com/dagger/dagger/issues/6252 | https://github.com/dagger/dagger/pull/6257 | fd8922f8b964be83bd3fed1490fda114641ac480 | 3b82755058493c63d399bf095b1c3c4b4eba2834 | 2023-12-11T16:59:25Z | go | 2023-12-13T11:16:00Z | core/schema/usermod.go | Name: fmt.Sprintf("%s.%s", m.metadata.Name, obj.typeDef.AsObject.Name),
Schema: typeSchemaStr,
Resolvers: objResolvers,
})
schemas = append(schemas, schema)
}
return schemas, nil
}
func (m *UserMod) SchemaIntrospectionJSON(ctx context.Context) (string, error) {
return m.deps.SchemaIntrospectionJSON(ctx)
}
func (m *UserMod) validateTypeDef(ctx context.Context, typeDef *core.TypeDef) error {
switch typeDef.Kind {
case core.TypeDefKindList:
return m.validateTypeDef(ctx, typeDef.AsList.ElementTypeDef)
case core.TypeDefKindObject:
obj := typeDef.AsObject
modType, ok, err := m.deps.ModTypeFor(ctx, typeDef)
if err != nil {
return fmt.Errorf("failed to get mod type for type def: %w", err)
}
if ok {
if sourceMod := modType.SourceMod(); sourceMod != nil && sourceMod.DagDigest() != m.DagDigest() {
return nil
}
}
for _, field := range obj.Fields {
if gqlFieldName(field.Name) == "id" { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,252 | π Module constructor returns pointer for empty object instead of returning nil for *Directory type | ### What is the issue?
When I created a module constructor with `// +optional=true` missing flag returned a pointer of the empty object instead of nil.
Example Code:
```go
package main
func New(
// +optional=true
src *Directory,
) *A {
return &A{Src: src}
}
type A struct {
Src *Directory
}
func (m *A) IsEmpty() bool {
return m.Src == nil
}
```
### Log output
```shell
dagger call is-empty
β dagger call is-empty [1.38s]
β false
β’ Cloud URL: https://dagger.cloud/runs/6ed9327f-a4e3-4257-9864-87733b642a5f
β’ Engine: 64fae4326b32 (version v0.9.4)
β§ 2.79s β 31 β
7
```
### Steps to reproduce
The code from example can be used for reproducing the issue.
### SDK version
GO SDK v0.9.4
### OS version
macOS 14.0
cc: @jedevc | https://github.com/dagger/dagger/issues/6252 | https://github.com/dagger/dagger/pull/6257 | fd8922f8b964be83bd3fed1490fda114641ac480 | 3b82755058493c63d399bf095b1c3c4b4eba2834 | 2023-12-11T16:59:25Z | go | 2023-12-13T11:16:00Z | core/schema/usermod.go | return fmt.Errorf("cannot define field with reserved name %q on object %q", field.Name, obj.Name)
}
if err := m.validateTypeDef(ctx, field.TypeDef); err != nil {
return err
}
}
for _, fn := range obj.Functions {
if gqlFieldName(fn.Name) == "id" {
return fmt.Errorf("cannot define function with reserved name %q on object %q", fn.Name, obj.Name)
}
if err := m.validateTypeDef(ctx, fn.ReturnType); err != nil {
return err
}
for _, arg := range fn.Args {
if gqlArgName(arg.Name) == "id" {
return fmt.Errorf("cannot define argument with reserved name %q on function %q", arg.Name, fn.Name)
}
if err := m.validateTypeDef(ctx, arg.TypeDef); err != nil {
return err
}
}
}
}
return nil
}
func (m *UserMod) namespaceTypeDef(ctx context.Context, typeDef *core.TypeDef) error {
switch typeDef.Kind {
case core.TypeDefKindList:
if err := m.namespaceTypeDef(ctx, typeDef.AsList.ElementTypeDef); err != nil {
return err |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,252 | π Module constructor returns pointer for empty object instead of returning nil for *Directory type | ### What is the issue?
When I created a module constructor with `// +optional=true` missing flag returned a pointer of the empty object instead of nil.
Example Code:
```go
package main
func New(
// +optional=true
src *Directory,
) *A {
return &A{Src: src}
}
type A struct {
Src *Directory
}
func (m *A) IsEmpty() bool {
return m.Src == nil
}
```
### Log output
```shell
dagger call is-empty
β dagger call is-empty [1.38s]
β false
β’ Cloud URL: https://dagger.cloud/runs/6ed9327f-a4e3-4257-9864-87733b642a5f
β’ Engine: 64fae4326b32 (version v0.9.4)
β§ 2.79s β 31 β
7
```
### Steps to reproduce
The code from example can be used for reproducing the issue.
### SDK version
GO SDK v0.9.4
### OS version
macOS 14.0
cc: @jedevc | https://github.com/dagger/dagger/issues/6252 | https://github.com/dagger/dagger/pull/6257 | fd8922f8b964be83bd3fed1490fda114641ac480 | 3b82755058493c63d399bf095b1c3c4b4eba2834 | 2023-12-11T16:59:25Z | go | 2023-12-13T11:16:00Z | core/schema/usermod.go | }
case core.TypeDefKindObject:
obj := typeDef.AsObject
_, ok, err := m.deps.ModTypeFor(ctx, typeDef)
if err != nil {
return fmt.Errorf("failed to get mod type for type def: %w", err)
}
if !ok {
obj.Name = namespaceObject(obj.Name, m.metadata.Name)
}
for _, field := range obj.Fields {
if err := m.namespaceTypeDef(ctx, field.TypeDef); err != nil {
return err
}
}
for _, fn := range obj.Functions {
if err := m.namespaceTypeDef(ctx, fn.ReturnType); err != nil {
return err
}
for _, arg := range fn.Args {
if err := m.namespaceTypeDef(ctx, arg.TypeDef); err != nil {
return err
}
}
}
}
return nil
}
type UserModObject struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,252 | π Module constructor returns pointer for empty object instead of returning nil for *Directory type | ### What is the issue?
When I created a module constructor with `// +optional=true` missing flag returned a pointer of the empty object instead of nil.
Example Code:
```go
package main
func New(
// +optional=true
src *Directory,
) *A {
return &A{Src: src}
}
type A struct {
Src *Directory
}
func (m *A) IsEmpty() bool {
return m.Src == nil
}
```
### Log output
```shell
dagger call is-empty
β dagger call is-empty [1.38s]
β false
β’ Cloud URL: https://dagger.cloud/runs/6ed9327f-a4e3-4257-9864-87733b642a5f
β’ Engine: 64fae4326b32 (version v0.9.4)
β§ 2.79s β 31 β
7
```
### Steps to reproduce
The code from example can be used for reproducing the issue.
### SDK version
GO SDK v0.9.4
### OS version
macOS 14.0
cc: @jedevc | https://github.com/dagger/dagger/issues/6252 | https://github.com/dagger/dagger/pull/6257 | fd8922f8b964be83bd3fed1490fda114641ac480 | 3b82755058493c63d399bf095b1c3c4b4eba2834 | 2023-12-11T16:59:25Z | go | 2023-12-13T11:16:00Z | core/schema/usermod.go | api *APIServer
mod *UserMod
typeDef *core.TypeDef
lazyLoadedFields []*UserModField
lazyLoadedFunctions []*UserModFunction
loadErr error
loadLock sync.Mutex
}
var _ ModType = (*UserModObject)(nil)
func newModObject(ctx context.Context, mod *UserMod, typeDef *core.TypeDef) (*UserModObject, error) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,252 | π Module constructor returns pointer for empty object instead of returning nil for *Directory type | ### What is the issue?
When I created a module constructor with `// +optional=true` missing flag returned a pointer of the empty object instead of nil.
Example Code:
```go
package main
func New(
// +optional=true
src *Directory,
) *A {
return &A{Src: src}
}
type A struct {
Src *Directory
}
func (m *A) IsEmpty() bool {
return m.Src == nil
}
```
### Log output
```shell
dagger call is-empty
β dagger call is-empty [1.38s]
β false
β’ Cloud URL: https://dagger.cloud/runs/6ed9327f-a4e3-4257-9864-87733b642a5f
β’ Engine: 64fae4326b32 (version v0.9.4)
β§ 2.79s β 31 β
7
```
### Steps to reproduce
The code from example can be used for reproducing the issue.
### SDK version
GO SDK v0.9.4
### OS version
macOS 14.0
cc: @jedevc | https://github.com/dagger/dagger/issues/6252 | https://github.com/dagger/dagger/pull/6257 | fd8922f8b964be83bd3fed1490fda114641ac480 | 3b82755058493c63d399bf095b1c3c4b4eba2834 | 2023-12-11T16:59:25Z | go | 2023-12-13T11:16:00Z | core/schema/usermod.go | if typeDef.Kind != core.TypeDefKindObject {
return nil, fmt.Errorf("expected object type def, got %s", typeDef.Kind)
}
obj := &UserModObject{
api: mod.api,
mod: mod,
typeDef: typeDef,
}
return obj, nil
}
func (obj *UserModObject) TypeDef() *core.TypeDef {
return obj.typeDef
}
func (obj *UserModObject) ConvertFromSDKResult(ctx context.Context, value any) (any, error) {
if value == nil {
return nil, nil
}
switch value := value.(type) {
case string:
decodedMap, err := resourceid.DecodeModuleID(value, obj.typeDef.AsObject.Name)
if err != nil {
return nil, fmt.Errorf("failed to decode module id: %w", err)
}
return obj.ConvertFromSDKResult(ctx, decodedMap)
case map[string]any:
for k, v := range value {
normalizedName := gqlFieldName(k) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,252 | π Module constructor returns pointer for empty object instead of returning nil for *Directory type | ### What is the issue?
When I created a module constructor with `// +optional=true` missing flag returned a pointer of the empty object instead of nil.
Example Code:
```go
package main
func New(
// +optional=true
src *Directory,
) *A {
return &A{Src: src}
}
type A struct {
Src *Directory
}
func (m *A) IsEmpty() bool {
return m.Src == nil
}
```
### Log output
```shell
dagger call is-empty
β dagger call is-empty [1.38s]
β false
β’ Cloud URL: https://dagger.cloud/runs/6ed9327f-a4e3-4257-9864-87733b642a5f
β’ Engine: 64fae4326b32 (version v0.9.4)
β§ 2.79s β 31 β
7
```
### Steps to reproduce
The code from example can be used for reproducing the issue.
### SDK version
GO SDK v0.9.4
### OS version
macOS 14.0
cc: @jedevc | https://github.com/dagger/dagger/issues/6252 | https://github.com/dagger/dagger/pull/6257 | fd8922f8b964be83bd3fed1490fda114641ac480 | 3b82755058493c63d399bf095b1c3c4b4eba2834 | 2023-12-11T16:59:25Z | go | 2023-12-13T11:16:00Z | core/schema/usermod.go | field, ok, err := obj.FieldByName(ctx, normalizedName)
if err != nil {
return nil, fmt.Errorf("failed to get field %q: %w", k, err)
}
if !ok {
continue
}
delete(value, k)
value[normalizedName], err = field.modType.ConvertFromSDKResult(ctx, v)
if err != nil {
return nil, fmt.Errorf("failed to convert field %q: %w", k, err)
}
}
return value, nil
default:
return nil, fmt.Errorf("unexpected result value type %T for object %q", value, obj.typeDef.AsObject.Name)
}
}
func (obj *UserModObject) ConvertToSDKInput(ctx context.Context, value any) (any, error) {
if value == nil {
return nil, nil
}
switch value := value.(type) {
case string:
return resourceid.DecodeModuleID(value, obj.typeDef.AsObject.Name)
case map[string]any: |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,252 | π Module constructor returns pointer for empty object instead of returning nil for *Directory type | ### What is the issue?
When I created a module constructor with `// +optional=true` missing flag returned a pointer of the empty object instead of nil.
Example Code:
```go
package main
func New(
// +optional=true
src *Directory,
) *A {
return &A{Src: src}
}
type A struct {
Src *Directory
}
func (m *A) IsEmpty() bool {
return m.Src == nil
}
```
### Log output
```shell
dagger call is-empty
β dagger call is-empty [1.38s]
β false
β’ Cloud URL: https://dagger.cloud/runs/6ed9327f-a4e3-4257-9864-87733b642a5f
β’ Engine: 64fae4326b32 (version v0.9.4)
β§ 2.79s β 31 β
7
```
### Steps to reproduce
The code from example can be used for reproducing the issue.
### SDK version
GO SDK v0.9.4
### OS version
macOS 14.0
cc: @jedevc | https://github.com/dagger/dagger/issues/6252 | https://github.com/dagger/dagger/pull/6257 | fd8922f8b964be83bd3fed1490fda114641ac480 | 3b82755058493c63d399bf095b1c3c4b4eba2834 | 2023-12-11T16:59:25Z | go | 2023-12-13T11:16:00Z | core/schema/usermod.go | for k, v := range value {
normalizedName := gqlFieldName(k)
field, ok, err := obj.FieldByName(ctx, normalizedName)
if err != nil {
return nil, fmt.Errorf("failed to get field %q: %w", k, err)
}
if !ok {
continue
}
value[k], err = field.modType.ConvertToSDKInput(ctx, v)
if err != nil {
return nil, fmt.Errorf("failed to convert field %q: %w", k, err)
}
}
return value, nil
default:
return nil, fmt.Errorf("unexpected input value type %T for object %q", value, obj.typeDef.AsObject.Name)
}
}
func (obj *UserModObject) SourceMod() Mod {
return obj.mod
}
func (obj *UserModObject) Fields(ctx context.Context) ([]*UserModField, error) {
fields, _, err := obj.loadFieldsAndFunctions(ctx)
if err != nil {
return nil, err
}
return fields, nil
}
func (obj *UserModObject) Functions(ctx context.Context) ([]*UserModFunction, error) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,252 | π Module constructor returns pointer for empty object instead of returning nil for *Directory type | ### What is the issue?
When I created a module constructor with `// +optional=true` missing flag returned a pointer of the empty object instead of nil.
Example Code:
```go
package main
func New(
// +optional=true
src *Directory,
) *A {
return &A{Src: src}
}
type A struct {
Src *Directory
}
func (m *A) IsEmpty() bool {
return m.Src == nil
}
```
### Log output
```shell
dagger call is-empty
β dagger call is-empty [1.38s]
β false
β’ Cloud URL: https://dagger.cloud/runs/6ed9327f-a4e3-4257-9864-87733b642a5f
β’ Engine: 64fae4326b32 (version v0.9.4)
β§ 2.79s β 31 β
7
```
### Steps to reproduce
The code from example can be used for reproducing the issue.
### SDK version
GO SDK v0.9.4
### OS version
macOS 14.0
cc: @jedevc | https://github.com/dagger/dagger/issues/6252 | https://github.com/dagger/dagger/pull/6257 | fd8922f8b964be83bd3fed1490fda114641ac480 | 3b82755058493c63d399bf095b1c3c4b4eba2834 | 2023-12-11T16:59:25Z | go | 2023-12-13T11:16:00Z | core/schema/usermod.go | _, functions, err := obj.loadFieldsAndFunctions(ctx)
if err != nil {
return nil, err
}
return functions, nil
}
func (obj *UserModObject) loadFieldsAndFunctions(ctx context.Context) (
loadedFields []*UserModField, loadedFunctions []*UserModFunction, rerr error,
) {
obj.loadLock.Lock()
defer obj.loadLock.Unlock()
if len(obj.lazyLoadedFields) > 0 || len(obj.lazyLoadedFunctions) > 0 {
return obj.lazyLoadedFields, obj.lazyLoadedFunctions, nil
}
if obj.loadErr != nil {
return nil, nil, obj.loadErr
}
defer func() {
obj.lazyLoadedFields = loadedFields
obj.lazyLoadedFunctions = loadedFunctions
obj.loadErr = rerr
}()
runtime, err := obj.mod.Runtime(ctx)
if err != nil {
return nil, nil, fmt.Errorf("failed to get module runtime: %w", err)
}
for _, fieldTypeDef := range obj.typeDef.AsObject.Fields {
modField, err := newModField(ctx, obj, fieldTypeDef)
if err != nil {
return nil, nil, fmt.Errorf("failed to create field: %w", err) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,252 | π Module constructor returns pointer for empty object instead of returning nil for *Directory type | ### What is the issue?
When I created a module constructor with `// +optional=true` missing flag returned a pointer of the empty object instead of nil.
Example Code:
```go
package main
func New(
// +optional=true
src *Directory,
) *A {
return &A{Src: src}
}
type A struct {
Src *Directory
}
func (m *A) IsEmpty() bool {
return m.Src == nil
}
```
### Log output
```shell
dagger call is-empty
β dagger call is-empty [1.38s]
β false
β’ Cloud URL: https://dagger.cloud/runs/6ed9327f-a4e3-4257-9864-87733b642a5f
β’ Engine: 64fae4326b32 (version v0.9.4)
β§ 2.79s β 31 β
7
```
### Steps to reproduce
The code from example can be used for reproducing the issue.
### SDK version
GO SDK v0.9.4
### OS version
macOS 14.0
cc: @jedevc | https://github.com/dagger/dagger/issues/6252 | https://github.com/dagger/dagger/pull/6257 | fd8922f8b964be83bd3fed1490fda114641ac480 | 3b82755058493c63d399bf095b1c3c4b4eba2834 | 2023-12-11T16:59:25Z | go | 2023-12-13T11:16:00Z | core/schema/usermod.go | }
loadedFields = append(loadedFields, modField)
}
for _, fn := range obj.typeDef.AsObject.Functions {
modFunction, err := newModFunction(ctx, obj.mod, obj, runtime, fn)
if err != nil {
return nil, nil, fmt.Errorf("failed to create function: %w", err)
}
loadedFunctions = append(loadedFunctions, modFunction)
}
return loadedFields, loadedFunctions, nil
}
func (obj *UserModObject) FieldByName(ctx context.Context, name string) (*UserModField, bool, error) {
fields, _, err := obj.loadFieldsAndFunctions(ctx)
if err != nil {
return nil, false, err
}
name = gqlFieldName(name)
for _, f := range fields {
if gqlFieldName(f.metadata.Name) == name {
return f, true, nil
}
}
return nil, false, nil
}
func (obj *UserModObject) FunctionByName(ctx context.Context, name string) (*UserModFunction, bool, error) {
_, functions, err := obj.loadFieldsAndFunctions(ctx)
if err != nil {
return nil, false, err
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,252 | π Module constructor returns pointer for empty object instead of returning nil for *Directory type | ### What is the issue?
When I created a module constructor with `// +optional=true` missing flag returned a pointer of the empty object instead of nil.
Example Code:
```go
package main
func New(
// +optional=true
src *Directory,
) *A {
return &A{Src: src}
}
type A struct {
Src *Directory
}
func (m *A) IsEmpty() bool {
return m.Src == nil
}
```
### Log output
```shell
dagger call is-empty
β dagger call is-empty [1.38s]
β false
β’ Cloud URL: https://dagger.cloud/runs/6ed9327f-a4e3-4257-9864-87733b642a5f
β’ Engine: 64fae4326b32 (version v0.9.4)
β§ 2.79s β 31 β
7
```
### Steps to reproduce
The code from example can be used for reproducing the issue.
### SDK version
GO SDK v0.9.4
### OS version
macOS 14.0
cc: @jedevc | https://github.com/dagger/dagger/issues/6252 | https://github.com/dagger/dagger/pull/6257 | fd8922f8b964be83bd3fed1490fda114641ac480 | 3b82755058493c63d399bf095b1c3c4b4eba2834 | 2023-12-11T16:59:25Z | go | 2023-12-13T11:16:00Z | core/schema/usermod.go | name = gqlFieldName(name)
for _, fn := range functions {
if gqlFieldName(fn.metadata.Name) == name {
return fn, true, nil
}
}
return nil, false, nil
}
func (obj *UserModObject) Schema(ctx context.Context) (*ast.SchemaDocument, Resolvers, error) {
ctx = bklog.WithLogger(ctx, bklog.G(ctx).WithField("object", obj.typeDef.AsObject.Name))
bklog.G(ctx).Debug("getting object schema")
fields, functions, err := obj.loadFieldsAndFunctions(ctx)
if err != nil {
return nil, nil, err
}
typeSchemaDoc := &ast.SchemaDocument{}
queryResolver := ObjectResolver{}
typeSchemaResolvers := Resolvers{
"Query": queryResolver,
}
objTypeDef := obj.typeDef.AsObject
objName := gqlObjectName(objTypeDef.Name)
objASTType, err := typeDefToASTType(obj.typeDef, false)
if err != nil {
return nil, nil, fmt.Errorf("failed to convert object to schema: %w", err)
}
modType, ok, err := obj.mod.deps.ModTypeFor(ctx, obj.typeDef)
if err != nil { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,252 | π Module constructor returns pointer for empty object instead of returning nil for *Directory type | ### What is the issue?
When I created a module constructor with `// +optional=true` missing flag returned a pointer of the empty object instead of nil.
Example Code:
```go
package main
func New(
// +optional=true
src *Directory,
) *A {
return &A{Src: src}
}
type A struct {
Src *Directory
}
func (m *A) IsEmpty() bool {
return m.Src == nil
}
```
### Log output
```shell
dagger call is-empty
β dagger call is-empty [1.38s]
β false
β’ Cloud URL: https://dagger.cloud/runs/6ed9327f-a4e3-4257-9864-87733b642a5f
β’ Engine: 64fae4326b32 (version v0.9.4)
β§ 2.79s β 31 β
7
```
### Steps to reproduce
The code from example can be used for reproducing the issue.
### SDK version
GO SDK v0.9.4
### OS version
macOS 14.0
cc: @jedevc | https://github.com/dagger/dagger/issues/6252 | https://github.com/dagger/dagger/pull/6257 | fd8922f8b964be83bd3fed1490fda114641ac480 | 3b82755058493c63d399bf095b1c3c4b4eba2834 | 2023-12-11T16:59:25Z | go | 2023-12-13T11:16:00Z | core/schema/usermod.go | return nil, nil, fmt.Errorf("failed to get mod type for type def: %w", err)
}
if ok {
if sourceMod := modType.SourceMod(); sourceMod != nil && sourceMod.DagDigest() != obj.mod.DagDigest() {
if len(objTypeDef.Fields) > 0 || len(objTypeDef.Functions) > 0 {
return nil, nil, fmt.Errorf("cannot attach new fields or functions to object %q from outside module", objName)
}
return nil, nil, nil
}
}
astDef := &ast.Definition{
Name: objName,
Description: formatGqlDescription(objTypeDef.Description),
Kind: ast.Object,
}
astIDDef := &ast.Definition{
Name: objName + "ID",
Description: formatGqlDescription("%s identifier", objName),
Kind: ast.Scalar,
}
astLoadDef := &ast.FieldDefinition{
Name: fmt.Sprintf("load%sFromID", objName),
Description: formatGqlDescription("Loads a %s from an ID", objName),
Arguments: ast.ArgumentDefinitionList{
&ast.ArgumentDefinition{
Name: "id",
Type: ast.NonNullNamedType(objName+"ID", nil),
}, |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,252 | π Module constructor returns pointer for empty object instead of returning nil for *Directory type | ### What is the issue?
When I created a module constructor with `// +optional=true` missing flag returned a pointer of the empty object instead of nil.
Example Code:
```go
package main
func New(
// +optional=true
src *Directory,
) *A {
return &A{Src: src}
}
type A struct {
Src *Directory
}
func (m *A) IsEmpty() bool {
return m.Src == nil
}
```
### Log output
```shell
dagger call is-empty
β dagger call is-empty [1.38s]
β false
β’ Cloud URL: https://dagger.cloud/runs/6ed9327f-a4e3-4257-9864-87733b642a5f
β’ Engine: 64fae4326b32 (version v0.9.4)
β§ 2.79s β 31 β
7
```
### Steps to reproduce
The code from example can be used for reproducing the issue.
### SDK version
GO SDK v0.9.4
### OS version
macOS 14.0
cc: @jedevc | https://github.com/dagger/dagger/issues/6252 | https://github.com/dagger/dagger/pull/6257 | fd8922f8b964be83bd3fed1490fda114641ac480 | 3b82755058493c63d399bf095b1c3c4b4eba2834 | 2023-12-11T16:59:25Z | go | 2023-12-13T11:16:00Z | core/schema/usermod.go | },
Type: ast.NonNullNamedType(objName, nil),
}
newObjResolver := ObjectResolver{}
astDef.Fields = append(astDef.Fields, &ast.FieldDefinition{
Name: "id",
Description: formatGqlDescription("A unique identifier for a %s", objName),
Type: ast.NonNullNamedType(objName+"ID", nil),
})
newObjResolver["id"] = func(p graphql.ResolveParams) (any, error) {
return resourceid.EncodeModule(objName, p.Source)
}
for _, field := range fields {
fieldDef, resolver, err := field.Schema(ctx)
if err != nil {
return nil, nil, err
}
astDef.Fields = append(astDef.Fields, fieldDef)
newObjResolver[fieldDef.Name] = resolver
}
for _, fn := range functions {
fieldDef, resolver, err := fn.Schema(ctx)
if err != nil {
return nil, nil, err
}
astDef.Fields = append(astDef.Fields, fieldDef)
newObjResolver[fieldDef.Name] = resolver
}
if len(newObjResolver) > 0 {
typeSchemaResolvers[objName] = newObjResolver |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,252 | π Module constructor returns pointer for empty object instead of returning nil for *Directory type | ### What is the issue?
When I created a module constructor with `// +optional=true` missing flag returned a pointer of the empty object instead of nil.
Example Code:
```go
package main
func New(
// +optional=true
src *Directory,
) *A {
return &A{Src: src}
}
type A struct {
Src *Directory
}
func (m *A) IsEmpty() bool {
return m.Src == nil
}
```
### Log output
```shell
dagger call is-empty
β dagger call is-empty [1.38s]
β false
β’ Cloud URL: https://dagger.cloud/runs/6ed9327f-a4e3-4257-9864-87733b642a5f
β’ Engine: 64fae4326b32 (version v0.9.4)
β§ 2.79s β 31 β
7
```
### Steps to reproduce
The code from example can be used for reproducing the issue.
### SDK version
GO SDK v0.9.4
### OS version
macOS 14.0
cc: @jedevc | https://github.com/dagger/dagger/issues/6252 | https://github.com/dagger/dagger/pull/6257 | fd8922f8b964be83bd3fed1490fda114641ac480 | 3b82755058493c63d399bf095b1c3c4b4eba2834 | 2023-12-11T16:59:25Z | go | 2023-12-13T11:16:00Z | core/schema/usermod.go | typeSchemaResolvers[objName+"ID"] = stringResolver[string]()
queryResolver[fmt.Sprintf("load%sFromID", objName)] = func(p graphql.ResolveParams) (any, error) {
return obj.ConvertFromSDKResult(ctx, p.Args["id"])
}
}
var constructorFieldDef *ast.FieldDefinition
var constructorResolver graphql.FieldResolveFn
isMainModuleObject := objName == gqlObjectName(obj.mod.metadata.Name)
if isMainModuleObject {
constructorFieldDef = &ast.FieldDefinition{
Name: gqlFieldName(objName),
Description: formatGqlDescription(objTypeDef.Description),
Type: objASTType,
}
if objTypeDef.Constructor != nil {
fnTypeDef := objTypeDef.Constructor
if fnTypeDef.ReturnType.Kind != core.TypeDefKindObject {
return nil, nil, fmt.Errorf("constructor function for object %s must return that object", objTypeDef.OriginalName)
}
if fnTypeDef.ReturnType.AsObject.OriginalName != objTypeDef.OriginalName {
return nil, nil, fmt.Errorf("constructor function for object %s must return that object", objTypeDef.OriginalName)
}
runtime, err := obj.mod.Runtime(ctx)
if err != nil {
return nil, nil, fmt.Errorf("failed to get module runtime: %w", err)
}
fn, err := newModFunction(ctx, obj.mod, obj, runtime, fnTypeDef)
if err != nil { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,252 | π Module constructor returns pointer for empty object instead of returning nil for *Directory type | ### What is the issue?
When I created a module constructor with `// +optional=true` missing flag returned a pointer of the empty object instead of nil.
Example Code:
```go
package main
func New(
// +optional=true
src *Directory,
) *A {
return &A{Src: src}
}
type A struct {
Src *Directory
}
func (m *A) IsEmpty() bool {
return m.Src == nil
}
```
### Log output
```shell
dagger call is-empty
β dagger call is-empty [1.38s]
β false
β’ Cloud URL: https://dagger.cloud/runs/6ed9327f-a4e3-4257-9864-87733b642a5f
β’ Engine: 64fae4326b32 (version v0.9.4)
β§ 2.79s β 31 β
7
```
### Steps to reproduce
The code from example can be used for reproducing the issue.
### SDK version
GO SDK v0.9.4
### OS version
macOS 14.0
cc: @jedevc | https://github.com/dagger/dagger/issues/6252 | https://github.com/dagger/dagger/pull/6257 | fd8922f8b964be83bd3fed1490fda114641ac480 | 3b82755058493c63d399bf095b1c3c4b4eba2834 | 2023-12-11T16:59:25Z | go | 2023-12-13T11:16:00Z | core/schema/usermod.go | return nil, nil, fmt.Errorf("failed to create function: %w", err)
}
fieldDef, resolver, err := fn.Schema(ctx)
if err != nil {
return nil, nil, fmt.Errorf("failed to get schema for constructor function: %w", err)
}
constructorFieldDef.Arguments = fieldDef.Arguments
constructorResolver = resolver
} else {
constructorResolver = PassthroughResolver
}
typeSchemaDoc.Extensions = append(typeSchemaDoc.Extensions, &ast.Definition{
Name: "Query",
Kind: ast.Object,
Fields: ast.FieldList{constructorFieldDef},
})
queryResolver[constructorFieldDef.Name] = constructorResolver
}
if len(astDef.Fields) > 0 || constructorFieldDef != nil {
typeSchemaDoc.Definitions = append(typeSchemaDoc.Definitions, astDef, astIDDef)
typeSchemaDoc.Extensions = append(typeSchemaDoc.Extensions, &ast.Definition{
Name: "Query",
Kind: ast.Object,
Fields: ast.FieldList{astLoadDef},
})
}
return typeSchemaDoc, typeSchemaResolvers, nil
}
type UserModField struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,252 | π Module constructor returns pointer for empty object instead of returning nil for *Directory type | ### What is the issue?
When I created a module constructor with `// +optional=true` missing flag returned a pointer of the empty object instead of nil.
Example Code:
```go
package main
func New(
// +optional=true
src *Directory,
) *A {
return &A{Src: src}
}
type A struct {
Src *Directory
}
func (m *A) IsEmpty() bool {
return m.Src == nil
}
```
### Log output
```shell
dagger call is-empty
β dagger call is-empty [1.38s]
β false
β’ Cloud URL: https://dagger.cloud/runs/6ed9327f-a4e3-4257-9864-87733b642a5f
β’ Engine: 64fae4326b32 (version v0.9.4)
β§ 2.79s β 31 β
7
```
### Steps to reproduce
The code from example can be used for reproducing the issue.
### SDK version
GO SDK v0.9.4
### OS version
macOS 14.0
cc: @jedevc | https://github.com/dagger/dagger/issues/6252 | https://github.com/dagger/dagger/pull/6257 | fd8922f8b964be83bd3fed1490fda114641ac480 | 3b82755058493c63d399bf095b1c3c4b4eba2834 | 2023-12-11T16:59:25Z | go | 2023-12-13T11:16:00Z | core/schema/usermod.go | obj *UserModObject
metadata *core.FieldTypeDef
modType ModType
}
func newModField(ctx context.Context, obj *UserModObject, metadata *core.FieldTypeDef) (*UserModField, error) {
modType, ok, err := obj.mod.ModTypeFor(ctx, metadata.TypeDef, true)
if err != nil {
return nil, fmt.Errorf("failed to get mod type for field %q: %w", metadata.Name, err)
}
if !ok {
return nil, fmt.Errorf("failed to get mod type for field %q", metadata.Name)
}
return &UserModField{
obj: obj,
metadata: metadata,
modType: modType,
}, nil |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,252 | π Module constructor returns pointer for empty object instead of returning nil for *Directory type | ### What is the issue?
When I created a module constructor with `// +optional=true` missing flag returned a pointer of the empty object instead of nil.
Example Code:
```go
package main
func New(
// +optional=true
src *Directory,
) *A {
return &A{Src: src}
}
type A struct {
Src *Directory
}
func (m *A) IsEmpty() bool {
return m.Src == nil
}
```
### Log output
```shell
dagger call is-empty
β dagger call is-empty [1.38s]
β false
β’ Cloud URL: https://dagger.cloud/runs/6ed9327f-a4e3-4257-9864-87733b642a5f
β’ Engine: 64fae4326b32 (version v0.9.4)
β§ 2.79s β 31 β
7
```
### Steps to reproduce
The code from example can be used for reproducing the issue.
### SDK version
GO SDK v0.9.4
### OS version
macOS 14.0
cc: @jedevc | https://github.com/dagger/dagger/issues/6252 | https://github.com/dagger/dagger/pull/6257 | fd8922f8b964be83bd3fed1490fda114641ac480 | 3b82755058493c63d399bf095b1c3c4b4eba2834 | 2023-12-11T16:59:25Z | go | 2023-12-13T11:16:00Z | core/schema/usermod.go | }
func (f *UserModField) Schema(ctx context.Context) (*ast.FieldDefinition, graphql.FieldResolveFn, error) {
typeDef := f.metadata.TypeDef
fieldASTType, err := typeDefToASTType(typeDef, false)
if err != nil {
return nil, nil, err
}
sourceMod := f.modType.SourceMod()
if sourceMod != nil && sourceMod.Name() != coreModuleName && sourceMod.DagDigest() != f.obj.mod.DagDigest() {
return nil, nil, fmt.Errorf("object %q field %q cannot reference external type from dependency module %q",
f.obj.typeDef.AsObject.OriginalName,
f.metadata.OriginalName,
sourceMod.Name(),
)
}
fieldDef := &ast.FieldDefinition{
Name: f.metadata.Name,
Description: formatGqlDescription(f.metadata.Description),
Type: fieldASTType,
}
return fieldDef, func(p graphql.ResolveParams) (any, error) {
res, err := graphql.DefaultResolveFn(p)
if err != nil {
return nil, err
}
return f.modType.ConvertFromSDKResult(ctx, res)
}, nil
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,066 | dagger mod publish should switch to `PUT /crawl` instead of `GET /crawl` | There has been a recent change - 7pm GMT on Nov. 5, 2023 - in the <https://daggerverse.dev> route that publishes a module.
It used to be `GET /crawl`. It is not `PUT /crawl`. This private PR has more details: https://github.com/dagger/dagger.io/pull/3058#issuecomment-1793819422
This is a reminder that we need to change the route that `dagger mod publish` uses & also cut a new release.
As a temporary workaround publish directly from <https://daggerverse.dev> instead.
I will be travelling & will not have internet for the next 10 hours. Unless someone else doesn't beat me to it - @vito @sipsma @jedevc @helderco @marcosnils @aluzzardi - I will look into this when I get on the other side.
π« | https://github.com/dagger/dagger/issues/6066 | https://github.com/dagger/dagger/pull/6274 | 4d96689943afb13c23f5984dbe19e7967c912a7d | d63f3fb2f14314206d748a25a95abf8e9731bd52 | 2023-11-06T11:07:55Z | go | 2023-12-15T21:29:50Z | cmd/dagger/module.go | package main
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
"os"
"path"
"path/filepath"
"strings"
"dagger.io/dagger"
"github.com/dagger/dagger/core/modules"
"github.com/dagger/dagger/engine/client"
"github.com/go-git/go-git/v5"
"github.com/iancoleman/strcase"
"github.com/moby/buildkit/util/gitutil"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/vito/progrock"
)
var ( |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,066 | dagger mod publish should switch to `PUT /crawl` instead of `GET /crawl` | There has been a recent change - 7pm GMT on Nov. 5, 2023 - in the <https://daggerverse.dev> route that publishes a module.
It used to be `GET /crawl`. It is not `PUT /crawl`. This private PR has more details: https://github.com/dagger/dagger.io/pull/3058#issuecomment-1793819422
This is a reminder that we need to change the route that `dagger mod publish` uses & also cut a new release.
As a temporary workaround publish directly from <https://daggerverse.dev> instead.
I will be travelling & will not have internet for the next 10 hours. Unless someone else doesn't beat me to it - @vito @sipsma @jedevc @helderco @marcosnils @aluzzardi - I will look into this when I get on the other side.
π« | https://github.com/dagger/dagger/issues/6066 | https://github.com/dagger/dagger/pull/6274 | 4d96689943afb13c23f5984dbe19e7967c912a7d | d63f3fb2f14314206d748a25a95abf8e9731bd52 | 2023-11-06T11:07:55Z | go | 2023-12-15T21:29:50Z | cmd/dagger/module.go | moduleURL string
moduleFlags = pflag.NewFlagSet("module", pflag.ContinueOnError)
sdk string
licenseID string
moduleName string
moduleRoot string
force bool
)
const (
moduleURLDefault = "."
)
func init() {
moduleFlags.StringVarP(&moduleURL, "mod", "m", "", "Path to dagger.json config file for the module or a directory containing that file. Either local path (e.g. \"/path/to/some/dir\") or a github repo (e.g. \"github.com/dagger/dagger/path/to/some/subdir\").")
moduleFlags.BoolVar(&focus, "focus", true, "Only show output for focused commands.")
moduleCmd.PersistentFlags().AddFlagSet(moduleFlags)
listenCmd.PersistentFlags().AddFlagSet(moduleFlags)
queryCmd.PersistentFlags().AddFlagSet(moduleFlags)
funcCmds.AddFlagSet(moduleFlags)
moduleInitCmd.PersistentFlags().StringVar(&sdk, "sdk", "", "SDK name or image ref to use for the module")
moduleInitCmd.MarkPersistentFlagRequired("sdk")
moduleInitCmd.PersistentFlags().StringVar(&moduleName, "name", "", "Name of the new module")
moduleInitCmd.MarkPersistentFlagRequired("name")
moduleInitCmd.PersistentFlags().StringVar(&licenseID, "license", "", "License identifier to generate - see https:spdx.org/licenses/")
moduleInitCmd.PersistentFlags().StringVarP(&moduleRoot, "root", "", "", "Root directory that should be loaded for the full module context. Defaults to the parent directory containing dagger.json.")
modulePublishCmd.PersistentFlags().BoolVarP(&force, "force", "f", false, "Force publish even if the git repository is not clean.")
moduleCmd.AddCommand(moduleInitCmd)
moduleCmd.AddCommand(moduleInstallCmd)
moduleCmd.AddCommand(moduleSyncCmd)
moduleCmd.AddCommand(modulePublishCmd) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,066 | dagger mod publish should switch to `PUT /crawl` instead of `GET /crawl` | There has been a recent change - 7pm GMT on Nov. 5, 2023 - in the <https://daggerverse.dev> route that publishes a module.
It used to be `GET /crawl`. It is not `PUT /crawl`. This private PR has more details: https://github.com/dagger/dagger.io/pull/3058#issuecomment-1793819422
This is a reminder that we need to change the route that `dagger mod publish` uses & also cut a new release.
As a temporary workaround publish directly from <https://daggerverse.dev> instead.
I will be travelling & will not have internet for the next 10 hours. Unless someone else doesn't beat me to it - @vito @sipsma @jedevc @helderco @marcosnils @aluzzardi - I will look into this when I get on the other side.
π« | https://github.com/dagger/dagger/issues/6066 | https://github.com/dagger/dagger/pull/6274 | 4d96689943afb13c23f5984dbe19e7967c912a7d | d63f3fb2f14314206d748a25a95abf8e9731bd52 | 2023-11-06T11:07:55Z | go | 2023-12-15T21:29:50Z | cmd/dagger/module.go | }
var moduleCmd = &cobra.Command{
Use: "module",
Aliases: []string{"mod"},
Short: "Manage dagger modules",
Long: "Manage dagger modules. By default, print the configuration of the specified module in json format.",
Hidden: true,
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
return withEngineAndTUI(ctx, client.Params{}, func(ctx context.Context, engineClient *client.Client) (err error) {
mod, _, err := getModuleRef(ctx, engineClient.Dagger())
if err != nil {
return fmt.Errorf("failed to get module: %w", err)
}
var cfg *modules.Config
switch {
case mod.Local:
cfg, err = mod.Config(ctx, nil)
if err != nil {
return fmt.Errorf("failed to get local module config: %w", err)
}
case mod.Git != nil:
rec := progrock.FromContext(ctx)
vtx := rec.Vertex("get-mod-config", strings.Join(os.Args, " "))
defer func() { vtx.Done(err) }()
readConfigTask := vtx.Task("reading git module config")
cfg, err = mod.Config(ctx, engineClient.Dagger())
readConfigTask.Done(err)
if err != nil {
return fmt.Errorf("failed to get git module config: %w", err) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,066 | dagger mod publish should switch to `PUT /crawl` instead of `GET /crawl` | There has been a recent change - 7pm GMT on Nov. 5, 2023 - in the <https://daggerverse.dev> route that publishes a module.
It used to be `GET /crawl`. It is not `PUT /crawl`. This private PR has more details: https://github.com/dagger/dagger.io/pull/3058#issuecomment-1793819422
This is a reminder that we need to change the route that `dagger mod publish` uses & also cut a new release.
As a temporary workaround publish directly from <https://daggerverse.dev> instead.
I will be travelling & will not have internet for the next 10 hours. Unless someone else doesn't beat me to it - @vito @sipsma @jedevc @helderco @marcosnils @aluzzardi - I will look into this when I get on the other side.
π« | https://github.com/dagger/dagger/issues/6066 | https://github.com/dagger/dagger/pull/6274 | 4d96689943afb13c23f5984dbe19e7967c912a7d | d63f3fb2f14314206d748a25a95abf8e9731bd52 | 2023-11-06T11:07:55Z | go | 2023-12-15T21:29:50Z | cmd/dagger/module.go | }
}
cfgBytes, err := json.MarshalIndent(cfg, "", " ")
if err != nil {
return fmt.Errorf("failed to marshal module config: %w", err)
}
cmd.Println(string(cfgBytes))
return nil
})
},
}
var moduleInitCmd = &cobra.Command{
Use: "init",
Short: "Initialize a new dagger module in a local directory.",
Hidden: false,
RunE: func(cmd *cobra.Command, _ []string) (rerr error) {
ctx := cmd.Context()
return withEngineAndTUI(ctx, client.Params{}, func(ctx context.Context, engineClient *client.Client) (err error) {
dag := engineClient.Dagger()
ref, _, err := getModuleRef(ctx, dag)
if err != nil {
return fmt.Errorf("failed to get module: %w", err)
}
moduleDir, err := ref.LocalSourcePath()
if err != nil {
return fmt.Errorf("module init is only supported for local modules")
}
if _, err := ref.Config(ctx, nil); err == nil {
return fmt.Errorf("module init config path already exists: %s", ref.Path)
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,066 | dagger mod publish should switch to `PUT /crawl` instead of `GET /crawl` | There has been a recent change - 7pm GMT on Nov. 5, 2023 - in the <https://daggerverse.dev> route that publishes a module.
It used to be `GET /crawl`. It is not `PUT /crawl`. This private PR has more details: https://github.com/dagger/dagger.io/pull/3058#issuecomment-1793819422
This is a reminder that we need to change the route that `dagger mod publish` uses & also cut a new release.
As a temporary workaround publish directly from <https://daggerverse.dev> instead.
I will be travelling & will not have internet for the next 10 hours. Unless someone else doesn't beat me to it - @vito @sipsma @jedevc @helderco @marcosnils @aluzzardi - I will look into this when I get on the other side.
π« | https://github.com/dagger/dagger/issues/6066 | https://github.com/dagger/dagger/pull/6274 | 4d96689943afb13c23f5984dbe19e7967c912a7d | d63f3fb2f14314206d748a25a95abf8e9731bd52 | 2023-11-06T11:07:55Z | go | 2023-12-15T21:29:50Z | cmd/dagger/module.go | if err := findOrCreateLicense(ctx, moduleDir); err != nil {
return err
}
cfg := modules.NewConfig(moduleName, sdk, moduleRoot)
return updateModuleConfig(ctx, dag, moduleDir, ref, cfg, cmd)
})
},
}
var moduleInstallCmd = &cobra.Command{
Use: "install",
Aliases: []string{"use"},
Short: "Add a new dependency to a dagger module",
Hidden: false,
RunE: func(cmd *cobra.Command, extraArgs []string) (rerr error) {
ctx := cmd.Context()
return withEngineAndTUI(ctx, client.Params{}, func(ctx context.Context, engineClient *client.Client) (err error) {
dag := engineClient.Dagger()
ref, _, err := getModuleRef(ctx, dag)
if err != nil {
return fmt.Errorf("failed to get module: %w", err)
}
moduleDir, err := ref.LocalSourcePath()
if err != nil {
return fmt.Errorf("module use is only supported for local modules")
}
modCfg, err := ref.Config(ctx, dag)
if err != nil {
return fmt.Errorf("failed to get module config: %w", err)
}
if err := modCfg.Use(ctx, dag, ref, extraArgs...); err != nil { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,066 | dagger mod publish should switch to `PUT /crawl` instead of `GET /crawl` | There has been a recent change - 7pm GMT on Nov. 5, 2023 - in the <https://daggerverse.dev> route that publishes a module.
It used to be `GET /crawl`. It is not `PUT /crawl`. This private PR has more details: https://github.com/dagger/dagger.io/pull/3058#issuecomment-1793819422
This is a reminder that we need to change the route that `dagger mod publish` uses & also cut a new release.
As a temporary workaround publish directly from <https://daggerverse.dev> instead.
I will be travelling & will not have internet for the next 10 hours. Unless someone else doesn't beat me to it - @vito @sipsma @jedevc @helderco @marcosnils @aluzzardi - I will look into this when I get on the other side.
π« | https://github.com/dagger/dagger/issues/6066 | https://github.com/dagger/dagger/pull/6274 | 4d96689943afb13c23f5984dbe19e7967c912a7d | d63f3fb2f14314206d748a25a95abf8e9731bd52 | 2023-11-06T11:07:55Z | go | 2023-12-15T21:29:50Z | cmd/dagger/module.go | return fmt.Errorf("failed to add module dependency: %w", err)
}
return updateModuleConfig(ctx, dag, moduleDir, ref, modCfg, cmd)
})
},
}
var moduleSyncCmd = &cobra.Command{
Use: "sync",
Short: "Synchronize a dagger module with the latest version of its extensions",
Hidden: false,
RunE: func(cmd *cobra.Command, extraArgs []string) (rerr error) {
ctx := cmd.Context()
return withEngineAndTUI(ctx, client.Params{}, func(ctx context.Context, engineClient *client.Client) (err error) {
dag := engineClient.Dagger()
ref, _, err := getModuleRef(ctx, dag)
if err != nil {
return fmt.Errorf("failed to get module: %w", err)
}
moduleDir, err := ref.LocalSourcePath()
if err != nil {
return fmt.Errorf("module sync is only supported for local modules")
}
modCfg, err := ref.Config(ctx, dag)
if err != nil {
return fmt.Errorf("failed to get module config: %w", err)
}
return updateModuleConfig(ctx, dag, moduleDir, ref, modCfg, cmd)
})
},
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,066 | dagger mod publish should switch to `PUT /crawl` instead of `GET /crawl` | There has been a recent change - 7pm GMT on Nov. 5, 2023 - in the <https://daggerverse.dev> route that publishes a module.
It used to be `GET /crawl`. It is not `PUT /crawl`. This private PR has more details: https://github.com/dagger/dagger.io/pull/3058#issuecomment-1793819422
This is a reminder that we need to change the route that `dagger mod publish` uses & also cut a new release.
As a temporary workaround publish directly from <https://daggerverse.dev> instead.
I will be travelling & will not have internet for the next 10 hours. Unless someone else doesn't beat me to it - @vito @sipsma @jedevc @helderco @marcosnils @aluzzardi - I will look into this when I get on the other side.
π« | https://github.com/dagger/dagger/issues/6066 | https://github.com/dagger/dagger/pull/6274 | 4d96689943afb13c23f5984dbe19e7967c912a7d | d63f3fb2f14314206d748a25a95abf8e9731bd52 | 2023-11-06T11:07:55Z | go | 2023-12-15T21:29:50Z | cmd/dagger/module.go | const daDaggerverse = "https:daggerverse.dev"
var modulePublishCmd = &cobra.Command{
Use: "publish",
Short: fmt.Sprintf("Publish your module to The Daggerverse (%s)", daDaggerverse),
Hidden: false,
RunE: func(cmd *cobra.Command, extraArgs []string) (rerr error) {
ctx := cmd.Context()
return withEngineAndTUI(ctx, client.Params{}, func(ctx context.Context, engineClient *client.Client) (err error) {
rec := progrock.FromContext(ctx)
vtx := rec.Vertex("publish", strings.Join(os.Args, " "), progrock.Focused())
defer func() { vtx.Done(err) }()
cmd.SetOut(vtx.Stdout())
cmd.SetErr(vtx.Stderr())
dag := engineClient.Dagger()
ref, _, err := getModuleRef(ctx, dag)
if err != nil {
return fmt.Errorf("failed to get module: %w", err)
}
moduleDir, err := ref.LocalSourcePath()
if err != nil {
return fmt.Errorf("module publish is only supported for local modules")
}
repo, err := git.PlainOpenWithOptions(moduleDir, &git.PlainOpenOptions{
DetectDotGit: true,
})
if err != nil {
return fmt.Errorf("failed to open git repo: %w", err)
}
wt, err := repo.Worktree()
if err != nil { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,066 | dagger mod publish should switch to `PUT /crawl` instead of `GET /crawl` | There has been a recent change - 7pm GMT on Nov. 5, 2023 - in the <https://daggerverse.dev> route that publishes a module.
It used to be `GET /crawl`. It is not `PUT /crawl`. This private PR has more details: https://github.com/dagger/dagger.io/pull/3058#issuecomment-1793819422
This is a reminder that we need to change the route that `dagger mod publish` uses & also cut a new release.
As a temporary workaround publish directly from <https://daggerverse.dev> instead.
I will be travelling & will not have internet for the next 10 hours. Unless someone else doesn't beat me to it - @vito @sipsma @jedevc @helderco @marcosnils @aluzzardi - I will look into this when I get on the other side.
π« | https://github.com/dagger/dagger/issues/6066 | https://github.com/dagger/dagger/pull/6274 | 4d96689943afb13c23f5984dbe19e7967c912a7d | d63f3fb2f14314206d748a25a95abf8e9731bd52 | 2023-11-06T11:07:55Z | go | 2023-12-15T21:29:50Z | cmd/dagger/module.go | return fmt.Errorf("failed to get git worktree: %w", err)
}
st, err := wt.Status()
if err != nil {
return fmt.Errorf("failed to get git status: %w", err)
}
head, err := repo.Head()
if err != nil {
return fmt.Errorf("failed to get git HEAD: %w", err)
}
commit := head.Hash()
rec.Debug("git commit", progrock.Labelf("commit", commit.String()))
orig, err := repo.Remote("origin")
if err != nil {
return fmt.Errorf("failed to get git remote: %w", err)
}
refPath, err := originToPath(orig.Config().URLs[0])
if err != nil {
return fmt.Errorf("failed to get module path: %w", err)
}
gitRoot := wt.Filesystem.Root()
absModDir, err := filepath.Abs(moduleDir)
if err != nil {
return fmt.Errorf("failed to get absolute module dir: %w", err)
}
pathFromRoot, err := filepath.Rel(gitRoot, absModDir)
if err != nil {
return fmt.Errorf("failed to get path from git root: %w", err)
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,066 | dagger mod publish should switch to `PUT /crawl` instead of `GET /crawl` | There has been a recent change - 7pm GMT on Nov. 5, 2023 - in the <https://daggerverse.dev> route that publishes a module.
It used to be `GET /crawl`. It is not `PUT /crawl`. This private PR has more details: https://github.com/dagger/dagger.io/pull/3058#issuecomment-1793819422
This is a reminder that we need to change the route that `dagger mod publish` uses & also cut a new release.
As a temporary workaround publish directly from <https://daggerverse.dev> instead.
I will be travelling & will not have internet for the next 10 hours. Unless someone else doesn't beat me to it - @vito @sipsma @jedevc @helderco @marcosnils @aluzzardi - I will look into this when I get on the other side.
π« | https://github.com/dagger/dagger/issues/6066 | https://github.com/dagger/dagger/pull/6274 | 4d96689943afb13c23f5984dbe19e7967c912a7d | d63f3fb2f14314206d748a25a95abf8e9731bd52 | 2023-11-06T11:07:55Z | go | 2023-12-15T21:29:50Z | cmd/dagger/module.go | if !st.IsClean() && !force {
cmd.Println(st)
return fmt.Errorf("git repository is not clean; run with --force to ignore")
}
refStr := fmt.Sprintf("%s@%s", path.Join(refPath, pathFromRoot), commit)
cmd.Println("publishing", refStr, "to", daDaggerverse)
modURL, err := url.JoinPath(daDaggerverse, "mod", refStr)
if err != nil {
return fmt.Errorf("failed to get module URL: %w", err)
}
res, err := http.Get(modURL)
if err != nil {
return fmt.Errorf("failed to get module: %w", err)
}
cmd.Printf("published to %s", modURL)
return res.Body.Close()
})
},
}
func originToPath(origin string) (string, error) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,066 | dagger mod publish should switch to `PUT /crawl` instead of `GET /crawl` | There has been a recent change - 7pm GMT on Nov. 5, 2023 - in the <https://daggerverse.dev> route that publishes a module.
It used to be `GET /crawl`. It is not `PUT /crawl`. This private PR has more details: https://github.com/dagger/dagger.io/pull/3058#issuecomment-1793819422
This is a reminder that we need to change the route that `dagger mod publish` uses & also cut a new release.
As a temporary workaround publish directly from <https://daggerverse.dev> instead.
I will be travelling & will not have internet for the next 10 hours. Unless someone else doesn't beat me to it - @vito @sipsma @jedevc @helderco @marcosnils @aluzzardi - I will look into this when I get on the other side.
π« | https://github.com/dagger/dagger/issues/6066 | https://github.com/dagger/dagger/pull/6274 | 4d96689943afb13c23f5984dbe19e7967c912a7d | d63f3fb2f14314206d748a25a95abf8e9731bd52 | 2023-11-06T11:07:55Z | go | 2023-12-15T21:29:50Z | cmd/dagger/module.go | url, err := gitutil.ParseURL(origin)
if err != nil {
return "", fmt.Errorf("failed to parse git remote origin URL: %w", err)
}
return strings.TrimSuffix(path.Join(url.Host, url.Path), ".git"), nil
}
func updateModuleConfig(
ctx context.Context,
dag *dagger.Client,
moduleDir string,
modFlag *modules.Ref,
modCfg *modules.Config,
cmd *cobra.Command,
) (rerr error) {
rec := progrock.FromContext(ctx)
configPath := filepath.Join(moduleDir, modules.Filename)
cfgBytes, err := json.MarshalIndent(modCfg, "", " ")
if err != nil {
return fmt.Errorf("failed to marshal module config: %w", err)
}
_, parentDirStatErr := os.Stat(moduleDir)
switch {
case parentDirStatErr == nil:
case os.IsNotExist(parentDirStatErr): |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,066 | dagger mod publish should switch to `PUT /crawl` instead of `GET /crawl` | There has been a recent change - 7pm GMT on Nov. 5, 2023 - in the <https://daggerverse.dev> route that publishes a module.
It used to be `GET /crawl`. It is not `PUT /crawl`. This private PR has more details: https://github.com/dagger/dagger.io/pull/3058#issuecomment-1793819422
This is a reminder that we need to change the route that `dagger mod publish` uses & also cut a new release.
As a temporary workaround publish directly from <https://daggerverse.dev> instead.
I will be travelling & will not have internet for the next 10 hours. Unless someone else doesn't beat me to it - @vito @sipsma @jedevc @helderco @marcosnils @aluzzardi - I will look into this when I get on the other side.
π« | https://github.com/dagger/dagger/issues/6066 | https://github.com/dagger/dagger/pull/6274 | 4d96689943afb13c23f5984dbe19e7967c912a7d | d63f3fb2f14314206d748a25a95abf8e9731bd52 | 2023-11-06T11:07:55Z | go | 2023-12-15T21:29:50Z | cmd/dagger/module.go | if err := os.MkdirAll(moduleDir, 0o755); err != nil {
return fmt.Errorf("failed to create module config directory: %w", err)
}
defer func() {
if rerr != nil {
os.RemoveAll(moduleDir)
}
}()
default:
return fmt.Errorf("failed to stat parent directory: %w", parentDirStatErr)
}
var cfgFileMode os.FileMode = 0o644
originalContents, configFileReadErr := os.ReadFile(configPath)
switch {
case configFileReadErr == nil:
stat, err := os.Stat(configPath)
if err != nil {
return fmt.Errorf("failed to stat module config: %w", err)
}
cfgFileMode = stat.Mode()
defer func() {
if rerr != nil {
os.WriteFile(configPath, originalContents, cfgFileMode)
}
}()
case os.IsNotExist(configFileReadErr):
defer func() { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,066 | dagger mod publish should switch to `PUT /crawl` instead of `GET /crawl` | There has been a recent change - 7pm GMT on Nov. 5, 2023 - in the <https://daggerverse.dev> route that publishes a module.
It used to be `GET /crawl`. It is not `PUT /crawl`. This private PR has more details: https://github.com/dagger/dagger.io/pull/3058#issuecomment-1793819422
This is a reminder that we need to change the route that `dagger mod publish` uses & also cut a new release.
As a temporary workaround publish directly from <https://daggerverse.dev> instead.
I will be travelling & will not have internet for the next 10 hours. Unless someone else doesn't beat me to it - @vito @sipsma @jedevc @helderco @marcosnils @aluzzardi - I will look into this when I get on the other side.
π« | https://github.com/dagger/dagger/issues/6066 | https://github.com/dagger/dagger/pull/6274 | 4d96689943afb13c23f5984dbe19e7967c912a7d | d63f3fb2f14314206d748a25a95abf8e9731bd52 | 2023-11-06T11:07:55Z | go | 2023-12-15T21:29:50Z | cmd/dagger/module.go | if rerr != nil {
os.Remove(configPath)
}
}()
default:
return fmt.Errorf("failed to read module config: %w", configFileReadErr)
}
if err := os.WriteFile(configPath, append(cfgBytes, '\n'), cfgFileMode); err != nil {
return fmt.Errorf("failed to write module config: %w", err)
}
mod, err := modFlag.AsModule(ctx, dag)
if err != nil {
return fmt.Errorf("failed to load module: %w", err)
}
codegen := mod.GeneratedCode()
if err := automateVCS(ctx, moduleDir, codegen); err != nil {
return fmt.Errorf("failed to automate vcs: %w", err)
}
entries, err := codegen.Code().Entries(ctx)
if err != nil {
return fmt.Errorf("failed to get codegen output entries: %w", err)
}
rec.Debug("syncing generated files", progrock.Labelf("entries", "%v", entries))
if _, err := codegen.Code().Export(ctx, moduleDir); err != nil {
return fmt.Errorf("failed to export codegen output: %w", err)
}
return nil
}
func getModuleRef(ctx context.Context, dag *dagger.Client) (*modules.Ref, bool, error) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,066 | dagger mod publish should switch to `PUT /crawl` instead of `GET /crawl` | There has been a recent change - 7pm GMT on Nov. 5, 2023 - in the <https://daggerverse.dev> route that publishes a module.
It used to be `GET /crawl`. It is not `PUT /crawl`. This private PR has more details: https://github.com/dagger/dagger.io/pull/3058#issuecomment-1793819422
This is a reminder that we need to change the route that `dagger mod publish` uses & also cut a new release.
As a temporary workaround publish directly from <https://daggerverse.dev> instead.
I will be travelling & will not have internet for the next 10 hours. Unless someone else doesn't beat me to it - @vito @sipsma @jedevc @helderco @marcosnils @aluzzardi - I will look into this when I get on the other side.
π« | https://github.com/dagger/dagger/issues/6066 | https://github.com/dagger/dagger/pull/6274 | 4d96689943afb13c23f5984dbe19e7967c912a7d | d63f3fb2f14314206d748a25a95abf8e9731bd52 | 2023-11-06T11:07:55Z | go | 2023-12-15T21:29:50Z | cmd/dagger/module.go | wasSet := false
moduleURL := moduleURL
if moduleURL == "" {
if v, ok := os.LookupEnv("DAGGER_MODULE"); ok {
moduleURL = v
wasSet = true
}
if moduleURL == "" {
moduleURL = moduleURLDefault
}
} else {
wasSet = true
}
cfg, err := modules.ResolveMovingRef(ctx, dag, moduleURL)
return cfg, wasSet, err
}
func loadModCmdWrapper( |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,066 | dagger mod publish should switch to `PUT /crawl` instead of `GET /crawl` | There has been a recent change - 7pm GMT on Nov. 5, 2023 - in the <https://daggerverse.dev> route that publishes a module.
It used to be `GET /crawl`. It is not `PUT /crawl`. This private PR has more details: https://github.com/dagger/dagger.io/pull/3058#issuecomment-1793819422
This is a reminder that we need to change the route that `dagger mod publish` uses & also cut a new release.
As a temporary workaround publish directly from <https://daggerverse.dev> instead.
I will be travelling & will not have internet for the next 10 hours. Unless someone else doesn't beat me to it - @vito @sipsma @jedevc @helderco @marcosnils @aluzzardi - I will look into this when I get on the other side.
π« | https://github.com/dagger/dagger/issues/6066 | https://github.com/dagger/dagger/pull/6274 | 4d96689943afb13c23f5984dbe19e7967c912a7d | d63f3fb2f14314206d748a25a95abf8e9731bd52 | 2023-11-06T11:07:55Z | go | 2023-12-15T21:29:50Z | cmd/dagger/module.go | fn func(context.Context, *client.Client, *dagger.Module, *cobra.Command, []string) error,
presetSecretToken string,
) func(*cobra.Command, []string) error {
return func(cmd *cobra.Command, cmdArgs []string) error {
return withEngineAndTUI(cmd.Context(), client.Params{
SecretToken: presetSecretToken,
}, func(ctx context.Context, engineClient *client.Client) (err error) {
rec := progrock.FromContext(ctx)
vtx := rec.Vertex("cmd-loader", strings.Join(os.Args, " "))
defer func() { vtx.Done(err) }()
load := vtx.Task("loading module")
loadedMod, err := loadMod(ctx, engineClient.Dagger())
load.Done(err)
if err != nil {
return err
}
return fn(ctx, engineClient, loadedMod, cmd, cmdArgs)
})
}
}
func loadMod(ctx context.Context, c *dagger.Client) (*dagger.Module, error) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,066 | dagger mod publish should switch to `PUT /crawl` instead of `GET /crawl` | There has been a recent change - 7pm GMT on Nov. 5, 2023 - in the <https://daggerverse.dev> route that publishes a module.
It used to be `GET /crawl`. It is not `PUT /crawl`. This private PR has more details: https://github.com/dagger/dagger.io/pull/3058#issuecomment-1793819422
This is a reminder that we need to change the route that `dagger mod publish` uses & also cut a new release.
As a temporary workaround publish directly from <https://daggerverse.dev> instead.
I will be travelling & will not have internet for the next 10 hours. Unless someone else doesn't beat me to it - @vito @sipsma @jedevc @helderco @marcosnils @aluzzardi - I will look into this when I get on the other side.
π« | https://github.com/dagger/dagger/issues/6066 | https://github.com/dagger/dagger/pull/6274 | 4d96689943afb13c23f5984dbe19e7967c912a7d | d63f3fb2f14314206d748a25a95abf8e9731bd52 | 2023-11-06T11:07:55Z | go | 2023-12-15T21:29:50Z | cmd/dagger/module.go | mod, modRequired, err := getModuleRef(ctx, c)
if err != nil {
return nil, fmt.Errorf("failed to get module config: %w", err)
}
if _, err := mod.Config(ctx, c); err != nil {
if !modRequired {
return nil, nil
}
return nil, fmt.Errorf("failed to load module config: %w", err)
}
loadedMod, err := mod.AsModule(ctx, c)
if err != nil {
return nil, fmt.Errorf("failed to load module: %w", err)
}
_, err = loadedMod.Serve(ctx)
if err != nil {
return nil, fmt.Errorf("failed to get loaded module ID: %w", err)
}
return loadedMod, nil
}
func loadModObjects(ctx context.Context, dag *dagger.Client, mod *dagger.Module) (*moduleDef, error) {
var res struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,066 | dagger mod publish should switch to `PUT /crawl` instead of `GET /crawl` | There has been a recent change - 7pm GMT on Nov. 5, 2023 - in the <https://daggerverse.dev> route that publishes a module.
It used to be `GET /crawl`. It is not `PUT /crawl`. This private PR has more details: https://github.com/dagger/dagger.io/pull/3058#issuecomment-1793819422
This is a reminder that we need to change the route that `dagger mod publish` uses & also cut a new release.
As a temporary workaround publish directly from <https://daggerverse.dev> instead.
I will be travelling & will not have internet for the next 10 hours. Unless someone else doesn't beat me to it - @vito @sipsma @jedevc @helderco @marcosnils @aluzzardi - I will look into this when I get on the other side.
π« | https://github.com/dagger/dagger/issues/6066 | https://github.com/dagger/dagger/pull/6274 | 4d96689943afb13c23f5984dbe19e7967c912a7d | d63f3fb2f14314206d748a25a95abf8e9731bd52 | 2023-11-06T11:07:55Z | go | 2023-12-15T21:29:50Z | cmd/dagger/module.go | Module *moduleDef
}
err := dag.Do(ctx, &dagger.Request{
Query: `
query Objects($module: ModuleID!) {
module: loadModuleFromID(id: $module) {
name
objects {
asObject {
name
constructor {
returnType {
kind
asObject {
name
}
}
args {
name
description
defaultValue
typeDef {
kind
optional
asObject {
name
}
asList { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,066 | dagger mod publish should switch to `PUT /crawl` instead of `GET /crawl` | There has been a recent change - 7pm GMT on Nov. 5, 2023 - in the <https://daggerverse.dev> route that publishes a module.
It used to be `GET /crawl`. It is not `PUT /crawl`. This private PR has more details: https://github.com/dagger/dagger.io/pull/3058#issuecomment-1793819422
This is a reminder that we need to change the route that `dagger mod publish` uses & also cut a new release.
As a temporary workaround publish directly from <https://daggerverse.dev> instead.
I will be travelling & will not have internet for the next 10 hours. Unless someone else doesn't beat me to it - @vito @sipsma @jedevc @helderco @marcosnils @aluzzardi - I will look into this when I get on the other side.
π« | https://github.com/dagger/dagger/issues/6066 | https://github.com/dagger/dagger/pull/6274 | 4d96689943afb13c23f5984dbe19e7967c912a7d | d63f3fb2f14314206d748a25a95abf8e9731bd52 | 2023-11-06T11:07:55Z | go | 2023-12-15T21:29:50Z | cmd/dagger/module.go | elementTypeDef {
kind
asObject {
name
}
}
}
}
}
}
functions {
name
description
returnType {
kind
asObject {
name
}
asList {
elementTypeDef {
kind
asObject {
name
}
}
}
}
args {
name
description |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,066 | dagger mod publish should switch to `PUT /crawl` instead of `GET /crawl` | There has been a recent change - 7pm GMT on Nov. 5, 2023 - in the <https://daggerverse.dev> route that publishes a module.
It used to be `GET /crawl`. It is not `PUT /crawl`. This private PR has more details: https://github.com/dagger/dagger.io/pull/3058#issuecomment-1793819422
This is a reminder that we need to change the route that `dagger mod publish` uses & also cut a new release.
As a temporary workaround publish directly from <https://daggerverse.dev> instead.
I will be travelling & will not have internet for the next 10 hours. Unless someone else doesn't beat me to it - @vito @sipsma @jedevc @helderco @marcosnils @aluzzardi - I will look into this when I get on the other side.
π« | https://github.com/dagger/dagger/issues/6066 | https://github.com/dagger/dagger/pull/6274 | 4d96689943afb13c23f5984dbe19e7967c912a7d | d63f3fb2f14314206d748a25a95abf8e9731bd52 | 2023-11-06T11:07:55Z | go | 2023-12-15T21:29:50Z | cmd/dagger/module.go | defaultValue
typeDef {
kind
optional
asObject {
name
}
asList {
elementTypeDef {
kind
asObject {
name
}
}
}
}
}
}
fields {
name
description
typeDef {
kind
optional
asObject {
name
}
asList {
elementTypeDef {
kind |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,066 | dagger mod publish should switch to `PUT /crawl` instead of `GET /crawl` | There has been a recent change - 7pm GMT on Nov. 5, 2023 - in the <https://daggerverse.dev> route that publishes a module.
It used to be `GET /crawl`. It is not `PUT /crawl`. This private PR has more details: https://github.com/dagger/dagger.io/pull/3058#issuecomment-1793819422
This is a reminder that we need to change the route that `dagger mod publish` uses & also cut a new release.
As a temporary workaround publish directly from <https://daggerverse.dev> instead.
I will be travelling & will not have internet for the next 10 hours. Unless someone else doesn't beat me to it - @vito @sipsma @jedevc @helderco @marcosnils @aluzzardi - I will look into this when I get on the other side.
π« | https://github.com/dagger/dagger/issues/6066 | https://github.com/dagger/dagger/pull/6274 | 4d96689943afb13c23f5984dbe19e7967c912a7d | d63f3fb2f14314206d748a25a95abf8e9731bd52 | 2023-11-06T11:07:55Z | go | 2023-12-15T21:29:50Z | cmd/dagger/module.go | asObject {
name
}
}
}
}
}
}
}
}
}
`,
Variables: map[string]interface{}{
"module": mod,
},
}, &dagger.Response{
Data: &res,
})
if err != nil {
err = fmt.Errorf("query module objects: %w", err)
}
return res.Module, err
}
type moduleDef struct {
Name string
Objects []*modTypeDef
}
func (m *moduleDef) AsObjects() []*modObject {
var defs []*modObject
for _, typeDef := range m.Objects { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,066 | dagger mod publish should switch to `PUT /crawl` instead of `GET /crawl` | There has been a recent change - 7pm GMT on Nov. 5, 2023 - in the <https://daggerverse.dev> route that publishes a module.
It used to be `GET /crawl`. It is not `PUT /crawl`. This private PR has more details: https://github.com/dagger/dagger.io/pull/3058#issuecomment-1793819422
This is a reminder that we need to change the route that `dagger mod publish` uses & also cut a new release.
As a temporary workaround publish directly from <https://daggerverse.dev> instead.
I will be travelling & will not have internet for the next 10 hours. Unless someone else doesn't beat me to it - @vito @sipsma @jedevc @helderco @marcosnils @aluzzardi - I will look into this when I get on the other side.
π« | https://github.com/dagger/dagger/issues/6066 | https://github.com/dagger/dagger/pull/6274 | 4d96689943afb13c23f5984dbe19e7967c912a7d | d63f3fb2f14314206d748a25a95abf8e9731bd52 | 2023-11-06T11:07:55Z | go | 2023-12-15T21:29:50Z | cmd/dagger/module.go | if typeDef.AsObject != nil {
defs = append(defs, typeDef.AsObject)
}
}
return defs
}
func (m *moduleDef) GetObject(name string) *modObject {
for _, obj := range m.AsObjects() {
if gqlObjectName(obj.Name) == gqlObjectName(name) {
return obj
}
}
return nil
}
func (m *moduleDef) GetMainObject() *modObject {
return m.GetObject(m.Name)
}
func (m *moduleDef) LoadObject(typeDef *modTypeDef) {
if typeDef.AsObject != nil && typeDef.AsObject.Functions == nil && typeDef.AsObject.Fields == nil {
obj := m.GetObject(typeDef.AsObject.Name)
if obj != nil {
typeDef.AsObject = obj
}
}
if typeDef.AsList != nil {
m.LoadObject(typeDef.AsList.ElementTypeDef)
}
}
type modTypeDef struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,066 | dagger mod publish should switch to `PUT /crawl` instead of `GET /crawl` | There has been a recent change - 7pm GMT on Nov. 5, 2023 - in the <https://daggerverse.dev> route that publishes a module.
It used to be `GET /crawl`. It is not `PUT /crawl`. This private PR has more details: https://github.com/dagger/dagger.io/pull/3058#issuecomment-1793819422
This is a reminder that we need to change the route that `dagger mod publish` uses & also cut a new release.
As a temporary workaround publish directly from <https://daggerverse.dev> instead.
I will be travelling & will not have internet for the next 10 hours. Unless someone else doesn't beat me to it - @vito @sipsma @jedevc @helderco @marcosnils @aluzzardi - I will look into this when I get on the other side.
π« | https://github.com/dagger/dagger/issues/6066 | https://github.com/dagger/dagger/pull/6274 | 4d96689943afb13c23f5984dbe19e7967c912a7d | d63f3fb2f14314206d748a25a95abf8e9731bd52 | 2023-11-06T11:07:55Z | go | 2023-12-15T21:29:50Z | cmd/dagger/module.go | Kind dagger.TypeDefKind
Optional bool
AsObject *modObject
AsList *modList
}
func (t *modTypeDef) ObjectName() string {
if t.AsObject != nil {
return t.AsObject.Name
}
return ""
}
type modObject struct {
Name string
Functions []*modFunction
Fields []*modField
Constructor *modFunction
}
func (o *modObject) GetFunctions() []*modFunction {
fns := make([]*modFunction, 0, len(o.Functions)+len(o.Fields))
for _, f := range o.Fields {
fns = append(fns, &modFunction{
Name: f.Name,
Description: f.Description,
ReturnType: f.TypeDef,
})
}
fns = append(fns, o.Functions...)
return fns
}
type modList struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,066 | dagger mod publish should switch to `PUT /crawl` instead of `GET /crawl` | There has been a recent change - 7pm GMT on Nov. 5, 2023 - in the <https://daggerverse.dev> route that publishes a module.
It used to be `GET /crawl`. It is not `PUT /crawl`. This private PR has more details: https://github.com/dagger/dagger.io/pull/3058#issuecomment-1793819422
This is a reminder that we need to change the route that `dagger mod publish` uses & also cut a new release.
As a temporary workaround publish directly from <https://daggerverse.dev> instead.
I will be travelling & will not have internet for the next 10 hours. Unless someone else doesn't beat me to it - @vito @sipsma @jedevc @helderco @marcosnils @aluzzardi - I will look into this when I get on the other side.
π« | https://github.com/dagger/dagger/issues/6066 | https://github.com/dagger/dagger/pull/6274 | 4d96689943afb13c23f5984dbe19e7967c912a7d | d63f3fb2f14314206d748a25a95abf8e9731bd52 | 2023-11-06T11:07:55Z | go | 2023-12-15T21:29:50Z | cmd/dagger/module.go | ElementTypeDef *modTypeDef
}
type modField struct {
Name string
Description string
TypeDef *modTypeDef
}
type modFunction struct {
Name string
Description string
ReturnType *modTypeDef
Args []*modFunctionArg
}
type modFunctionArg struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,066 | dagger mod publish should switch to `PUT /crawl` instead of `GET /crawl` | There has been a recent change - 7pm GMT on Nov. 5, 2023 - in the <https://daggerverse.dev> route that publishes a module.
It used to be `GET /crawl`. It is not `PUT /crawl`. This private PR has more details: https://github.com/dagger/dagger.io/pull/3058#issuecomment-1793819422
This is a reminder that we need to change the route that `dagger mod publish` uses & also cut a new release.
As a temporary workaround publish directly from <https://daggerverse.dev> instead.
I will be travelling & will not have internet for the next 10 hours. Unless someone else doesn't beat me to it - @vito @sipsma @jedevc @helderco @marcosnils @aluzzardi - I will look into this when I get on the other side.
π« | https://github.com/dagger/dagger/issues/6066 | https://github.com/dagger/dagger/pull/6274 | 4d96689943afb13c23f5984dbe19e7967c912a7d | d63f3fb2f14314206d748a25a95abf8e9731bd52 | 2023-11-06T11:07:55Z | go | 2023-12-15T21:29:50Z | cmd/dagger/module.go | Name string
Description string
TypeDef *modTypeDef
DefaultValue dagger.JSON
flagName string
}
func (r *modFunctionArg) FlagName() string {
if r.flagName == "" {
r.flagName = cliName(r.Name)
}
return r.flagName
}
func getDefaultValue[T any](r *modFunctionArg) (T, error) {
var val T
err := json.Unmarshal([]byte(r.DefaultValue), &val)
return val, err
}
func gqlObjectName(name string) string {
return strcase.ToCamel(name)
}
func gqlFieldName(name string) string {
return strcase.ToLowerCamel(name)
}
func gqlArgName(name string) string {
return strcase.ToLowerCamel(name)
}
func cliName(name string) string {
return strcase.ToKebab(name)
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | package core
import (
"bytes"
_ "embed"
"encoding/base64"
"encoding/json"
"fmt"
"net/http"
"os"
"path"
"path/filepath"
"strconv"
"strings"
"testing"
"github.com/containerd/containerd/platforms"
"github.com/google/go-containerregistry/pkg/name"
"github.com/google/go-containerregistry/pkg/v1/remote"
"github.com/moby/buildkit/identity"
ocispecs "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/stretchr/testify/require"
"gopkg.in/yaml.v3"
"dagger.io/dagger"
"github.com/dagger/dagger/core"
"github.com/dagger/dagger/core/schema"
"github.com/dagger/dagger/engine/buildkit"
"github.com/dagger/dagger/internal/testutil"
)
func TestContainerScratch(t *testing.T) {
t.Parallel()
res := struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | Container struct {
ID string
Rootfs struct {
Entries []string
}
}
}{}
err := testutil.Query(
`{
container {
id
rootfs {
entries
}
}
}`, &res, nil)
require.NoError(t, err)
require.Empty(t, res.Container.Rootfs.Entries)
}
func TestContainerFrom(t *testing.T) {
t.Parallel()
res := struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | Container struct {
From struct {
File struct {
Contents string
}
}
}
}{}
err := testutil.Query(
`{
container {
from(address: "`+alpineImage+`") {
file(path: "/etc/alpine-release") {
contents
}
}
}
}`, &res, nil)
require.NoError(t, err)
require.Equal(t, res.Container.From.File.Contents, "3.18.2\n")
}
func TestContainerBuild(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | c, ctx := connect(t)
contextDir := c.Directory().
WithNewFile("main.go",
`package main
import "fmt"
import "os"
func main() {
for _, env := range os.Environ() {
fmt.Println(env)
}
}`)
t.Run("default Dockerfile location", func(t *testing.T) {
src := contextDir.
WithNewFile("Dockerfile",
`FROM golang:1.18.2-alpine
WORKDIR /src
COPY main.go .
RUN go mod init hello
RUN go build -o /usr/bin/goenv main.go
ENV FOO=bar
CMD goenv
`)
env, err := c.Container().Build(src).Stdout(ctx)
require.NoError(t, err)
require.Contains(t, env, "FOO=bar\n")
})
t.Run("custom Dockerfile location", func(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | src := contextDir.
WithNewFile("subdir/Dockerfile.whee",
`FROM golang:1.18.2-alpine
WORKDIR /src
COPY main.go .
RUN go mod init hello
RUN go build -o /usr/bin/goenv main.go
ENV FOO=bar
CMD goenv
`)
env, err := c.Container().Build(src, dagger.ContainerBuildOpts{
Dockerfile: "subdir/Dockerfile.whee",
}).Stdout(ctx)
require.NoError(t, err)
require.Contains(t, env, "FOO=bar\n")
})
t.Run("subdirectory with default Dockerfile location", func(t *testing.T) {
src := contextDir.
WithNewFile("Dockerfile",
`FROM golang:1.18.2-alpine
WORKDIR /src
COPY main.go .
RUN go mod init hello
RUN go build -o /usr/bin/goenv main.go
ENV FOO=bar
CMD goenv
`)
sub := c.Directory().WithDirectory("subcontext", src).Directory("subcontext")
env, err := c.Container().Build(sub).Stdout(ctx)
require.NoError(t, err) |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | require.Contains(t, env, "FOO=bar\n")
})
t.Run("subdirectory with custom Dockerfile location", func(t *testing.T) {
src := contextDir.
WithNewFile("subdir/Dockerfile.whee",
`FROM golang:1.18.2-alpine
WORKDIR /src
COPY main.go .
RUN go mod init hello
RUN go build -o /usr/bin/goenv main.go
ENV FOO=bar
CMD goenv
`)
sub := c.Directory().WithDirectory("subcontext", src).Directory("subcontext")
env, err := c.Container().Build(sub, dagger.ContainerBuildOpts{
Dockerfile: "subdir/Dockerfile.whee",
}).Stdout(ctx)
require.NoError(t, err)
require.Contains(t, env, "FOO=bar\n")
})
t.Run("with build args", func(t *testing.T) {
src := contextDir.
WithNewFile("Dockerfile",
`FROM golang:1.18.2-alpine
ARG FOOARG=bar
WORKDIR /src
COPY main.go .
RUN go mod init hello
RUN go build -o /usr/bin/goenv main.go
ENV FOO=$FOOARG |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | CMD goenv
`)
env, err := c.Container().Build(src).Stdout(ctx)
require.NoError(t, err)
require.Contains(t, env, "FOO=bar\n")
env, err = c.Container().Build(src, dagger.ContainerBuildOpts{BuildArgs: []dagger.BuildArg{{Name: "FOOARG", Value: "barbar"}}}).Stdout(ctx)
require.NoError(t, err)
require.Contains(t, env, "FOO=barbar\n")
})
t.Run("with target", func(t *testing.T) {
src := contextDir.
WithNewFile("Dockerfile",
`FROM golang:1.18.2-alpine AS base
CMD echo "base"
FROM base AS stage1
CMD echo "stage1"
FROM base AS stage2
CMD echo "stage2"
`)
output, err := c.Container().Build(src).Stdout(ctx)
require.NoError(t, err)
require.Contains(t, output, "stage2\n")
output, err = c.Container().Build(src, dagger.ContainerBuildOpts{Target: "stage1"}).Stdout(ctx)
require.NoError(t, err)
require.Contains(t, output, "stage1\n")
require.NotContains(t, output, "stage2\n")
})
t.Run("with build secrets", func(t *testing.T) {
sec := c.SetSecret("my-secret", "barbar")
src := contextDir. |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | WithNewFile("Dockerfile",
`FROM golang:1.18.2-alpine
WORKDIR /src
RUN --mount=type=secret,id=my-secret test "$(cat /run/secrets/my-secret)" = "barbar"
RUN --mount=type=secret,id=my-secret cp /run/secrets/my-secret /secret
CMD cat /secret
`)
stdout, err := c.Container().Build(src, dagger.ContainerBuildOpts{
Secrets: []*dagger.Secret{sec},
}).Stdout(ctx)
require.NoError(t, err)
require.Contains(t, stdout, "***")
})
t.Run("just build, don't execute", func(t *testing.T) {
src := contextDir.
WithNewFile("Dockerfile", "FROM "+alpineImage+"\nCMD false")
_, err := c.Container().Build(src).Sync(ctx)
require.NoError(t, err)
_, err = c.Container().Build(src).WithExec(nil).Sync(ctx)
require.NotEmpty(t, err)
})
t.Run("just build, short-circuit", func(t *testing.T) {
src := contextDir.
WithNewFile("Dockerfile", "FROM "+alpineImage+"\nRUN false")
_, err := c.Container().Build(src).Sync(ctx)
require.NotEmpty(t, err)
})
}
func TestContainerWithRootFS(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | t.Parallel()
c, ctx := connect(t)
alpine316 := c.Container().From(alpineImage)
alpine316ReleaseStr, err := alpine316.File("/etc/alpine-release").Contents(ctx)
require.NoError(t, err)
alpine316ReleaseStr = strings.TrimSpace(alpine316ReleaseStr)
dir := alpine316.Rootfs()
_, err = c.Container().WithEnvVariable("ALPINE_RELEASE", alpine316ReleaseStr).WithRootfs(dir).WithExec([]string{
"/bin/sh",
"-c",
"test -f /etc/alpine-release && test \"$(head -n 1 /etc/alpine-release)\" = \"$ALPINE_RELEASE\"",
}).Sync(ctx)
require.NoError(t, err)
alpine315 := c.Container().From(alpineImage)
varVal := "testing123"
alpine315WithVar := alpine315.WithEnvVariable("DAGGER_TEST", varVal)
varValResp, err := alpine315WithVar.EnvVariable(ctx, "DAGGER_TEST")
require.NoError(t, err)
require.Equal(t, varVal, varValResp)
alpine315ReplacedFS := alpine315WithVar.WithRootfs(dir)
varValResp, err = alpine315ReplacedFS.EnvVariable(ctx, "DAGGER_TEST")
require.NoError(t, err)
require.Equal(t, varVal, varValResp)
releaseStr, err := alpine315ReplacedFS.File("/etc/alpine-release").Contents(ctx)
require.NoError(t, err)
require.Equal(t, "3.18.2\n", releaseStr)
}
var helloSrc string
func TestContainerWithRootFSSubdir(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | t.Parallel()
c, ctx := connect(t)
hello := c.Directory().WithNewFile("main.go", helloSrc).File("main.go")
ctr := c.Container().
From(golangImage).
WithMountedFile("/src/main.go", hello).
WithEnvVariable("CGO_ENABLED", "0").
WithExec([]string{"go", "build", "-o", "/out/hello", "/src/main.go"})
out, err := c.Container().
WithRootfs(ctr.Directory("/out")).
WithExec([]string{"/hello"}).
Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "Hello, world!\n", out)
}
func TestContainerExecSync(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | t.Parallel()
err := testutil.Query(
`{
container {
from(address: "`+alpineImage+`") {
withExec(args: ["false"]) {
sync
}
}
}
}`, nil, nil)
require.Contains(t, err.Error(), `process "false" did not complete successfully`)
}
func TestContainerExecStdoutStderr(t *testing.T) {
t.Parallel()
res := struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | Container struct {
From struct {
WithExec struct {
Stdout string
Stderr string
}
}
}
}{}
err := testutil.Query(
`{
container {
from(address: "`+alpineImage+`") {
withExec(args: ["sh", "-c", "echo hello; echo goodbye >/dev/stderr"]) {
stdout
stderr
}
}
}
}`, &res, nil)
require.NoError(t, err)
require.Equal(t, res.Container.From.WithExec.Stdout, "hello\n")
require.Equal(t, res.Container.From.WithExec.Stderr, "goodbye\n")
}
func TestContainerExecStdin(t *testing.T) {
t.Parallel()
res := struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | Container struct {
From struct {
WithExec struct {
Stdout string
}
}
}
}{}
err := testutil.Query(
`{
container {
from(address: "`+alpineImage+`") {
withExec(args: ["cat"], stdin: "hello") {
stdout
}
}
}
}`, &res, nil)
require.NoError(t, err)
require.Equal(t, res.Container.From.WithExec.Stdout, "hello")
}
func TestContainerExecRedirectStdoutStderr(t *testing.T) {
t.Parallel()
res := struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | Container struct {
From struct {
WithExec struct {
Out, Err struct {
Contents string
}
}
}
}
}{}
err := testutil.Query(
`{
container {
from(address: "`+alpineImage+`") {
withExec(
args: ["sh", "-c", "echo hello; echo goodbye >/dev/stderr"],
redirectStdout: "out",
redirectStderr: "err"
) {
out: file(path: "out") {
contents
}
err: file(path: "err") {
contents
}
}
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | }
}`, &res, nil)
require.NoError(t, err)
require.Equal(t, res.Container.From.WithExec.Out.Contents, "hello\n")
require.Equal(t, res.Container.From.WithExec.Err.Contents, "goodbye\n")
c, ctx := connect(t)
execWithMount := c.Container().From(alpineImage).
WithMountedDirectory("/mnt", c.Directory()).
WithExec([]string{"sh", "-c", "echo hello; echo goodbye >/dev/stderr"}, dagger.ContainerWithExecOpts{
RedirectStdout: "/mnt/out",
RedirectStderr: "/mnt/err",
})
stdout, err := execWithMount.File("/mnt/out").Contents(ctx)
require.NoError(t, err)
require.Equal(t, "hello\n", stdout)
stderr, err := execWithMount.File("/mnt/err").Contents(ctx)
require.NoError(t, err)
require.Equal(t, "goodbye\n", stderr)
_, err = execWithMount.Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "hello\n", stdout)
_, err = execWithMount.Stderr(ctx)
require.NoError(t, err)
require.Equal(t, "goodbye\n", stderr)
}
func TestContainerExecWithWorkdir(t *testing.T) {
t.Parallel()
res := struct {
Container struct {
From struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | WithWorkdir struct {
WithExec struct {
Stdout string
}
}
}
}
}{}
err := testutil.Query(
`{
container {
from(address: "`+alpineImage+`") {
withWorkdir(path: "/usr") {
withExec(args: ["pwd"]) {
stdout
}
}
}
}
}`, &res, nil)
require.NoError(t, err)
require.Equal(t, res.Container.From.WithWorkdir.WithExec.Stdout, "/usr\n")
}
func TestContainerExecWithUser(t *testing.T) {
t.Parallel()
res := struct {
Container struct {
From struct {
User string
WithUser struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | User string
WithExec struct {
Stdout string
}
}
}
}
}{}
t.Run("user name", func(t *testing.T) {
err := testutil.Query(
`{
container {
from(address: "`+alpineImage+`") {
user
withUser(name: "daemon") {
user
withExec(args: ["whoami"]) {
stdout
}
}
}
}
}`, &res, nil)
require.NoError(t, err)
require.Equal(t, "", res.Container.From.User)
require.Equal(t, "daemon", res.Container.From.WithUser.User)
require.Equal(t, "daemon\n", res.Container.From.WithUser.WithExec.Stdout)
})
t.Run("user and group name", func(t *testing.T) {
err := testutil.Query( |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | `{
container {
from(address: "`+alpineImage+`") {
user
withUser(name: "daemon:floppy") {
user
withExec(args: ["sh", "-c", "whoami; groups"]) {
stdout
}
}
}
}
}`, &res, nil)
require.NoError(t, err)
require.Equal(t, "", res.Container.From.User)
require.Equal(t, "daemon:floppy", res.Container.From.WithUser.User)
require.Equal(t, "daemon\nfloppy\n", res.Container.From.WithUser.WithExec.Stdout)
})
t.Run("user ID", func(t *testing.T) {
err := testutil.Query(
`{
container {
from(address: "`+alpineImage+`") {
user
withUser(name: "2") {
user
withExec(args: ["whoami"]) {
stdout
}
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | }
}
}`, &res, nil)
require.NoError(t, err)
require.Equal(t, "", res.Container.From.User)
require.Equal(t, "2", res.Container.From.WithUser.User)
require.Equal(t, "daemon\n", res.Container.From.WithUser.WithExec.Stdout)
})
t.Run("user and group ID", func(t *testing.T) {
err := testutil.Query(
`{
container {
from(address: "`+alpineImage+`") {
user
withUser(name: "2:11") {
user
withExec(args: ["sh", "-c", "whoami; groups"]) {
stdout
}
}
}
}
}`, &res, nil)
require.NoError(t, err)
require.Equal(t, "", res.Container.From.User)
require.Equal(t, "2:11", res.Container.From.WithUser.User)
require.Equal(t, "daemon\nfloppy\n", res.Container.From.WithUser.WithExec.Stdout)
})
}
func TestContainerExecWithEntrypoint(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | t.Parallel()
c, ctx := connect(t)
base := c.Container().From(alpineImage)
before, err := base.Entrypoint(ctx)
require.NoError(t, err)
require.Empty(t, before)
withEntry := base.WithEntrypoint([]string{"sh"})
after, err := withEntry.Entrypoint(ctx)
require.NoError(t, err)
require.Equal(t, []string{"sh"}, after)
used, err := withEntry.WithExec([]string{"-c", "echo $HOME"}).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "/root\n", used)
_, err = withEntry.WithExec([]string{"sh", "-c", "echo $HOME"}).Sync(ctx)
require.Error(t, err)
skipped, err := withEntry.WithExec([]string{"sh", "-c", "echo $HOME"}, dagger.ContainerWithExecOpts{
SkipEntrypoint: true,
}).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "/root\n", skipped)
withoutEntry := withEntry.WithEntrypoint(nil)
removed, err := withoutEntry.Entrypoint(ctx)
require.NoError(t, err)
require.Empty(t, removed)
}
func TestContainerWithDefaultArgs(t *testing.T) {
t.Parallel()
res := struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | Container struct {
From struct {
Entrypoint []string
DefaultArgs []string
WithExec struct {
Stdout string
}
WithDefaultArgs struct {
Entrypoint []string
DefaultArgs []string
}
WithEntrypoint struct {
Entrypoint []string
DefaultArgs []string
WithExec struct {
Stdout string
}
WithDefaultArgs struct {
Entrypoint []string
DefaultArgs []string
WithExec struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | Stdout string
}
}
}
}
}
}{}
err := testutil.Query(
`{
container {
from(address: "`+alpineImage+`") {
entrypoint
defaultArgs
withDefaultArgs {
entrypoint
defaultArgs
}
withEntrypoint(args: ["sh", "-c"]) {
entrypoint
defaultArgs
withExec(args: ["echo $HOME"]) {
stdout
}
withDefaultArgs(args: ["id"]) {
entrypoint
defaultArgs
withExec(args: []) {
stdout
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | }
}
}
}
}`, &res, nil)
t.Run("default alpine (no entrypoint)", func(t *testing.T) {
require.NoError(t, err)
require.Empty(t, res.Container.From.Entrypoint)
require.Equal(t, []string{"/bin/sh"}, res.Container.From.DefaultArgs)
})
t.Run("with nil default args", func(t *testing.T) {
require.Empty(t, res.Container.From.WithDefaultArgs.Entrypoint)
require.Empty(t, res.Container.From.WithDefaultArgs.DefaultArgs)
})
t.Run("with entrypoint set", func(t *testing.T) {
require.Equal(t, []string{"sh", "-c"}, res.Container.From.WithEntrypoint.Entrypoint)
require.Equal(t, []string{"/bin/sh"}, res.Container.From.WithEntrypoint.DefaultArgs)
})
t.Run("with exec args", func(t *testing.T) {
require.Equal(t, "/root\n", res.Container.From.WithEntrypoint.WithExec.Stdout)
})
t.Run("with default args set", func(t *testing.T) {
require.Equal(t, []string{"sh", "-c"}, res.Container.From.WithEntrypoint.WithDefaultArgs.Entrypoint)
require.Equal(t, []string{"id"}, res.Container.From.WithEntrypoint.WithDefaultArgs.DefaultArgs)
require.Equal(t, "uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel),11(floppy),20(dialout),26(tape),27(video)\n", res.Container.From.WithEntrypoint.WithDefaultArgs.WithExec.Stdout)
})
}
func TestContainerExecWithEnvVariable(t *testing.T) {
t.Parallel()
res := struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | Container struct {
From struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | WithEnvVariable struct {
WithExec struct {
Stdout string
}
}
}
}
}{}
err := testutil.Query(
`{
container {
from(address: "`+alpineImage+`") {
withEnvVariable(name: "FOO", value: "bar") {
withExec(args: ["env"]) {
stdout
}
}
}
}
}`, &res, nil)
require.NoError(t, err)
require.Contains(t, res.Container.From.WithEnvVariable.WithExec.Stdout, "FOO=bar\n")
}
func TestContainerVariables(t *testing.T) {
t.Parallel()
res := struct {
Container struct {
From struct {
EnvVariables []schema.EnvVariable
WithExec struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | Stdout string
}
}
}
}{}
err := testutil.Query(
`{
container {
from(address: "golang:1.18.2-alpine") {
envVariables {
name
value
}
withExec(args: ["env"]) {
stdout
}
}
}
}`, &res, nil)
require.NoError(t, err)
require.Equal(t, []schema.EnvVariable{
{Name: "PATH", Value: "/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"},
{Name: "GOLANG_VERSION", Value: "1.18.2"},
{Name: "GOPATH", Value: "/go"},
}, res.Container.From.EnvVariables)
require.Contains(t, res.Container.From.WithExec.Stdout, "GOPATH=/go\n")
}
func TestContainerVariable(t *testing.T) {
t.Parallel()
res := struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | Container struct {
From struct {
EnvVariable *string
}
}
}{}
err := testutil.Query(
`{
container {
from(address: "golang:1.18.2-alpine") {
envVariable(name: "GOLANG_VERSION")
}
}
}`, &res, nil)
require.NoError(t, err)
require.NotNil(t, res.Container.From.EnvVariable)
require.Equal(t, "1.18.2", *res.Container.From.EnvVariable)
err = testutil.Query(
`{
container {
from(address: "golang:1.18.2-alpine") {
envVariable(name: "UNKNOWN")
}
}
}`, &res, nil)
require.NoError(t, err)
require.Nil(t, res.Container.From.EnvVariable)
}
func TestContainerWithoutVariable(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | t.Parallel()
res := struct {
Container struct {
From struct {
WithoutEnvVariable struct {
EnvVariables []schema.EnvVariable
WithExec struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | Stdout string
}
}
}
}
}{}
err := testutil.Query(
`{
container {
from(address: "golang:1.18.2-alpine") {
withoutEnvVariable(name: "GOLANG_VERSION") {
envVariables {
name
value
}
withExec(args: ["env"]) {
stdout
}
}
}
}
}`, &res, nil)
require.NoError(t, err)
require.Equal(t, res.Container.From.WithoutEnvVariable.EnvVariables, []schema.EnvVariable{
{Name: "PATH", Value: "/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"},
{Name: "GOPATH", Value: "/go"},
})
require.NotContains(t, res.Container.From.WithoutEnvVariable.WithExec.Stdout, "GOLANG_VERSION")
}
func TestContainerEnvVariablesReplace(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | t.Parallel()
res := struct {
Container struct {
From struct {
WithEnvVariable struct {
EnvVariables []schema.EnvVariable
WithExec struct {
Stdout string
}
}
}
}
}{}
err := testutil.Query(
`{
container {
from(address: "golang:1.18.2-alpine") {
withEnvVariable(name: "GOPATH", value: "/gone") {
envVariables {
name |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | value
}
withExec(args: ["env"]) {
stdout
}
}
}
}
}`, &res, nil)
require.NoError(t, err)
require.Equal(t, res.Container.From.WithEnvVariable.EnvVariables, []schema.EnvVariable{
{Name: "PATH", Value: "/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"},
{Name: "GOLANG_VERSION", Value: "1.18.2"},
{Name: "GOPATH", Value: "/gone"},
})
require.Contains(t, res.Container.From.WithEnvVariable.WithExec.Stdout, "GOPATH=/gone\n")
}
func TestContainerWithEnvVariableExpand(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
t.Run("add env var without expansion", func(t *testing.T) {
out, err := c.Container().
From(alpineImage).
WithEnvVariable("FOO", "foo:$PATH").
WithExec([]string{"printenv", "FOO"}).
Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "foo:$PATH\n", out)
})
t.Run("add env var with expansion", func(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | out, err := c.Container().
From(alpineImage).
WithEnvVariable("USER_PATH", "/opt").
WithEnvVariable(
"PATH",
"${USER_PATH}/bin:$PATH",
dagger.ContainerWithEnvVariableOpts{
Expand: true,
},
).
WithExec([]string{"printenv", "PATH"}).
Stdout(ctx)
require.NoError(t, err)
require.Equal(t,
"/opt/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\n",
out,
)
})
}
func TestContainerLabel(t *testing.T) {
c, ctx := connect(t)
t.Run("container with new label", func(t *testing.T) {
label, err := c.Container().From(alpineImage).WithLabel("FOO", "BAR").Label(ctx, "FOO")
require.NoError(t, err)
require.Contains(t, label, "BAR")
})
t.Run("container labels", func(t *testing.T) {
res := struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | Container struct {
From struct {
Labels []schema.Label
}
}
}{}
err := testutil.Query(
`{
container {
from(address: "nginx") {
labels {
name
value
}
}
}
}`, &res, nil)
require.NoError(t, err)
require.Equal(t, []schema.Label{
{Name: "maintainer", Value: "NGINX Docker Maintainers <docker-maint@nginx.com>"},
}, res.Container.From.Labels) |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | })
t.Run("container without label", func(t *testing.T) {
label, err := c.Container().From("nginx").WithoutLabel("maintainer").Label(ctx, "maintainer")
require.NoError(t, err)
require.Empty(t, label)
})
t.Run("container replace label", func(t *testing.T) {
label, err := c.Container().From("nginx").WithLabel("maintainer", "bar").Label(ctx, "maintainer")
require.NoError(t, err)
require.Contains(t, label, "bar")
})
t.Run("container with new label - nil panics", func(t *testing.T) {
label, err := c.Container().WithLabel("FOO", "BAR").Label(ctx, "FOO")
require.NoError(t, err)
require.Contains(t, label, "BAR")
})
t.Run("container label - nil panics", func(t *testing.T) {
label, err := c.Container().Label(ctx, "FOO")
require.NoError(t, err)
require.Empty(t, label)
})
t.Run("container without label - nil panics", func(t *testing.T) {
label, err := c.Container().WithoutLabel("maintainer").Label(ctx, "maintainer")
require.NoError(t, err)
require.Empty(t, label)
})
t.Run("container labels - nil panics", func(t *testing.T) {
res := struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | Container struct {
From struct {
Labels []schema.Label
}
}
}{}
err := testutil.Query(
`{
container {
labels {
name
value
}
}
}`, &res, nil)
require.NoError(t, err)
require.Empty(t, res.Container.From.Labels)
})
}
func TestContainerWorkdir(t *testing.T) {
t.Parallel()
res := struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | Container struct {
From struct {
Workdir string
WithExec struct {
Stdout string
}
}
}
}{}
err := testutil.Query(
`{
container {
from(address: "golang:1.18.2-alpine") {
workdir
withExec(args: ["pwd"]) {
stdout
}
}
}
}`, &res, nil)
require.NoError(t, err)
require.Equal(t, res.Container.From.Workdir, "/go")
require.Equal(t, res.Container.From.WithExec.Stdout, "/go\n")
}
func TestContainerWithWorkdir(t *testing.T) {
t.Parallel()
res := struct {
Container struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | From struct {
WithWorkdir struct {
Workdir string
WithExec struct {
Stdout string
}
}
}
}
}{}
err := testutil.Query(
`{
container {
from(address: "golang:1.18.2-alpine") {
withWorkdir(path: "/usr") {
workdir
withExec(args: ["pwd"]) {
stdout
}
}
}
}
}`, &res, nil)
require.NoError(t, err)
require.Equal(t, res.Container.From.WithWorkdir.Workdir, "/usr")
require.Equal(t, res.Container.From.WithWorkdir.WithExec.Stdout, "/usr\n")
}
func TestContainerWithMountedDirectory(t *testing.T) {
t.Parallel()
dirRes := struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | Directory struct {
WithNewFile struct {
WithNewFile struct {
ID string
}
}
}
}{}
err := testutil.Query(
`{
directory {
withNewFile(path: "some-file", contents: "some-content") {
withNewFile(path: "some-dir/sub-file", contents: "sub-content") {
id
}
}
}
}`, &dirRes, nil)
require.NoError(t, err)
id := dirRes.Directory.WithNewFile.WithNewFile.ID
execRes := struct {
Container struct {
From struct {
WithMountedDirectory struct {
WithExec struct {
Stdout string
WithExec struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | Stdout string
}
}
}
}
}
}{}
err = testutil.Query(
`query Test($id: DirectoryID!) {
container {
from(address: "`+alpineImage+`") {
withMountedDirectory(path: "/mnt", source: $id) {
withExec(args: ["cat", "/mnt/some-file"]) {
stdout
withExec(args: ["cat", "/mnt/some-dir/sub-file"]) {
stdout
}
}
}
}
}
}`, &execRes, &testutil.QueryOptions{Variables: map[string]any{
"id": id,
}})
require.NoError(t, err)
require.Equal(t, "some-content", execRes.Container.From.WithMountedDirectory.WithExec.Stdout)
require.Equal(t, "sub-content", execRes.Container.From.WithMountedDirectory.WithExec.WithExec.Stdout)
}
func TestContainerWithMountedDirectorySourcePath(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | t.Parallel()
dirRes := struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | Directory struct {
WithNewFile struct {
WithNewFile struct {
Directory struct {
ID string
}
}
}
}
}{}
err := testutil.Query(
`{
directory {
withNewFile(path: "some-file", contents: "some-content") {
withNewFile(path: "some-dir/sub-file", contents: "sub-content") {
directory(path: "some-dir") {
id
}
}
}
}
}`, &dirRes, nil)
require.NoError(t, err)
id := dirRes.Directory.WithNewFile.WithNewFile.Directory.ID
execRes := struct {
Container struct {
From struct {
WithMountedDirectory struct {
WithExec struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | WithExec struct {
Stdout string
}
}
}
}
}
}{}
err = testutil.Query(
`query Test($id: DirectoryID!) {
container {
from(address: "`+alpineImage+`") {
withMountedDirectory(path: "/mnt", source: $id) {
withExec(args: ["sh", "-c", "echo >> /mnt/sub-file; echo -n more-content >> /mnt/sub-file"]) {
withExec(args: ["cat", "/mnt/sub-file"]) {
stdout
}
}
}
}
}
}`, &execRes, &testutil.QueryOptions{Variables: map[string]any{
"id": id,
}})
require.NoError(t, err)
require.Equal(t, "sub-content\nmore-content", execRes.Container.From.WithMountedDirectory.WithExec.WithExec.Stdout)
}
func TestContainerWithMountedDirectoryPropagation(t *testing.T) {
t.Parallel()
dirRes := struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | Directory struct {
WithNewFile struct {
ID core.DirectoryID
}
}
}{}
err := testutil.Query(
`{
directory {
withNewFile(path: "some-file", contents: "some-content") {
id
}
}
}`, &dirRes, nil, dagger.WithLogOutput(os.Stdout))
require.NoError(t, err)
id := dirRes.Directory.WithNewFile.ID
execRes := struct {
Container struct {
From struct {
WithMountedDirectory struct {
WithExec struct {
Stdout string
WithExec struct {
WithExec struct {
Stdout string
WithMountedDirectory struct {
WithExec struct {
Stdout string
WithExec struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | Stdout string
}
}
}
}
}
}
}
}
}
}{}
err = testutil.Query(
`query Test($id: DirectoryID!) {
container {
from(address: "`+alpineImage+`") {
withMountedDirectory(path: "/mnt", source: $id) {
withExec(args: ["cat", "/mnt/some-file"]) {
# original content
stdout
withExec(args: ["sh", "-c", "echo >> /mnt/some-file; echo -n more-content >> /mnt/some-file"]) {
withExec(args: ["cat", "/mnt/some-file"]) {
# modified content should propagate
stdout
withMountedDirectory(path: "/mnt", source: $id) {
withExec(args: ["cat", "/mnt/some-file"]) {
# should be back to the original content
stdout
withExec(args: ["cat", "/mnt/some-file"]) {
# original content override should propagate |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | stdout
}
}
}
}
}
}
}
}
}
}`, &execRes, &testutil.QueryOptions{Variables: map[string]any{
"id": id,
}}, dagger.WithLogOutput(os.Stdout))
require.NoError(t, err)
require.Equal(t,
"some-content",
execRes.Container.From.WithMountedDirectory.WithExec.Stdout)
require.Equal(t,
"some-content\nmore-content",
execRes.Container.From.WithMountedDirectory.WithExec.WithExec.WithExec.Stdout)
require.Equal(t,
"some-content",
execRes.Container.From.WithMountedDirectory.WithExec.WithExec.WithExec.WithMountedDirectory.WithExec.Stdout)
require.Equal(t,
"some-content",
execRes.Container.From.WithMountedDirectory.WithExec.WithExec.WithExec.WithMountedDirectory.WithExec.WithExec.Stdout)
}
func TestContainerWithMountedFile(t *testing.T) {
t.Parallel()
dirRes := struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | Directory struct {
WithNewFile struct {
File struct {
ID core.FileID
}
}
}
}{}
err := testutil.Query(
`{
directory {
withNewFile(path: "some-dir/sub-file", contents: "sub-content") {
file(path: "some-dir/sub-file") {
id
}
}
}
}`, &dirRes, nil)
require.NoError(t, err)
id := dirRes.Directory.WithNewFile.File.ID
execRes := struct {
Container struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | From struct {
WithMountedFile struct {
WithExec struct {
Stdout string
}
}
}
}
}{}
err = testutil.Query(
`query Test($id: FileID!) {
container {
from(address: "`+alpineImage+`") {
withMountedFile(path: "/mnt/file", source: $id) {
withExec(args: ["cat", "/mnt/file"]) {
stdout
}
}
}
}
}`, &execRes, &testutil.QueryOptions{Variables: map[string]any{
"id": id,
}})
require.NoError(t, err)
require.Equal(t, "sub-content", execRes.Container.From.WithMountedFile.WithExec.Stdout)
}
func TestContainerWithMountedCache(t *testing.T) {
t.Parallel()
cacheID := newCache(t)
execRes := struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | Container struct {
From struct {
WithEnvVariable struct {
WithMountedCache struct {
WithExec struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | Stdout string
}
}
}
}
}
}{}
query := `query Test($cache: CacheVolumeID!, $rand: String!) {
container {
from(address: "` + alpineImage + `") {
withEnvVariable(name: "RAND", value: $rand) {
withMountedCache(path: "/mnt/cache", cache: $cache) {
withExec(args: ["sh", "-c", "echo $RAND >> /mnt/cache/file; cat /mnt/cache/file"]) {
stdout
}
}
}
}
}
}`
rand1 := identity.NewID()
err := testutil.Query(query, &execRes, &testutil.QueryOptions{Variables: map[string]any{
"cache": cacheID,
"rand": rand1,
}})
require.NoError(t, err)
require.Equal(t, rand1+"\n", execRes.Container.From.WithEnvVariable.WithMountedCache.WithExec.Stdout)
rand2 := identity.NewID()
err = testutil.Query(query, &execRes, &testutil.QueryOptions{Variables: map[string]any{
"cache": cacheID, |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | "rand": rand2,
}})
require.NoError(t, err)
require.Equal(t, rand1+"\n"+rand2+"\n", execRes.Container.From.WithEnvVariable.WithMountedCache.WithExec.Stdout)
}
func TestContainerWithMountedCacheFromDirectory(t *testing.T) {
t.Parallel()
dirRes := struct {
Directory struct {
WithNewFile struct {
Directory struct {
ID core.FileID
}
}
}
}{}
err := testutil.Query(
`{
directory {
withNewFile(path: "some-dir/sub-file", contents: "initial-content\n") {
directory(path: "some-dir") {
id
}
}
}
}`, &dirRes, nil)
require.NoError(t, err)
initialID := dirRes.Directory.WithNewFile.Directory.ID
cacheID := newCache(t)
execRes := struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | Container struct {
From struct {
WithEnvVariable struct {
WithMountedCache struct {
WithExec struct {
Stdout string
}
}
}
}
}
}{}
query := `query Test($cache: CacheVolumeID!, $rand: String!, $init: DirectoryID!) {
container {
from(address: "` + alpineImage + `") { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | withEnvVariable(name: "RAND", value: $rand) {
withMountedCache(path: "/mnt/cache", cache: $cache, source: $init) {
withExec(args: ["sh", "-c", "echo $RAND >> /mnt/cache/sub-file; cat /mnt/cache/sub-file"]) {
stdout
}
}
}
}
}
}`
rand1 := identity.NewID()
err = testutil.Query(query, &execRes, &testutil.QueryOptions{Variables: map[string]any{
"init": initialID,
"rand": rand1,
"cache": cacheID,
}})
require.NoError(t, err)
require.Equal(t, "initial-content\n"+rand1+"\n", execRes.Container.From.WithEnvVariable.WithMountedCache.WithExec.Stdout)
rand2 := identity.NewID()
err = testutil.Query(query, &execRes, &testutil.QueryOptions{Variables: map[string]any{
"init": initialID,
"rand": rand2,
"cache": cacheID,
}})
require.NoError(t, err)
require.Equal(t, "initial-content\n"+rand1+"\n"+rand2+"\n", execRes.Container.From.WithEnvVariable.WithMountedCache.WithExec.Stdout)
}
func TestContainerWithMountedTemp(t *testing.T) {
t.Parallel()
execRes := struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | Container struct {
From struct {
WithMountedTemp struct {
WithExec struct {
Stdout string
}
}
}
}
}{}
err := testutil.Query(`{
container {
from(address: "`+alpineImage+`") {
withMountedTemp(path: "/mnt/tmp") {
withExec(args: ["grep", "/mnt/tmp", "/proc/mounts"]) {
stdout
}
}
}
}
}`, &execRes, nil)
require.NoError(t, err)
require.Contains(t, execRes.Container.From.WithMountedTemp.WithExec.Stdout, "tmpfs /mnt/tmp tmpfs")
}
func TestContainerWithDirectory(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | t.Parallel()
c, ctx := connect(t)
dir := c.Directory().
WithNewFile("some-file", "some-content").
WithNewFile("some-dir/sub-file", "sub-content").
Directory("some-dir")
ctr := c.Container().
From(alpineImage).
WithWorkdir("/workdir").
WithDirectory("with-dir", dir)
contents, err := ctr.WithExec([]string{"cat", "with-dir/sub-file"}).
Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "sub-content", contents)
contents, err = ctr.WithExec([]string{"cat", "/workdir/with-dir/sub-file"}).
Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "sub-content", contents) |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | mount := c.Directory().
WithNewFile("mounted-file", "mounted-content")
ctr = c.Container().
From(alpineImage).
WithWorkdir("/workdir").
WithMountedDirectory("mnt/mount", mount).
WithDirectory("mnt/mount/dst/with-dir", dir)
contents, err = ctr.WithExec([]string{"cat", "mnt/mount/mounted-file"}).
Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "mounted-content", contents)
contents, err = ctr.WithExec([]string{"cat", "mnt/mount/dst/with-dir/sub-file"}).
Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "sub-content", contents)
mnt := c.Directory().WithNewDirectory("/a/b/c")
ctr = c.Container().
From(alpineImage).
WithMountedDirectory("/mnt", mnt)
dir = c.Directory().
WithNewDirectory("/foo").
WithNewFile("/foo/some-file", "some-content")
ctr = ctr.WithDirectory("/mnt/a/b/foo", dir)
contents, err = ctr.WithExec([]string{"cat", "/mnt/a/b/foo/foo/some-file"}).
Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "some-content", contents)
}
func TestContainerWithFile(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | t.Parallel()
c, ctx := connect(t)
file := c.Directory().
WithNewFile("some-file", "some-content").
File("some-file")
ctr := c.Container().
From(alpineImage).
WithWorkdir("/workdir").
WithFile("target-file", file)
contents, err := ctr.WithExec([]string{"cat", "target-file"}).
Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "some-content", contents)
contents, err = ctr.WithExec([]string{"cat", "/workdir/target-file"}).
Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "some-content", contents)
}
func TestContainerWithNewFile(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | t.Parallel()
c, ctx := connect(t)
ctr := c.Container().
From(alpineImage).
WithWorkdir("/workdir").
WithNewFile("some-file", dagger.ContainerWithNewFileOpts{
Contents: "some-content",
})
contents, err := ctr.WithExec([]string{"cat", "some-file"}).
Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "some-content", contents)
contents, err = ctr.WithExec([]string{"cat", "/workdir/some-file"}).
Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "some-content", contents)
}
func TestContainerMountsWithoutMount(t *testing.T) {
t.Parallel()
dirRes := struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | Directory struct {
WithNewFile struct {
WithNewFile struct {
ID string
}
}
}
}{}
err := testutil.Query(
`{
directory {
withNewFile(path: "some-file", contents: "some-content") {
withNewFile(path: "some-dir/sub-file", contents: "sub-content") {
id
}
}
}
}`, &dirRes, nil)
require.NoError(t, err)
id := dirRes.Directory.WithNewFile.WithNewFile.ID
execRes := struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | Container struct {
From struct {
WithDirectory struct {
WithMountedTemp struct {
Mounts []string
WithMountedDirectory struct {
Mounts []string
WithExec struct {
Stdout string
WithoutMount struct {
Mounts []string
WithExec struct {
Stdout string
}
}
}
}
}
}
}
}
}{}
err = testutil.Query(
`query Test($id: DirectoryID!) {
container {
from(address: "`+alpineImage+`") { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | withDirectory(path: "/mnt/dir", directory: "") {
withMountedTemp(path: "/mnt/tmp") {
mounts
withMountedDirectory(path: "/mnt/dir", source: $id) {
mounts
withExec(args: ["ls", "/mnt/dir"]) {
stdout
withoutMount(path: "/mnt/dir") {
mounts
withExec(args: ["ls", "/mnt/dir"]) {
stdout
}
}
}
}
}
}
}
}
}`, &execRes, &testutil.QueryOptions{Variables: map[string]any{
"id": id,
}})
require.NoError(t, err)
require.Equal(t, []string{"/mnt/tmp"}, execRes.Container.From.WithDirectory.WithMountedTemp.Mounts)
require.Equal(t, []string{"/mnt/tmp", "/mnt/dir"}, execRes.Container.From.WithDirectory.WithMountedTemp.WithMountedDirectory.Mounts)
require.Equal(t, "some-dir\nsome-file\n", execRes.Container.From.WithDirectory.WithMountedTemp.WithMountedDirectory.WithExec.Stdout)
require.Equal(t, "", execRes.Container.From.WithDirectory.WithMountedTemp.WithMountedDirectory.WithExec.WithoutMount.WithExec.Stdout)
require.Equal(t, []string{"/mnt/tmp"}, execRes.Container.From.WithDirectory.WithMountedTemp.WithMountedDirectory.WithExec.WithoutMount.Mounts)
}
func TestContainerReplacedMounts(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 3,284 | Use `withoutEntrypoint`, `withoutWorkdir`, `withoutUser` and `withoutDefaultArgs` to remove | Currently, passing nil or empty arguments to those function reinit the values.
It's not that explicit and clear.
It will make more API endpoints, but it's gonna be clearer. | https://github.com/dagger/dagger/issues/3284 | https://github.com/dagger/dagger/pull/6278 | 568d802bb892f1e074cf74cfce2a551989418964 | cd825bde699a0beb0adb5c2529da5469118a172b | 2022-10-07T15:00:07Z | go | 2023-12-19T13:11:01Z | core/integration/container_test.go | t.Parallel()
c, ctx := connect(t)
lower := c.Directory().WithNewFile("some-file", "lower-content")
upper := c.Directory().WithNewFile("some-file", "upper-content")
ctr := c.Container().
From(alpineImage).
WithMountedDirectory("/mnt/dir", lower)
t.Run("initial content is lower", func(t *testing.T) {
mnts, err := ctr.Mounts(ctx)
require.NoError(t, err)
require.Equal(t, []string{"/mnt/dir"}, mnts)
out, err := ctr.WithExec([]string{"cat", "/mnt/dir/some-file"}).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "lower-content", out)
})
replaced := ctr.WithMountedDirectory("/mnt/dir", upper)
t.Run("mounts of same path are replaced", func(t *testing.T) {
mnts, err := replaced.Mounts(ctx)
require.NoError(t, err)
require.Equal(t, []string{"/mnt/dir"}, mnts)
out, err := replaced.WithExec([]string{"cat", "/mnt/dir/some-file"}).Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "upper-content", out)
}) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.