#services v2 is merged :elmofire:

1 messages ยท Page 1 of 1 (latest)

frosty trellis
#
35: exec go build -o /runtime .
35: > in load builtin module sdk go
35: [0.51s] # dagger
35: [0.51s] ./worker.go:223:34: cannot use registrySvc (variable of type *Container) as *Service value in argument to worker.WithServiceBinding
35: [0.51s] ./worker.go:224:41: cannot use privateRegistry() (value of type *Container) as *Service value in argument to worker.WithServiceBinding("registry", registrySvc).WithServiceBinding
35: [0.51s] ./worker.go:231:26: worker.Endpoint undefined (type *Container has no field or method Endpoint)
35: [0.51s] ./worker.go:231:40: undefined: ContainerEndpointOpts
35: [0.51s] ./worker.go:266:39: cannot use worker (variable of type *Container) as *Service value in argument to w.GoBase.WithExec([]string{โ€ฆ}).WithMountedDirectory("/app", dag.Host().Directory(".")).WithMountedDirectory(utilDirPath, testEngineUtils).WithEnvVariable("_DAGGER_TESTS_ENGINE_TAR", filepath.Join(utilDirPath, "engine.tar")).WithWorkdir("/app").WithServiceBinding
35: [0.51s] ./worker.go:267:34: cannot use registrySvc (variable of type *Container) as *Service value in argument to w.GoBase.WithExec([]string{โ€ฆ}).WithMountedDirectory("/app", dag.Host().Directory(".")).WithMountedDirectory(utilDirPath, testEngineUtils).WithEnvVariable("_DAGGER_TESTS_ENGINE_TAR", filepath.Join(utilDirPath, "engine.tar")).WithWorkdir("/app").WithServiceBinding("dagger-engine", worker).WithServiceBinding
35: exec go build -o /runtime . ERROR: process "go build -o /runtime ." did not complete successfully: exit code: 1
#

Going to try to get Solomon's dagger module that builds dagger working with the new style. Going to look up the breaking change description

royal valley
#

yep - you can get rid of the WithExec(nil) now too

frosty trellis
#

nice. I think I'm running into issues duing dagger mod sync though

#

this one is weird...wonder if I can delete the WithExec...

WithExec(nil, ContainerWithExecOpts{
            InsecureRootCapabilities: true,
        }).Service()
royal valley
#

nah that one should probably stay

#

since it adds the opts

frosty trellis
#

using dagger cli built by ./hack/dev on main

#

seems like a chicken-egg with dagger.gen.go that I've run into sometimes

royal valley
#

can you link the module?

frosty trellis
#

Here's a simpler one

package main

import (
    "context"
)

type Test struct {}

func (m *Test) MyFunction(ctx context.Context) (string, error) {
    // create HTTP service container with exposed port 8080
    httpSrv := dag.Container().
        From("python").
        WithDirectory("/srv", dag.Directory().WithNewFile("index.html", "Hello, world!")).
        WithWorkdir("/srv").
        WithExec([]string{"python", "-m", "http.server", "8080"}).
        WithExposedPort(8080).
        Service() // ONLY DIFFERENCE

    // create client container with service binding
    // access HTTP service and print result
    val, err := dag.Container().
        From("alpine").
        WithServiceBinding("www", httpSrv).
        WithExec([]string{"wget", "-O-", "http://www:8080"}).
        Stdout(ctx)

    return val, err
}
#

using code from the PR s/client/dag/

#
test โžค dagger mod init --name=test --sdk=go
test โžค dagger mod sync                                                                                          git:main*
โœ˜ asModule(sourceSubpath: ".") ERROR [1.41s]
โ–ถ load builtin module sdk go
  โœ˜ exec go build -o /runtime . ERROR [0.24s]
  โ”ƒ # test
  โ”ƒ ./main.go:17:3: dag.Container().From("python").WithDirectory("/srv", dag.Directory().WithNewFile("index.html", "Hello,
  โ”ƒ ld!")).WithWorkdir("/srv").WithExec([]string{โ€ฆ}).WithExposedPort(8080).Service undefined (type *Container has no field
  โ”ƒ method Service)
โ€ข Engine: c3980dd25c6c (version devel ())
โง— 1.76s โœ” 16 โˆ… 2 โœ˜ 2
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "test" to get functions: failed to get function output directory: process "go build -o /runtime ." did not complete successfully: exit code: 1
royal valley
#

needs to be AsService() now

#

but i'm more worried about those "LoadCommitFromID" errors

frosty trellis
#

I just used that code

#

Will fix

royal valley
#

yep

frosty trellis
#
package main

import (
    "context"
)

type Test struct {}

func (m *Test) MyFunction(ctx context.Context) (string, error) {
    // create HTTP service container with exposed port 8080
    httpSrv := dag.Container().
        From("python").
        WithDirectory("/srv", dag.Directory().WithNewFile("index.html", "Hello, world!")).
        WithWorkdir("/srv").
        WithExec([]string{"python", "-m", "http.server", "8080"}).
        WithExposedPort(8080).
        AsService() // ONLY DIFFERENCE

    // create client container with service binding
    // access HTTP service and print result
    val, err := dag.Container().
        From("alpine").
        WithServiceBinding("www", httpSrv).
        WithExec([]string{"wget", "-O-", "http://www:8080"}).
        Stdout(ctx)

    return val, err
}
dagger query -m . <<EOF                                                                                  git:main*
query {
test { myFunction }
}
EOF
#

works!

royal valley
#

updated the PR description to avoid confusion

#

still looking for a repro on those other errors though, could just be a link to the module you tried to sync

frosty trellis
#

Errors ๐Ÿ‘†

#

will try to move the name of the service container as discussed

frosty trellis
#

Guessing the issue with the the superGit module being used since

dagger2 โžค dagger mod use github.com/shykes/daggerverse/supergit@e2f1b5443f8c398a9866fc9f11eba4b7f20f6471
โœ˜ asModule(sourceSubpath: ".") ERROR [2.02s]
โ–ถ load builtin module sdk go โ–ถ load builtin module sdk go
  โœ˜ exec go build -o /runtime . ERROR [0.23s]
  โ”ƒ # dagger
  โ”ƒ ./dagger.gen.go:226:12: dag.LoadCommitFromID undefined (type *Client has no field or method LoadCommitFromID)
  โ”ƒ ./dagger.gen.go:226:29: undefined: CommitID
  โ”ƒ ./dagger.gen.go:4161:12: dag.LoadRemoteTagFromID undefined (type *Client has no field or method LoadRemoteTag
  โ”ƒ ID)
  โ”ƒ ./dagger.gen.go:4161:32: undefined: RemoteTagID
โ€ข Engine: c3980dd25c6c (version devel ())
โง— 3.29s โœ” 41 โˆ… 9 โœ˜ 2
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "dagger" to get functions: failed to get function output directory: process "go build -o /runtime ." did not complete successfully: exit code: 1
royal valley
#

figured that one out โ˜๏ธ - it's because Commit and RemoteTag define an "ID" method, which is effectively a reserved word, since that indicates to codegen that the object is ID-able

#

we should document that as a no-no

#

or find some other way of dealing with that

#

i think that'll just have to be reserved, since we also want all objects to be ID-able at some point in the future (I'd guess short/medium-term)

frosty trellis
#

I think that's what was happening...

#
 # supergit
  โ”ƒ ./remote.go:92:22: field and method with the same name Commit
  โ”ƒ         ./remote.go:89:2: other declaration of Commit
  โ”ƒ ./remote.go:93:9: cannot use rt.Commit (value of type func() string) as string value in return statement
supple bane
royal valley
frosty trellis
#

Another question that came out in the discussion was, "should dagger mod init take kebab-case module names in addition to graphQL camelCase"

#

or alternatively, be able to work with several casing schemes

#

dagger mod init fooBar
dagger mod init FooBar
dagger mod init foo_bar
dagger mod init foo-bar

supple bane
supple bane