Skip to content

Services v2: new API, c2h and h2c networking, start/stop support, run via gateway - #5557

Merged
vito merged 294 commits into
dagger:mainfrom
vito:services-v2-c2h-h2c
Oct 19, 2023
Merged

vito merged 294 commits into
dagger:mainfrom
vito:services-v2-c2h-h2c

Conversation

@vito

@vito vito commented Aug 2, 2023 •

Copy link
Copy Markdown
Contributor

This PR combines a few efforts that have been piling up throughout our chaotic Zenith adventures; sorry for the huge PR:

  1. Switch services to run via the gateway interface instead of via Solve() (previously Breaking API change: run services via gateway, revise API #5322) (fixes DEV-1656)
    • No more scary looking canceled/failed vertexes/runs
    • Services no longer count towards concurrency limit (which could cause deadlock)
    • Services are no longer deduped across all client call sites; each client gets its own instance
    • Regular containers no longer have a hostname, allowing them to use the CNI pool (fixes DEV-1644)
    • This was backported: Backport: services via gateway, minus API changes #5764
  2. Support for explicit Service.start and Service.stop APIs
  3. Support for container => host networking (Host.service), represented as a proxy Service
  4. Support for host => service networking (Host.tunnel), also represented as a proxy Service

Code samples

Container-to-container networking

Same as before, except you need to call Container.asService to get a Service instead of binding directly to a container.

// create HTTP service container with exposed port 8080
httpSrv := client.Container().
	From("python").
	WithDirectory("/srv", client.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 := client.Container().
	From("alpine").
	WithServiceBinding("www", httpSrv).
	WithExec([]string{"wget", "-O-", "http://www:8080"}).
	Stdout(ctx)

Host-to-container networking

Simply call Host.tunnel(service).start. By default it wlll let the OS choose randomly available ports on the host side, which is really nice for things like throwaway service containers in test suites. You call endpoint to get the final addr with whichever port is bound.

content := "Hello, world!"
srv := c.Container().
	From("python").
	WithMountedDirectory(
		"/srv/www",
		c.Directory().WithNewFile("index.html", content),
	).
	WithWorkdir("/srv/www").
	WithExposedPort(8000).
	WithExec([]string{"python", "-m", "http.server"}).
	AsService()

tunnel, err := c.Host().Tunnel(srv).Start(ctx)
require.NoError(t, err)

defer func() {
    _, err := tunnel.Stop(ctx)
    require.NoError(t, err)
}()

srvAddr, err := tunnel.Endpoint(ctx)
require.NoError(t, err)

res, err := http.Get("http://" + srvAddr)
require.NoError(t, err)
defer res.Body.Close()

body, err := io.ReadAll(res.Body)
require.NoError(t, err)

require.Equal(t, content, string(body))

Container-to-host networking

Call Host.service([]PortForward) to create a Service that proxies traffic through the host to the configured ports.

Under the hood this works almost exactly the same as Host.unixSocket. In fact it uses a new flavor of Socket internally.

l, err := net.Listen("tcp", "127.0.0.1:0")
require.NoError(t, err)

defer l.Close()

go http.Serve(l, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
	fmt.Fprintln(w, r.URL.Query().Get("content"))
}))

_, portStr, err := net.SplitHostPort(l.Addr().String())
require.NoError(t, err)
port, err := strconv.Atoi(portStr)
require.NoError(t, err)

host := c.Host().Service([]dagger.PortForward{
    {Frontend: 80, Backend: port},
})

out, err := c.Container().
	From(alpineImage).
	WithServiceBinding("www", host).
	WithExec([]string{"wget", "-O-", "http://www/?content=hello"}).
	Stdout(ctx)
require.NoError(t, err)
require.Equal(t, "hello\n", out)

Service start/stop

Services are designed to be expressed as a DAG with explicit bindings allowing services to be started lazily, just like every other DAG node. But sometimes you just want to explicitly manage the lifecycle. Service.start and Service.stop let you do that.

// somewhere in your test suite setup
dockerd, err := c.Container().From("docker:dind").AsService().Start(ctx)

// dockerd is now running, and will stay running
// so you don't have to worry about it restarting after a 10 second gap

// then in all of your tests, continue to use an explicit binding:
tests, err := c.Container().From("golang").
  WithServiceBinding("docker", dockerd).
  WithEnvVariable("DOCKER_HOST", "tcp://docker:2375").
  WithExec([]string{"go", "test", "./..."}).
  Sync(ctx)

// or, if you prefer not to Google what port `docker:dind` listens on,
// trust `Endpoint` to construct the address.
//
// note that this has the exact same non-cache-busting semantics as WithServiceBinding,
// since hostnames are stable and content-addressed
//
// this could go in global suite setup.
dockerHost, err := dockerd.Endpoint(ctx, dagger.ServiceEndpointOpts{
  Scheme: "tcp",
})

tests, err := c.Container().From("golang").
  WithEnvVariable("DOCKER_HOST", dockerHost).
  WithExec([]string{"go", "test", "./..."}).
  Sync(ctx)

// if your tests created local files (e.g. failed browser test screenshots),
// access them using the tests var

API changes:

# NEW
"A unique service identifier."
scalar ServiceID

# NEW
type Service {
  "A unique identifier for this service."
  id: ServiceID!

  """
  Retrieves a hostname which can be used by clients to reach this container.

  Currently experimental; set _EXPERIMENTAL_DAGGER_SERVICES_DNS=0 to disable.
  """
  hostname: String!

  """
  Retrieves an endpoint that clients can use to reach this container.

  If no port is specified, the first exposed port is used. If none exist an error is returned.

  If a scheme is specified, a URL is returned. Otherwise, a host:port pair is returned.

  Currently experimental; set _EXPERIMENTAL_DAGGER_SERVICES_DNS=0 to disable.
  """
  endpoint(
    "The exposed port number for the endpoint"
    port: Int
    "Return a URL with the given scheme, eg. http for http://"
    scheme: String
  ): String!

  """
  Start the service and wait for its health checks to succeed.

  Services bound to a Container do not need to be manually started.
  """
  start: ServiceID!

  """
  Stop the service.
  """
  stop: ServiceID!
}

# NEW
extend type Query {
  """
  Loads a service from ID.
  """
  service(id: ServiceID!): Service!
}

# NEW
extend type Container {
  """
  Retrieves a service that will run the container.
  """
  asService: Service!
}

# BREAKING
type Container {
  withServiceBinding(
    alias: String!
    # BREAKING: used to be ContainerID
    service: ServiceID! 
  ): Container!

  # BREAKING: moved to Service
  # hostname: String!

  # BREAKING: moved to Service
  # endpoint(port: Int, scheme: String): String!
}

# BREAKING
type Query {
  git(
    url: String!
    keepGitDir: Boolean
    # BREAKING: used to be ContainerID
    experimentalServiceHost: ServiceID
  ): GitRepository!

  http(
    url: String!
    # BREAKING: used to be ContainerID
    experimentalServiceHost: ServiceID
  ): File!
}

# NEW
extend type Host {
  """
  Creates a tunnel that forwards traffic from the host to a service.
  """
  tunnel(
    "Service to send traffic from the tunnel."
    service: ServiceID!

    """
    Map each service port to the same port on the host, as if the service were
    running natively.

    Note: enabling may result in port conflicts.
    """
    native: Boolean = false

    """
    Configure explicit port forwarding rules for the tunnel.

    If a port's frontend is unspecified or 0, a random port will be chosen by
    the host.

    If no ports are given, all of the service's ports are forwarded. If native
    is true, each port maps to the same port on the host. If native is false,
    each port maps to a random port chosen by the host.

    If ports are given and native is true, the ports are additive.
    """
    ports: [PortForward!]
  ): Service!

  """
  Creates a service that forwards traffic to a specified address via the host.
  """
  service(
    """
    Ports to expose via the service, forwarding through the host network.

    If a port's frontend is unspecified or 0, it defaults to the same as the
    backend port.

    An empty set of ports is not valid; an error will be returned.
    """
    ports: [PortForward!]!

    "Upstream host to forward traffic to."
    host: String = "localhost"
  ): Service!

}

"Port forwarding rules for tunneling network traffic."
input PortForward {
  """
  Port to expose to clients. If unspecified, a default will be chosen.
  """
  frontend: Int

  "Destination port for traffic."
  backend: Int!

  "Protocol to use for traffic."
  protocol: NetworkProtocol = TCP
}

TODOs

  • UDP host => container support
  • UDP container => host support
  • Container <=> container socket support

Prior art

  • @shykes's API proposal: "bass plus" container networking #4163
    • I borrowed elements of this but decided to split Host.proxy into two APIs
      • Host.reverseProxy for c2h, modeled as using the host as a reverse proxy
      • Service.proxy for h2c, modeled as creating a proxy into the service
      • I'd like someone to confirm these names actually make sense vs. whether they just look nice and symmetrical so my brain just feels good about them.
  • Spike: host-to-container networking #4738
    • Tried a few different approaches in this PR, the last thing I tried was to center things around Socket instead since nothing was inherently begging for a Service type, but I ended up adding a Service type anyway, so figured it was time to reconsider the proxy approach.

Implementation notes

  • I spent some time trying to unify Socket and Service into one concept but in the end I think it's clearer to just leave them as separate APIs.
  • I took some elements from it the original "bass plus networking" proposal ("proxy" terminology and the use of Services for h2c/c2h), but I think the API in this PR is a bit easier to grok (subjective) and feels more natural in common use cases.

@vito
vito force-pushed the services-v2-c2h-h2c branch 7 times, most recently from 948814b to 133d444 Compare August 2, 2023 23:27
@vito
vito marked this pull request as ready for review August 3, 2023 01:55
@vito
vito requested review from a team as code owners August 3, 2023 01:55
@vito

vito commented Aug 3, 2023

Copy link
Copy Markdown
Contributor Author

I'm on PTO Thursday and Friday, so current status: ready for review but not ready for v0.8.0. I think having two breaking releases back to back is the lesser evil to rushing a big API change.

There's a handful of TODOs at the bottom of the description, but I think those could also be done in separate PRs, since this one's already pretty gigantic. 😅

More importantly I want to leave time for everyone to bikeshed the API. I think I landed on something that feels clear in code, but my head is spinning from all the different terms and directional variations so it's entirely possible I've gotten things confused somewhere. 😵‍💫

@wingyplus

wingyplus commented Aug 3, 2023 •

Copy link
Copy Markdown
Contributor

This looks like the testcontainer, maybe can replacing it?

@vito

vito commented Aug 3, 2023

Copy link
Copy Markdown
Contributor Author

@wingyplus Yep, there's a lot of overlap! I prioritized the same use case when thinking about the Host => Container design. Testcontainers covers more domain-specific nuance, like having DB-specific integrations so it's easy to get a full ConnectionString for a Postgres service you just started, but this PR adds the primitives necessary to build that pretty easily, and maybe those could become extensions in the future.

@vito
vito force-pushed the services-v2-c2h-h2c branch 2 times, most recently from 33b2b7c to c456fd9 Compare August 8, 2023 15:14
@vito
vito requested a review from shykes August 8, 2023 16:56
@shykes

shykes commented Aug 8, 2023

Copy link
Copy Markdown
Contributor

Thanks for doing this! I know it's a very requested feature.

As expected, some API bikeshedding. I'm still forming an opinion, but here are some early points:

  1. "Reverse proxy" my first reaction was to be disoriented, reverse in relation to what etc. I think that term is less universally understood than it used to be, but I could be wrong. I think my original proposal has a risk of disorienting users too, "inbound" and "outbound" are more explicit, but you still need to think for a second and mentally position yourself, "inbound in position to what". Will think on it a bit more.

  2. In retrospect I think we should have attached all host-related functions to the top-level host. In other words, I think directory { export }, container { export } might have been mistakes. I think we underestimated how much people are confusing "things that happen inside the DAG" with "things that happen at the boundary between the DAG and the host". It's a pretty big mental shift, and there's a learning curve to it. I'm seeing people run into problems we consider very basic, like using host directory operations for things that really don't require it. So, even though having service { proxy } is consistent with how we've mixed host and non-host functions in the schema so far, I think we should break consistency and group it all under host, and possibly in the future we should consider doing the same for directory operations.

@vito

vito commented Aug 8, 2023 •

Copy link
Copy Markdown
Contributor Author

Great, thanks for taking the time! Let the bikeshedding commence:

  1. "Reverse proxy" my first reaction was to be disoriented, reverse in relation to what etc. I think that term is less universally understood than it used to be, but I could be wrong. I think my original proposal has a risk of disorienting users too, "inbound" and "outbound" are more explicit, but you still need to think for a second and mentally position yourself, "inbound in position to what". Will think on it a bit more.

Yeah, "reverse proxy" is what I was mainly alluding to here:

I think I landed on something that feels clear in code, but my head is spinning from all the different terms and directional variations so it's entirely possible I've gotten things confused somewhere. 😵‍💫

I was pretty confused by inbound/outbound even after reading the doc strings. I also felt confused by the notion of setting it all up in one API call, since in my mind h2c and c2h are somewhat discrete usage patterns. It felt a bit like a swiss-army knife, and it seemed hard to guess the correct combination for what I'd be trying to do at any given moment because nearly every field was optional (I presume as a result of having to support both cases in one API).

The previous API also supported setting up a bunch of proxies in one proxy API call, but I don't think that's a huge loss. Generally I think it's better to have an API that deals with 1 thing at a time, and have us optimize things into a single proxy instance under the hood if needed/possible.

So in short, everything started to click after adopting the terms "reverse proxy" and "upstream," combined with splitting the API up into smaller APIs with required params to guide you along. It also looked nice in code, so I rolled with it. But the real test is whether it makes sense to someone else. 😁

  1. In retrospect I think we should have attached all host-related functions to the top-level host. In other words, I think directory { export }, container { export } might have been mistakes. I think we underestimated how much people are confusing "things that happen inside the DAG" with "things that happen at the boundary between the DAG and the host". It's a pretty big mental shift, and there's a learning curve to it. I'm seeing people run into problems we consider very basic, like using host directory operations for things that really don't require it. So, even though having service { proxy } is consistent with how we've mixed host and non-host functions in the schema so far, I think we should break consistency and group it all under host, and possibly in the future we should consider doing the same for directory operations.

Yeah I remember discussions around this in the past. I'll try changing the API to this:

extend type Host {
  """
  Defines a proxy to forward traffic from a host IP:Port to a service.
  """
  proxy(
    "The service to proxy traffic to."
    upstream: ServiceID!

    "Host IP:Port for proxy binding. Port 0 implies any available port."
    hostListenAddress: String!

    "Service port to send traffic. Defaults to first exposed port."
    upstreamPort: Int

    "Traffic protocol. Defaults to TCP."
    protocol: NetworkProtocol = TCP
  ): Service!

  """
  Creates a proxy forwarding traffic via the host to a specified address.
  """
  reverseProxy(
    "Backend server host:port for traffic forwarding."
    upstreamAddress: String!

    "Listening port for incoming connections."
    servicePort: Int!

    "Traffic protocol. Defaults to TCP."
    protocol: NetworkProtocol = TCP
  ): Service!
}

The code change is trivial:

// proxy, err := srv.Proxy(localBindAddr).Start(ctx)
proxy, err := c.Host().Proxy(srv, localBindAddr).Start(ctx)

The chaining was nice before, but also a bit confusing, because you could do something nonsensical like srv.Proxy(addr).Proxy(addr).Proxy(addr) with no real indication that it's a strange thing to do. You can of course still do this but you have to really try.

I like seeing "proxy" and "reverseProxy" side by side, with a bit of symmetry: they both have an upstream but one is to a service and the other is to an address reverse-proxied through the host. EDIT: To be clear I like the symmetry in shape but am still totally open to being sold on different terms if "reverse proxy" / "upstream" aren't universal enough.

@shykes

shykes commented Aug 8, 2023

Copy link
Copy Markdown
Contributor

Why not take advantage of WithServiceBinding to specify network dependency? More DRY and will be more flexible in future iterations of the design, also more familiar when debugging in an interactive shell.

@vito

vito commented Aug 8, 2023

Copy link
Copy Markdown
Contributor Author

@shykes Not sure what you mean - C2H already leverages WithServiceBinding:

host := c.Host().ReverseProxy(localDialAddr, 80)

for _, content := range []string{"yes", "no", "maybe", "so"} {
	out, err := c.Container().
		From(alpineImage).
		WithServiceBinding("www", host).
		WithExec([]string{"wget", "-O-", "http://www/?content=" + content}).
		Stdout(ctx)
	require.NoError(t, err)
	require.Equal(t, content+"\n", out)
}

For H2C there isn't anything to call WithServiceBinding against since you're just mutating host state.

@shykes

shykes commented Aug 8, 2023

Copy link
Copy Markdown
Contributor

For H2C there isn't anything to call WithServiceBinding against since you're just mutating host state.

I think it’s beneficial for H2C and C2H to both rely on the same primitive, namely: an actual proxy running in a container. One of the benefits (there are several) is that you can use WithServiceBinding the usual way for H2C.

From there it’s a small step to saying “why have two different functions when it’s the same proxy under the hood, just wired differently; what if I want to combine or swap c2h and h2c forward rules in the same proxy etc” hence: a single host { proxy} which can be configured for h2c, c2h or both.

Now I understand your “swiss army knife” comment, I see how it would feel contrived to have the same type for c2h and h2c if the underlying primitive were completely different.

@vito

vito commented Aug 8, 2023

Copy link
Copy Markdown
Contributor Author

@shykes I'm confused. 🤔 Why would I want a proxy running in a container for H2C when I already have the service itself running in a container? Wouldn't that just put me back at square 1? I'd need to figure out how to route traffic from the host to the proxy container.

I also don't know what "using WithServiceBinding the usual way" would mean. In the API, what would I call WithServiceBinding against for H2C?

My impression is that the symmetry of the terms H2C and C2H make it really tempting to fully align them on the same primitives, but in practice they're not similar at all, and it's a total red herring. They have fundamentally different requirements, and fully aligning them is either impossible or more confusing than it's worth. Even if we're able to align the primitives, it doesn't necessarily result in a more intuitive API.

The design for H2C is based on two features: Docker Compose-style service port publishing, and Testcontainers-style ephemeral service addresses for tests (hence allowing to bind on :0). I don't see how these could be implemented in the same way as C2H, since you fundamentally need some special sauce to allow listening for traffic from the host side.

@gerhard

gerhard commented Aug 9, 2023

Copy link
Copy Markdown
Contributor

I am stopping here for the day, but I intend to pick this one up tomorrow.

Do we want this to be in v0.8.2 @vito @sipsma @shykes ?

@vito

vito commented Aug 9, 2023

Copy link
Copy Markdown
Contributor Author

@gerhard It's a breaking change, so it should be v0.9. Also still pending API bikeshedding, so not ready yet.

@sipsma

sipsma commented Aug 9, 2023 •

Copy link
Copy Markdown
Contributor

Dropping a random thought before I forget; in theory c2h h2c would allow us to get rid of the need for ./hack/dev to export to docker (which is slow and consumes disk space), instead just running it as a service.

I think the main thing that would be missing is we'd ideally want some notion of a "long-running service independent of any one session", but if there's any hack to work around that doesn't cause problems (e.g. background a dagger client that keeps the service running in such a way that isn't fragile), this would be a really nice dogfooding opportunity.

Feel free to ignore, most likely too far outside the scope of this PR, just wanted to mention.

@shykes

shykes commented Aug 10, 2023 •

Copy link
Copy Markdown
Contributor

@vito I was picturing the h2c proxy as a container with special routing attached to it (to get traffic to and from the host) but otherwise still a regular container, because that way you could start/stop them, open a shell into them, possibly customize them with extensions later, any future instrumentation of services (middleware to monitor egress/ingress, future multi-host networking etc) would just magically work because it relies on an underlying container implementation.

BUT!

Perhaps that should be purely an implementation concern. If I ignore the implementation and look only at interfaces, I understand your preference for two simple primitives, with just enough symmetry, rather than a swiss army knife proxy type. I can see the elegance of it and I trust your taste.

AND!

If we’re not going for a swiss army proxy type, I think perhaps “proxy” is not the best term, because it does evoke a swiss army knife, typically with multiple rules to route traffic to or from multiple services. In the current proposal
they are more like single-service proxies, which doesn’t fit the word as well.

Maybe we don’t need a new word at all? Maybe it’s just services? How about this:

extend type Host {
  “Make a service reachable from the host”
  withServiceBinding(
    "The service to bind”
    service: ServiceID!

    "Optional port offset to avoid conflicts"
    portOffset: Int
  ): Host!

  "An external service running on the host network”
  service(
    host: String = “localhost”
    port: Int!
    protocol: NetworkProtocol = TCP
  ): Service!
}

@vito
vito force-pushed the services-v2-c2h-h2c branch 2 times, most recently from bc76ae6 to ce2d828 Compare August 10, 2023 14:18
vito added 8 commits October 18, 2023 15:29
this doesn't work when there are breaking changes (noted in two
comments)

Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
This reverts commit 1807036.

Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
misinterpreted the failure, and this actually causes ci failure

Signed-off-by: Alex Suraci <[email protected]>
@vito
vito force-pushed the services-v2-c2h-h2c branch from f205dc3 to ec202e9 Compare October 18, 2023 19:58
Signed-off-by: Alex Suraci <[email protected]>
.asService()

// expose HTTP service to host
const tunnel = client.host().tunnel(httpSrv).start()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const tunnel = client.host().tunnel(httpSrv).start()
const tunnel = await client.host().tunnel(httpSrv).start()

@vito

vito commented Oct 18, 2023

Copy link
Copy Markdown
Contributor Author

This PR has gotten a bit unwieldy, so I plan to merge as soon as the CI is green now that we have a solid start on the documentation, and we already have a few breaking changes merged anyway. We can continue working on docs/blog posts in a separate PR. Will need an approval first though. 🙏

vito added 2 commits October 18, 2023 17:12
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
@sipsma

sipsma commented Oct 18, 2023 •

Copy link
Copy Markdown
Contributor

@vito looking again quick, in meantime does this test failure look meaningful? #5919 Sorry, wrong link 😅 https://github.com/dagger/dagger/actions/runs/6566668161/job/17837828358?pr=5557#step:4:30037

@sipsma sipsma left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM on another quick skim!

# Use Services in Dagger

:::warning
Dagger v0.8.8 includes a breaking change for binding service containers to containers. The `Container.withServiceBinding` API now takes a `Service` instead of a `Container`, so you must call `Container.asService` on its argument. See the section on [binding container services to containers](#bind-service-containers-to-containers) for examples.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non-blocking, but v0.8.8 is out of date right? It appears again in this file a few times below

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch - bumped to v0.9.0 👍

@vito

vito commented Oct 19, 2023

Copy link
Copy Markdown
Contributor Author

@vito looking again quick, in meantime does this test failure look meaningful? #5919 Sorry, wrong link 😅 https://github.com/dagger/dagger/actions/runs/6566668161/job/17837828358?pr=5557#step:4:30037

@sipsma I've seen that test fail on main too, seems like there's a flake afoot. 😢

The Python SDK tests are also failing for reasons I can't quite grok - it passes locally, and it passed in CI before after 3 attempts. 🤔 cc @helderco

I'll re-run both to get everything green but I'll hold off on merging until tomorrow in case there's something genuinely broken there that I'm missing (very possible with how many merge conflicts I've had to resolve at this point).

@sipsma

sipsma commented Oct 19, 2023

Copy link
Copy Markdown
Contributor

The Python SDK tests are also failing for reasons I can't quite grok - it passes locally, and it passed in CI before after 3 attempts. 🤔

@vito That python flake in particular should hopefully be fixed by this PR: https://github.com/dagger/dagger/pull/5919/files

The other one, I looked quickly later when I had a sec, I'm pretty sure we just are closing the dagger client before DONE is received in the progress output; so a flake but not meaningful and not a blocker for here.

@vito

vito commented Oct 19, 2023 •

Copy link
Copy Markdown
Contributor Author

The other one, I looked quickly later when I had a sec, I'm pretty sure we just are closing the dagger client before DONE is received in the progress output; so a flake but not meaningful and not a blocker for here.

The weird thing is that Close is supposed to synchronize on this to ensure all services are spun down (hence the service being DONE) and that all logs are flushed. So this could be a genuine bug, or some other flakiness in the test, but I think it exists on main already. Will keep an eye on this.

@vito
vito merged commit 33cdd12 into dagger:main Oct 19, 2023
@vito
vito deleted the services-v2-c2h-h2c branch October 19, 2023 02:41
schlapzz pushed a commit to schlapzz/dagger that referenced this pull request Nov 24, 2023
… via gateway (dagger#5557)

* h2c: reuse buf, set to 32k (same as io.Copy)

Signed-off-by: Alex Suraci <[email protected]>

* c2h: don't treat dial errors as fatal

Signed-off-by: Alex Suraci <[email protected]>

* c2h: set timeout for container release

matched 30 seconds to a timeout we set elsewhere on the same thing

Signed-off-by: Alex Suraci <[email protected]>

* Service.Clone: clone ports too

Signed-off-by: Alex Suraci <[email protected]>

* multierror -> errors.Join

Signed-off-by: Alex Suraci <[email protected]>

* h2c: cancel on server close

Signed-off-by: Alex Suraci <[email protected]>

* un-globalize AllServices

and get rid of WithServices because generic methods aren't supported and
wrappers are annoying anyway

Signed-off-by: Alex Suraci <[email protected]>

* fix premature cancel()

Signed-off-by: Alex Suraci <[email protected]>

* split Services out into a separate file, add godoc

lots of tricky behavior, worth documenting

Signed-off-by: Alex Suraci <[email protected]>

* elixir SDK: support INPUT_OBJECT

unclear why this is needed now, when we already have BuildArg

Signed-off-by: Alex Suraci <[email protected]>

* add changelog

Signed-off-by: Alex Suraci <[email protected]>

* make services no longer experimental

Couldn't find any instances on GitHub of anyone disabling this, and
there are no known open issues.

Code Search query:

    _EXPERIMENTAL_DAGGER_SERVICES_DNS AND (NOT "Currently experimental" OR "to running the Dagger Engine")

Signed-off-by: Alex Suraci <[email protected]>

* regen SDKs

Signed-off-by: Alex Suraci <[email protected]>

* disable engine-in-engine-dev for now

Signed-off-by: Alex Suraci <[email protected]>

* fix progrock deprecations/removals

Signed-off-by: Alex Suraci <[email protected]>

* testdata/nested -> testdata/nested-c2c

Signed-off-by: Alex Suraci <[email protected]>

* tests: client.Close cleanups

Signed-off-by: Alex Suraci <[email protected]>

* Zenith episode two: revenge of the function

Signed-off-by: Solomon Hykes <[email protected]>

* core: baseline core schema implementation for envs+checks.

Signed-off-by: Erik Sipsma <[email protected]>

* WIP module+function graphql schemas

Signed-off-by: Erik Sipsma <[email protected]>

* WIP modules+functions implementation

Signed-off-by: Erik Sipsma <[email protected]>

* WIP go sdk updates

Signed-off-by: Erik Sipsma <[email protected]>

* base working functions w/ go sdk

Signed-off-by: Erik Sipsma <[email protected]>

* update module test connect usage

Signed-off-by: Alex Suraci <[email protected]>

* disable depguard lint

not sure why we would want this, it fails locally on innocuous imports

Signed-off-by: Alex Suraci <[email protected]>

* disable unused param linters

These have mostly just been frustrating and unhelpful, usually resulting
in worse code than before.

Signed-off-by: Alex Suraci <[email protected]>

* fix up lints

Signed-off-by: Alex Suraci <[email protected]>

* support id-able types as inputs; extending core types

Signed-off-by: Erik Sipsma <[email protected]>

* fix support for chainable types

Signed-off-by: Erik Sipsma <[email protected]>

* ignore non-fatal compile errors

These we're causing annoying situations where you change a function
signature in user code, run `dagger mod sync` and then codegen gets a
compilation error because the old main func is incompatible with the new
signature and hasn't been updated yet.

Just ignoring these sorts of errors avoids this situation and doesn't
really cause any harm. We can still try parse the code and generate from
there. If the end result is still not compilable, then it just won't be
runnable.

Signed-off-by: Erik Sipsma <[email protected]>

* flesh out zenith intro instructions, add demo mod

zenith/ is now has an .envrc, making it suitable as a temporary
playground for writing Zenith modules

Signed-off-by: Alex Suraci <[email protected]>

* bump Go runtime to 1.21

otherwise fresh mods created with 1.21 fail on 'go 1.21.0' in go.mod

Signed-off-by: Alex Suraci <[email protected]>

* query: fix --progress=plain requirement

Signed-off-by: Alex Suraci <[email protected]>

* fix sdk/go unit tests

Signed-off-by: Alex Suraci <[email protected]>

* codegen: generate querybuilder/ package

fixes go mod replace issue

Signed-off-by: Alex Suraci <[email protected]>

* mod init: bootstrap Go module

This is a really delicate dance. For whatever reason Go doesn't like
these go.mod/go.sum files hoisted over from sdk/go/ and requires you to
run `go mod tidy`, otherwise it complains about entries missing from
go.sum, which is confusing because it works just fine for the SDK.

So the order of operations is:

* Detect if a main package exists.
* If it doesn't, write an initial main.go file before we even start
  doing codegen, otherwise the initial codegen won't have anything to
  process.
* Run code generation.
* Write initial go.mod/go.sum files with a sane default Go module name
  based on the outer module.
  * If no outer module is found, the bare Dagger module name is used and
    a warning is printed.
* Run go mod tidy.

The last step is critical; without it, dagger mod sync will error on the
same errors mentioned in the first paragraph.

Signed-off-by: Alex Suraci <[email protected]>

* support multiple passes for codegen

There's a chicken/egg problem with running codegen and generating stub
templates. If the template refers to a type like Container, the
introspection will have no idea what that refers to on the first pass.
So we need to do one pass to generate all the base types, and then
another pass to generate from the stub.

Signed-off-by: Alex Suraci <[email protected]>

* fix post-merge compilation errors

Signed-off-by: Alex Suraci <[email protected]>

* un-break cmd/client-gen

Signed-off-by: Alex Suraci <[email protected]>

* re-bump progrock for ioctl fix

Signed-off-by: Alex Suraci <[email protected]>

* respect existing .gitattributes

Signed-off-by: Alex Suraci <[email protected]>

* update core/integration for input pointer change

not completely sure if we want this, rolling with it for now

pros:

* everything is always a pointer, don't need to special-case input types
  vs regular types

cons:

* breaking change
* plain input types don't feel as intuitive as pointers

Signed-off-by: Alex Suraci <[email protected]>

* codegen: respect existing go.mod

Signed-off-by: Alex Suraci <[email protected]>

* listen: add --allow-cors

makes it easy to use off-the-shelf GraphQL inspectors

Signed-off-by: Alex Suraci <[email protected]>

* support non-local module dependencies

Signed-off-by: Alex Suraci <[email protected]>

* fix TypeDef { kind } resolving to 'null'

Signed-off-by: Alex Suraci <[email protected]>

* fix uninterruptible codegen

Signed-off-by: Alex Suraci <[email protected]>

* query: unfocus by default

Signed-off-by: Alex Suraci <[email protected]>

* bump progrock to avoid printing TUI to redirected stderr

Signed-off-by: Alex Suraci <[email protected]>

* use a single strcase package

Signed-off-by: Alex Suraci <[email protected]>

* fix module dependencies not loading

(this is thanks to a flying Erik)

Signed-off-by: Alex Suraci <[email protected]>

* Module: expose sdk, dependencies, source dir

To be used in Da Daggerverse.

Signed-off-by: Alex Suraci <[email protected]>

* dagger mod extend -> use

Signed-off-by: Alex Suraci <[email protected]>

* fix always getting description of first func

Signed-off-by: Alex Suraci <[email protected]>

* expose dependency configs

this helps daggerverse crawl a module recursively, since otherwise it
can't know how people should fetch the module

Signed-off-by: Alex Suraci <[email protected]>

* new module ref format, resolve at use time

The new format is Go module style:

  github.com/foo/bar/subpath@version

In dagger.json, the version will _always_ be a commit. The CLI accepts
any ref; it will be resolved by dagger mod use.

This format might change again, since there are gotchas that make this
hard to support in the general case (e.g. GitLab's arbitrarily-nested
repo URIs). but this is easier on the eyes. We probably also want to
stick with semver tags rather than commits. I'll figure that out next.

It would be nice if there was an easy-on-the-eyes scheme that was
totally unambiguous as to whether the provided ref is a branch, tag, or
commit, and which part is the repo and which part is the subpath.

Signed-off-by: Alex Suraci <[email protected]>

* fix uninterruptible package loading

Signed-off-by: Alex Suraci <[email protected]>

* thread ctx through to template packages.Load too

Signed-off-by: Alex Suraci <[email protected]>

* fix a couple of rogue filepath.Dirs

Signed-off-by: Alex Suraci <[email protected]>

* support distinguishing git commit from desired tag

in practice these are both just commits until semver tags are supported

Signed-off-by: Alex Suraci <[email protected]>

* fix -m with git ref

Signed-off-by: Alex Suraci <[email protected]>

* Added example to README

Signed-off-by: Vikram Vaswani <[email protected]>

* Fixed indentation in README example

Signed-off-by: Vikram Vaswani <[email protected]>

* tweak git docs

Signed-off-by: kpenfound <[email protected]>

* revise README

* avoid ./zenith/zenith
* avoid reusing Vito module name for 'create your own' flow
* add caveat for extending core types

Signed-off-by: Alex Suraci <[email protected]>

* Zenith README: chaining example

Signed-off-by: Solomon Hykes <[email protected]>

* Zenith README: fix errors

Signed-off-by: Solomon Hykes <[email protected]>

* fix: dagger mod use should override previous versions

Previously, dagger mod use would allow creating multiple versions of a
single module:

	{
	  "root": "",
	  "name": "foo",
	  "sdk": "go",
	  "dependencies": [
	    "github.com/<example>/daggerverse@aaa"
	    "github.com/<example>/daggerverse@bbb"
	  ]
	}

To prevent this, we can resolve all the dependencies, and then use the
dependency set based on only the path instead of the combination of path
and version.

Signed-off-by: Justin Chadwell <[email protected]>

* non-error returns, void returns, optional ctx

Signed-off-by: Alex Suraci <[email protected]>

* bump graphql for explicit scalar error handling

otherwise it's impossible to have a JSON scalar that evaluates to null
(which is how void return values are represented), since it gets treated
as an error

Signed-off-by: Alex Suraci <[email protected]>

* fix lints

Signed-off-by: Alex Suraci <[email protected]>

* skip non-working env tests

Signed-off-by: Alex Suraci <[email protected]>

* avoid panic if proxy env not set

likely an underlying bug here though; env should be set

Signed-off-by: Alex Suraci <[email protected]>

* fix services not having ProxyEnv

this used to be baked into the DAG as part of WithExec, but that moved
to Client.Solve, so we need to do the same thing here.

Signed-off-by: Alex Suraci <[email protected]>

* allow non-ctx first arg

Signed-off-by: Alex Suraci <[email protected]>

* sdk/go modules support Opts args

This is an alternative format to regular args that allows you to accept
optional args with default values.

There's a slight smell that defaults aren't applied for
function-to-function calls within the module. It might not be worth
having the default:"..." tag for that reason, but it's nice to have them
in the GraphQL schema.

Signed-off-by: Alex Suraci <[email protected]>

* refactor for gocyclo lint

Signed-off-by: Alex Suraci <[email protected]>

* add test for custom types

Signed-off-by: Alex Suraci <[email protected]>

* fix not including functions for custom types

this fix is a bit hacky (bool arg, whee); the long-term fix is to
refactor the schema so that modules can provide multiple Object types,
instead of relying on crawling the module's own functions

Signed-off-by: Alex Suraci <[email protected]>

* fix: prevent Directory.Without from failing on missing files

Other similar Without methods, such as `container.WithoutMount` do not
fail if the target is not present.

However, previously in BuildKit, the llb.WithAllowNotFound was never
explicitly required. Updating to the newer BuildKit correctly respects
this option, so we need to include llb.WithAllowNotFound directly.

Signed-off-by: Justin Chadwell <[email protected]>

* don't recursively load packages

attempting to peacefully coexist with tools like goenv and asdf, don't
think this ever needed to be recursive

Signed-off-by: Alex Suraci <[email protected]>

* fix: apply ToLowerCamel consistently

Signed-off-by: Justin Chadwell <[email protected]>

* fix + test using local modules

Signed-off-by: Alex Suraci <[email protected]>

* switch from input types to withFoo pattern

Previously functions and types were represented as input types, which
was a little inconvenient in two ways:

* You can't return an input type, so any type that needed to be returned
  had a duplicate 'regular' type definition.
* One of the input types (TypeDef) was self-referential, meaning we had
  to switch to pointers for input types, which was a breaking change for
  things like BuildArg (which still needs to be rolled back).

This commit changes TypeDef to use the more familiar withFoo style of
construction instead, and adds a TypeDefID so that it can be passed as
an input.

A possible downside here is that the module's entrypoint that registers
all the objects might involve multiple API calls to pass IDs around. I
haven't measured performance, but it's certainly hard to beat passing
all of the information in as one big precomputed type.

Signed-off-by: Alex Suraci <[email protected]>

* Make engine version overrideable

Signed-off-by: Solomon Hykes <[email protected]>

* dagger version also prints worker registry address

Signed-off-by: Solomon Hykes <[email protected]>

* debugging module failure

Signed-off-by: Alex Suraci <[email protected]>

* fix references to other objects

Signed-off-by: Alex Suraci <[email protected]>

* only unmarshal opts that are present

Signed-off-by: Alex Suraci <[email protected]>

* fix passing lists to functions

Signed-off-by: Alex Suraci <[email protected]>

* fix self-referential (chaining) types

Signed-off-by: Alex Suraci <[email protected]>

* un-weird container.Clone

this was causing panics to happen at a later time, not sure if/why it's
needed or leftover debugging

Signed-off-by: Alex Suraci <[email protected]>

* fixup remove logs

confirmed everything was ok

Signed-off-by: Alex Suraci <[email protected]>

* register multiple objects

Previously we would only register the main module, which only allowed
functions on types referenced and embedded in the module's own TypeDefs
to be registered.

Now we'll instead register each object separately, with shallow
references to other types embedded.

Along the way, fixed an issue that I was able to reproduce with
self-referential types:

  vito/dagger-gitutil@d919459

The function was being called with an empty ModuleID. I checked to see
if it was a regression and it seemed to be broken in a different way
before (circular reference in TypeDef somehow).

Signed-off-by: Alex Suraci <[email protected]>

* remove overly defensive guard

this was mostly for debugging

Signed-off-by: Alex Suraci <[email protected]>

* fix extending existing types

Signed-off-by: Alex Suraci <[email protected]>

* only stitch module constructor, not all types

This was never the intention, and seems to be breaking shykes/dagger.

I think we might just want to let users define explicit constructors or
something. Maybe by defining methods on *Client? (Ideally that'd be *DAG
or something instead.)

Signed-off-by: Alex Suraci <[email protected]>

* Add minimal Python support

Signed-off-by: Helder Correia <[email protected]>

* go codegen: preserve definition order, pretty-print

Signed-off-by: Alex Suraci <[email protected]>

* fix code that can't run anyway, explain why

Signed-off-by: Alex Suraci <[email protected]>

* roll back debugging code

Signed-off-by: Alex Suraci <[email protected]>

* Add git to the Python runtime

Signed-off-by: Helder Correia <[email protected]>

* mount dagger CLI to /bin/dagger when nesting

Motivated by the next commit, but seems like a worthwhile experiment in
its own right.

Signed-off-by: Alex Suraci <[email protected]>

* goruntime: run dagger mod sync before building

This way you don't need to commit all the generated code.

A better way to approach this would be to move this responsibility into
a pluggable runtime image, which technically we're doing, just in a
round-about way. Maybe runtimes can just be external images.

Signed-off-by: Alex Suraci <[email protected]>

* fix setting empty field description

Signed-off-by: Alex Suraci <[email protected]>

* remove now-superfluous mod sync commands

codegen now happens on-the-fly

Signed-off-by: Alex Suraci <[email protected]>

* add TESTFLAGS="-foo -bar ./baz/" engine:testcustom

Signed-off-by: Alex Suraci <[email protected]>

* test wrapping/unwrapping core types

Signed-off-by: Alex Suraci <[email protected]>

* only generate main.go if it doesn't already exist

Signed-off-by: Alex Suraci <[email protected]>

* fix a couple of module loading bugs

TestModuleGoUseLocal has been driving my crazy - it was failing in CI,
and in ./hack/make engine:test, but succeeding with ./hack/dev go test!

I had also previously seen it fail by allowing `dagger query` to hit
transitive dependencies, but it would sometimes to pass.

The latest flavor of failure is because (*Client).Dep is not defined in
the generated code for the Use module (which uses a dep called Dep). The
root cause turned out to be two bugs interacting:

* The schema stitching process was checking for pre-existing types by
  querying the currentSchemaView, which seemed to be the "" schema view,
  rather than checking the view that's being extended.

* The dagger CLI was calling .Serve on each dependency, which caused
  them to be stitched in to the "" schema view.

As a result, Dep's schema wasn't being fully generated into the view
because the stitching process saw that it was installed in the "" view.

The first fix is to simply stop calling Serve for dependencies in the
CLI. Dependencies are already served to the dependent module's schema
view at FromConfig time, so this isn't necessary for codegen. I may have
added this by mistake while figuring out how everything works. Not sure.

The second fix is to check against the destination schema view to
determine whether things are already defined, rather than checking
against the "" schema view. This just feels more correct in general. It
mostly worked before because the "" schema view and the destination
schema view always started from the schema of all core types, but
technically if someone loaded a module into the "" schema you'd get the
same breakage observed here.

Signed-off-by: Alex Suraci <[email protected]>

* fix lints

Signed-off-by: Alex Suraci <[email protected]>

* sdk/nodejs: handle reserve words, regen

now appends _ to any word that is reserved in JavaScript/TypeScript.
chiefly "function."

Signed-off-by: Alex Suraci <[email protected]>

* pythonruntime: fmt

Signed-off-by: Alex Suraci <[email protected]>

* draft some GraphQL API docs

Signed-off-by: Alex Suraci <[email protected]>

* regen rust

Signed-off-by: Alex Suraci <[email protected]>

* regen elixir sdk

had to manually revert the original changes first; SDK regen doesn't
remove no-longer-needed files (e.g. environment.ex)

Signed-off-by: Alex Suraci <[email protected]>

* sdk/nodejs: allow from and export without _

this was working before, so let's stick with it.

Signed-off-by: Alex Suraci <[email protected]>

* regen go, python, nodejs

Signed-off-by: Alex Suraci <[email protected]>

* regen java

Signed-off-by: Alex Suraci <[email protected]>

* Abandon black's preview style

Signed-off-by: Helder Correia <[email protected]>

* add basic test for extending core types

intentionally covers the smallest example: extending a core type, while
defining no additional types or functions of our own. previously this
did not work because only types discoverable by crawling the module's
functions would be added.

Signed-off-by: Alex Suraci <[email protected]>

* Add support for new scalars JSON, Void, ModuleID, FunctionID, TypeDefID in Java SDK

Signed-off-by: Jean-Christophe Sirot <[email protected]>

* refactor + test codegen

trying to move this into a higher-level API that SDK codegen, `dagger
mod sync`, and Runtimes can all use directly

Signed-off-by: Alex Suraci <[email protected]>

* dagger mod init: test and handle more situations

also generally clean up and consolidate logging/progrock usage

Signed-off-by: Alex Suraci <[email protected]>

* move querybuilder back under ./internal/

Signed-off-by: Alex Suraci <[email protected]>

* go codegen: .gitignore generated files

Signed-off-by: Alex Suraci <[email protected]>

* fix modules_test.go

Signed-off-by: Alex Suraci <[email protected]>

* refactor codegen order, .gitignore generated files

also remove previously-committed generated files along the way

Signed-off-by: Alex Suraci <[email protected]>

* fix loading not-generated package

Signed-off-by: Alex Suraci <[email protected]>

* move git tests to separate

Signed-off-by: Alex Suraci <[email protected]>

* clean up and regen modules

Signed-off-by: Alex Suraci <[email protected]>

* HACK: add cache buster

this codegen really needs to be put into the image

Signed-off-by: Alex Suraci <[email protected]>

* load non-module package, too

needed for sdk:go:generate

Signed-off-by: Alex Suraci <[email protected]>

* remove unused func

Signed-off-by: Alex Suraci <[email protected]>

* fix handling of root: .., support outer go.mod

Signed-off-by: Alex Suraci <[email protected]>

* generate base dagger.gen.go if it doesn't exist

otherwise you can end up stuck with code that refers to unknown types if
you deleted the file

Signed-off-by: Alex Suraci <[email protected]>

* fix tricky ordering, yay tests

Signed-off-by: Alex Suraci <[email protected]>

* disable crippling memoization

Signed-off-by: Solomon Hykes <[email protected]>

* module-ize codegen by moving it under sdk/go

Here's the plan: each SDK provides a module for running codegen against
user modules.

These SDK modules replace the runtimes that current live in core. Once
bootstrapped, they can be pushed to an image registry and invoked from
the CLI.

For the Go SDK this works out nicely because codegen already depended on
the SDK client, so now it can just live in the same module.

For now, the NodeJS codegen also made the trip into sdk/go/.
Theoretically this codegen could be split out into a separate module,
but right now the juice isn't worth the squeeze. The dagger.io/dagger
module is already oriented the right way dependency-wise.

Signed-off-by: Alex Suraci <[email protected]>

* use bootstrapped vito/dagger-sdk-go image

This was tricky: now when we're loading a module we _also_ need to load
its SDK module and call its function to build the runtime. Loading
modules and calling functions currently actually lives in core/schema/,
while constructing a module and setting up the runtime lives in core/,
so for now I've just hacked a callback function into
(core.Module).FromConfig, which lets me call back to core/schema/.

There's a specific interface that SDK modules must implement, currently
totally ad-hoc, worth bikeshedding:

  moduleRuntime(modSource: DirectoryID!, subPath: String): Container!

Signed-off-by: Alex Suraci <[email protected]>

* tidy up runtime bootstrapping

Previously this passed the _dependent_ module's source path + dir to the
SDK which was completely bogus. now it uses the SDK's. I'm starting to
suspect this didn't actually work before, and I was being fooled by
aggressive function caching, _or_ the fact that my 'with-dev' helper was
actually running the wrong CLI.

Now we use a special label to get the path to the module config. Not
totally sure about this. Committing mostly as a checkpoint.

Signed-off-by: Alex Suraci <[email protected]>

* avoid blank line at start of .gitignore

Signed-off-by: Alex Suraci <[email protected]>

* avoid generating bogus go.mod

Signed-off-by: Alex Suraci <[email protected]>

* Directory.asModule can be given a pre-built runtime

This is useful for bootstrapping SDKs (see next commit).

Signed-off-by: Alex Suraci <[email protected]>

* sdk/go: add bootstrapping for runtime image

We are now fully independent from the goruntime code currently living on
zenith-functions! See help.txt for details.

Signed-off-by: Alex Suraci <[email protected]>

* fully decouple dagger CLI from SDK codegen

* SDK runtime modules are now used for codegen, exposed as
  Module.generatedCode for ease of consumption
* Dagger CLI now hardcodes a mapping from SDK name ("go") to a pre-built
  SDK runtime image, currently pointing to a personal image ref. In
  practice we'll likely want to push these to tags that match the engine
  version.
* Dagger CLI now places the runtime image ref in dagger.json, which is
  the new source of truth for the module runtime.
* Merged core/moduleconfig/ and core/resolver/ into sdk/go/modules/.
  These are both critical for codegen, and make sense to expose in a
  stable library so that things like Daggerverse can use it.

Signed-off-by: Alex Suraci <[email protected]>

* sdk/go: fix generating empty object stub

this is actually just removing complexity that doesn't need to be around
anymore

Signed-off-by: Alex Suraci <[email protected]>

* sdk/go: build image on linux/amd64 and linux/arm64

Signed-off-by: Alex Suraci <[email protected]>

* fix constructing container from ID dropping platform

Signed-off-by: Alex Suraci <[email protected]>

* refactor sdk name => runtime flow, fix backwards compat

Signed-off-by: Alex Suraci <[email protected]>

* cache internal module calls

With SDKs as modules, this VERY quickly stacks up!

Caches the call to load the module, and the calls to the SDK runtime.
Everything else remains uncached. dagger mod sync is back to sub-0.5s.

Signed-off-by: Alex Suraci <[email protected]>

* silence that pesky version compatibility check

* Skip the entire call when connecting internally, to save time
* Log at Debug level for remaining cases where it makes sense to keep
  the check. If I'm already developing, I don't need to be warned about
  it all the time.

Signed-off-by: Alex Suraci <[email protected]>

* fix zero-ing out SDKRuntime when no SDK name set

Signed-off-by: Alex Suraci <[email protected]>

* show progress during codegen

kinda neat; directly uses progrock.sock for dagger mod sync, and just
uses local console output for on-the-fly codegen to avoid noise

Signed-off-by: Alex Suraci <[email protected]>

* add GeneratedCode type so codegen can give VCS hints

Now that codegen happens remotely, it doesn't make sense at all for it
to attempt to automate your local git repository. It also is hokey for
each SDK to concern itself with all the different kinds of VCSes. Git is
obviously dominant today, but there's no reason to make it the only
option at the SDK layer.

Instead SDKs now return a GeneratedCode type which lists file paths to
ignore and/or file paths to mark as generated. The CLI picks these up
and takes it from there.

Adding a whole new ID-able type took a bit of boilerplate, but it seems
worth it, and hopefully this pattern becomes cheaper with v2 IDs.

Signed-off-by: Alex Suraci <[email protected]>

* fix: don't use --vcs flag

not a thing anymore

Signed-off-by: Alex Suraci <[email protected]>

* Bust Function runtime cache once per-session.

Using a timestamp to bust function execution results in every call to a
function resulting in the full DAG of "internal" function calls (i.e.
calls to other functions from the implementation of one function) to be
walked along every possible path, which has exponential time complexity
and thus can cause genuine performance problems.

Now we instead use the server ID, which is randomly generated once per
session, to bust so that we still cache within the context of a single
session and thus avoid the poor time complexity.

Signed-off-by: Erik Sipsma <[email protected]>

* remove dead code

Signed-off-by: Alex Suraci <[email protected]>

* fix a couple of tests

Signed-off-by: Alex Suraci <[email protected]>

* fix gitignore path already there check

Signed-off-by: Alex Suraci <[email protected]>

* fix up go/nodejs codegen

Signed-off-by: Alex Suraci <[email protected]>

* bump sdk

Signed-off-by: Alex Suraci <[email protected]>

* regen python and java, fix python lint

Signed-off-by: Alex Suraci <[email protected]>

* Handle field parameters colliding with java keywords by prepending with a '_'.
Upgrade `TestWithDatabase` sample code with the new Service API

Signed-off-by: Jean-Christophe Sirot <[email protected]>

* fix: consistent errors for non-existent module directory

Previously, when a module was not provided for the dagger query command
using the `-m` flag, the error message did not indicate that the module
did not exist even when it was requested by the user.

This patch reworks the logic - dagger query will now always error if the
module provided by `-m` did not exist, but will keep the desired
behaviour that it should not error if the current directory is not a
module.

Signed-off-by: Justin Chadwell <[email protected]>

* fix: dagger mod init should require sdk and name args

We were previously calling the wrong function to do this.

Signed-off-by: Justin Chadwell <[email protected]>

* Add `dagger call` command

This is very WIP, just publishing so others can hack on it. Only supports "top-level" (from type that matches current module) functions without arguments and only tested functions that return a string.

Added `ParentName` to `core.Function` to fix a direct `dagger.Function.Call`. It used to work but is failing due to recent changes while unmarshaling input. However, since we plan to make a chained call, it's better to build a query instead of calling the functions directly.

See TODO list at the top for follow-ups.

Signed-off-by: Helder Correia <[email protected]>

* Small linting fix

Signed-off-by: Helder Correia <[email protected]>

* backport dagger shell

Signed-off-by: Erik Sipsma <[email protected]>

* chore: dagger shell branch: fix conflicts

Signed-off-by: grouville <[email protected]>

* fix: mount the correct dependency sub-folder

Without this, we can end up caching the wrong top-level directory.

Signed-off-by: Justin Chadwell <[email protected]>

* cleanup egregious stuff from dagger shell impl

Signed-off-by: Erik Sipsma <[email protected]>

* fix go sdk lints

Signed-off-by: Erik Sipsma <[email protected]>

* appease engine lints

Signed-off-by: Erik Sipsma <[email protected]>

* fix missed engine lint

Signed-off-by: Erik Sipsma <[email protected]>

* upgrade go+golangci to see if it fixes bizarre lint fail

Signed-off-by: Erik Sipsma <[email protected]>

* fix gitignore of sdk/go/runtime

Signed-off-by: Erik Sipsma <[email protected]>

* fix + test using multiple modules

two bug fixes:

1. dagger mod use incorrectly deduped on path alone, instead of also
   considering the subpath
1. a fun mutation bug in the schema was causing all sorts of fun module
   identity crises

Signed-off-by: Alex Suraci <[email protected]>

* fix go sdk tests

Signed-off-by: Erik Sipsma <[email protected]>

* fix elixer sdk lints

Signed-off-by: Erik Sipsma <[email protected]>

* appease residual lints

Signed-off-by: Erik Sipsma <[email protected]>

* upgrade sphinx-rtd-theme to see if it fixes read-the-docs build

Signed-off-by: Erik Sipsma <[email protected]>

* use session: prefix for blobsource

Signed-off-by: Erik Sipsma <[email protected]>

* add explicit requirements.txt for python docs

As of a few days ago, readthedocs requires you to explicitly set
dependencies in a requirements.txt:
https://blog.readthedocs.com/defaulting-latest-build-tools/

Signed-off-by: Erik Sipsma <[email protected]>

* stop pointerizing input types

this was needed to avoid dependency cycles in self-referential input
types, but we don't have those anymore, in favor of just always using
objects and passing them in by their ID.

Signed-off-by: Alex Suraci <[email protected]>

* use a hyper specific tag

just trying things on

Signed-off-by: Alex Suraci <[email protected]>

* regen go sdk

Signed-off-by: Alex Suraci <[email protected]>

* regen nodejs sdk

Signed-off-by: Alex Suraci <[email protected]>

* fix up tests (botched merge somewhere)

Signed-off-by: Alex Suraci <[email protected]>

* updated services docs for pr-5557

Signed-off-by: Jenn Allen <[email protected]>

* apply docs suggestions

thanks!

Co-authored-by: vikram-dagger <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>

* Updated services guides

Signed-off-by: Vikram Vaswani <[email protected]>

* Lint fix

Signed-off-by: Vikram Vaswani <[email protected]>

* Update docs/current/guides/snippets/build-test-publish-php/dagger.php

Co-authored-by: Alex Suraci <[email protected]>
Signed-off-by: vikram-dagger <[email protected]>

* Update docs/current/guides/757394-use-service-containers.md

Co-authored-by: Alex Suraci <[email protected]>
Signed-off-by: vikram-dagger <[email protected]>

* services: adopt new IDable patterns

Signed-off-by: Alex Suraci <[email protected]>

* regen SDKs

Signed-off-by: Alex Suraci <[email protected]>

* bump go sdk

Signed-off-by: Alex Suraci <[email protected]>

* fix newly added test

Signed-off-by: Alex Suraci <[email protected]>

* Updated examples and content

Signed-off-by: Vikram Vaswani <[email protected]>

* Lint fix

Signed-off-by: Vikram Vaswani <[email protected]>

* Lint fix

Signed-off-by: Vikram Vaswani <[email protected]>

* Updated filename and paths

Signed-off-by: Vikram Vaswani <[email protected]>

* Copy edit

Signed-off-by: Vikram Vaswani <[email protected]>

* Code update

Signed-off-by: Vikram Vaswani <[email protected]>

* docs tweaks

* compromise on Foo.barBaz syntax for referring to APIs
* fix what I think was a sentence ordering glitch ('select first port'
  applies to Endpoint specifically)
* turn Host.unixSocket tip into a guidepost instead of pointing out
  internal implementation details

Signed-off-by: Alex Suraci <[email protected]>

* Container.service -> Container.asService

Signed-off-by: Alex Suraci <[email protected]>

* make python lint happy

Signed-off-by: Alex Suraci <[email protected]>

* fix awkward gofmt formatting

Signed-off-by: Alex Suraci <[email protected]>

* Added code samples

Signed-off-by: Vikram Vaswani <[email protected]>

* Lint fixes

Signed-off-by: Vikram Vaswani <[email protected]>

* comment out incorrect code in example

Signed-off-by: Vikram Vaswani <[email protected]>

* Lint fix

Signed-off-by: Vikram Vaswani <[email protected]>

* Lint fix

Signed-off-by: Vikram Vaswani <[email protected]>

* Create guide expose-host-services-to-container for the node SDK

Signed-off-by: jffarge <[email protected]>

* Create a Node.js SDK guide for start-stop-services

Signed-off-by: jffarge <[email protected]>

* Remove unused fetch library

Signed-off-by: jffarge <[email protected]>

* rename main.go to main_test.go for to test

Signed-off-by: Alex Suraci <[email protected]>

* Added Python snippets

Signed-off-by: Vikram Vaswani <[email protected]>

* decouple core from internal/mage

this doesn't work when there are breaking changes (noted in two
comments)

Signed-off-by: Alex Suraci <[email protected]>

* regen SDKs

Signed-off-by: Alex Suraci <[email protected]>

* Revert "decouple core from internal/mage"

This reverts commit 1807036.

Signed-off-by: Alex Suraci <[email protected]>

* internal/mage: move consts into separate package

Signed-off-by: Alex Suraci <[email protected]>

* sdk/go: fix go.mod

Signed-off-by: Alex Suraci <[email protected]>

* undo main_test.go rename

misinterpreted the failure, and this actually causes ci failure

Signed-off-by: Alex Suraci <[email protected]>

* tidy

Signed-off-by: Alex Suraci <[email protected]>

* fix docs link

Signed-off-by: Alex Suraci <[email protected]>

* add a couple of awaits

Signed-off-by: Alex Suraci <[email protected]>

* services docs: v0.8.8 -> v0.9.0

Signed-off-by: Alex Suraci <[email protected]>

---------

Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Solomon Hykes <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Vikram Vaswani <[email protected]>
Signed-off-by: kpenfound <[email protected]>
Signed-off-by: Justin Chadwell <[email protected]>
Signed-off-by: Helder Correia <[email protected]>
Signed-off-by: Jean-Christophe Sirot <[email protected]>
Signed-off-by: grouville <[email protected]>
Signed-off-by: Jenn Allen <[email protected]>
Signed-off-by: vikram-dagger <[email protected]>
Signed-off-by: jffarge <[email protected]>
Co-authored-by: Solomon Hykes <[email protected]>
Co-authored-by: Erik Sipsma <[email protected]>
Co-authored-by: Vikram Vaswani <[email protected]>
Co-authored-by: kpenfound <[email protected]>
Co-authored-by: Justin Chadwell <[email protected]>
Co-authored-by: Solomon Hykes <[email protected]>
Co-authored-by: Helder Correia <[email protected]>
Co-authored-by: Jean-Christophe Sirot <[email protected]>
Co-authored-by: grouville <[email protected]>
Co-authored-by: Jenn Allen <[email protected]>
Co-authored-by: vikram-dagger <[email protected]>
Co-authored-by: jffarge <[email protected]>
Signed-off-by: Christian Schlatter <[email protected]>
schlapzz pushed a commit to schlapzz/dagger that referenced this pull request Nov 24, 2023
… via gateway (dagger#5557)

* h2c: reuse buf, set to 32k (same as io.Copy)

Signed-off-by: Alex Suraci <[email protected]>

* c2h: don't treat dial errors as fatal

Signed-off-by: Alex Suraci <[email protected]>

* c2h: set timeout for container release

matched 30 seconds to a timeout we set elsewhere on the same thing

Signed-off-by: Alex Suraci <[email protected]>

* Service.Clone: clone ports too

Signed-off-by: Alex Suraci <[email protected]>

* multierror -> errors.Join

Signed-off-by: Alex Suraci <[email protected]>

* h2c: cancel on server close

Signed-off-by: Alex Suraci <[email protected]>

* un-globalize AllServices

and get rid of WithServices because generic methods aren't supported and
wrappers are annoying anyway

Signed-off-by: Alex Suraci <[email protected]>

* fix premature cancel()

Signed-off-by: Alex Suraci <[email protected]>

* split Services out into a separate file, add godoc

lots of tricky behavior, worth documenting

Signed-off-by: Alex Suraci <[email protected]>

* elixir SDK: support INPUT_OBJECT

unclear why this is needed now, when we already have BuildArg

Signed-off-by: Alex Suraci <[email protected]>

* add changelog

Signed-off-by: Alex Suraci <[email protected]>

* make services no longer experimental

Couldn't find any instances on GitHub of anyone disabling this, and
there are no known open issues.

Code Search query:

    _EXPERIMENTAL_DAGGER_SERVICES_DNS AND (NOT "Currently experimental" OR "to running the Dagger Engine")

Signed-off-by: Alex Suraci <[email protected]>

* regen SDKs

Signed-off-by: Alex Suraci <[email protected]>

* disable engine-in-engine-dev for now

Signed-off-by: Alex Suraci <[email protected]>

* fix progrock deprecations/removals

Signed-off-by: Alex Suraci <[email protected]>

* testdata/nested -> testdata/nested-c2c

Signed-off-by: Alex Suraci <[email protected]>

* tests: client.Close cleanups

Signed-off-by: Alex Suraci <[email protected]>

* Zenith episode two: revenge of the function

Signed-off-by: Solomon Hykes <[email protected]>

* core: baseline core schema implementation for envs+checks.

Signed-off-by: Erik Sipsma <[email protected]>

* WIP module+function graphql schemas

Signed-off-by: Erik Sipsma <[email protected]>

* WIP modules+functions implementation

Signed-off-by: Erik Sipsma <[email protected]>

* WIP go sdk updates

Signed-off-by: Erik Sipsma <[email protected]>

* base working functions w/ go sdk

Signed-off-by: Erik Sipsma <[email protected]>

* update module test connect usage

Signed-off-by: Alex Suraci <[email protected]>

* disable depguard lint

not sure why we would want this, it fails locally on innocuous imports

Signed-off-by: Alex Suraci <[email protected]>

* disable unused param linters

These have mostly just been frustrating and unhelpful, usually resulting
in worse code than before.

Signed-off-by: Alex Suraci <[email protected]>

* fix up lints

Signed-off-by: Alex Suraci <[email protected]>

* support id-able types as inputs; extending core types

Signed-off-by: Erik Sipsma <[email protected]>

* fix support for chainable types

Signed-off-by: Erik Sipsma <[email protected]>

* ignore non-fatal compile errors

These we're causing annoying situations where you change a function
signature in user code, run `dagger mod sync` and then codegen gets a
compilation error because the old main func is incompatible with the new
signature and hasn't been updated yet.

Just ignoring these sorts of errors avoids this situation and doesn't
really cause any harm. We can still try parse the code and generate from
there. If the end result is still not compilable, then it just won't be
runnable.

Signed-off-by: Erik Sipsma <[email protected]>

* flesh out zenith intro instructions, add demo mod

zenith/ is now has an .envrc, making it suitable as a temporary
playground for writing Zenith modules

Signed-off-by: Alex Suraci <[email protected]>

* bump Go runtime to 1.21

otherwise fresh mods created with 1.21 fail on 'go 1.21.0' in go.mod

Signed-off-by: Alex Suraci <[email protected]>

* query: fix --progress=plain requirement

Signed-off-by: Alex Suraci <[email protected]>

* fix sdk/go unit tests

Signed-off-by: Alex Suraci <[email protected]>

* codegen: generate querybuilder/ package

fixes go mod replace issue

Signed-off-by: Alex Suraci <[email protected]>

* mod init: bootstrap Go module

This is a really delicate dance. For whatever reason Go doesn't like
these go.mod/go.sum files hoisted over from sdk/go/ and requires you to
run `go mod tidy`, otherwise it complains about entries missing from
go.sum, which is confusing because it works just fine for the SDK.

So the order of operations is:

* Detect if a main package exists.
* If it doesn't, write an initial main.go file before we even start
  doing codegen, otherwise the initial codegen won't have anything to
  process.
* Run code generation.
* Write initial go.mod/go.sum files with a sane default Go module name
  based on the outer module.
  * If no outer module is found, the bare Dagger module name is used and
    a warning is printed.
* Run go mod tidy.

The last step is critical; without it, dagger mod sync will error on the
same errors mentioned in the first paragraph.

Signed-off-by: Alex Suraci <[email protected]>

* support multiple passes for codegen

There's a chicken/egg problem with running codegen and generating stub
templates. If the template refers to a type like Container, the
introspection will have no idea what that refers to on the first pass.
So we need to do one pass to generate all the base types, and then
another pass to generate from the stub.

Signed-off-by: Alex Suraci <[email protected]>

* fix post-merge compilation errors

Signed-off-by: Alex Suraci <[email protected]>

* un-break cmd/client-gen

Signed-off-by: Alex Suraci <[email protected]>

* re-bump progrock for ioctl fix

Signed-off-by: Alex Suraci <[email protected]>

* respect existing .gitattributes

Signed-off-by: Alex Suraci <[email protected]>

* update core/integration for input pointer change

not completely sure if we want this, rolling with it for now

pros:

* everything is always a pointer, don't need to special-case input types
  vs regular types

cons:

* breaking change
* plain input types don't feel as intuitive as pointers

Signed-off-by: Alex Suraci <[email protected]>

* codegen: respect existing go.mod

Signed-off-by: Alex Suraci <[email protected]>

* listen: add --allow-cors

makes it easy to use off-the-shelf GraphQL inspectors

Signed-off-by: Alex Suraci <[email protected]>

* support non-local module dependencies

Signed-off-by: Alex Suraci <[email protected]>

* fix TypeDef { kind } resolving to 'null'

Signed-off-by: Alex Suraci <[email protected]>

* fix uninterruptible codegen

Signed-off-by: Alex Suraci <[email protected]>

* query: unfocus by default

Signed-off-by: Alex Suraci <[email protected]>

* bump progrock to avoid printing TUI to redirected stderr

Signed-off-by: Alex Suraci <[email protected]>

* use a single strcase package

Signed-off-by: Alex Suraci <[email protected]>

* fix module dependencies not loading

(this is thanks to a flying Erik)

Signed-off-by: Alex Suraci <[email protected]>

* Module: expose sdk, dependencies, source dir

To be used in Da Daggerverse.

Signed-off-by: Alex Suraci <[email protected]>

* dagger mod extend -> use

Signed-off-by: Alex Suraci <[email protected]>

* fix always getting description of first func

Signed-off-by: Alex Suraci <[email protected]>

* expose dependency configs

this helps daggerverse crawl a module recursively, since otherwise it
can't know how people should fetch the module

Signed-off-by: Alex Suraci <[email protected]>

* new module ref format, resolve at use time

The new format is Go module style:

  github.com/foo/bar/subpath@version

In dagger.json, the version will _always_ be a commit. The CLI accepts
any ref; it will be resolved by dagger mod use.

This format might change again, since there are gotchas that make this
hard to support in the general case (e.g. GitLab's arbitrarily-nested
repo URIs). but this is easier on the eyes. We probably also want to
stick with semver tags rather than commits. I'll figure that out next.

It would be nice if there was an easy-on-the-eyes scheme that was
totally unambiguous as to whether the provided ref is a branch, tag, or
commit, and which part is the repo and which part is the subpath.

Signed-off-by: Alex Suraci <[email protected]>

* fix uninterruptible package loading

Signed-off-by: Alex Suraci <[email protected]>

* thread ctx through to template packages.Load too

Signed-off-by: Alex Suraci <[email protected]>

* fix a couple of rogue filepath.Dirs

Signed-off-by: Alex Suraci <[email protected]>

* support distinguishing git commit from desired tag

in practice these are both just commits until semver tags are supported

Signed-off-by: Alex Suraci <[email protected]>

* fix -m with git ref

Signed-off-by: Alex Suraci <[email protected]>

* Added example to README

Signed-off-by: Vikram Vaswani <[email protected]>

* Fixed indentation in README example

Signed-off-by: Vikram Vaswani <[email protected]>

* tweak git docs

Signed-off-by: kpenfound <[email protected]>

* revise README

* avoid ./zenith/zenith
* avoid reusing Vito module name for 'create your own' flow
* add caveat for extending core types

Signed-off-by: Alex Suraci <[email protected]>

* Zenith README: chaining example

Signed-off-by: Solomon Hykes <[email protected]>

* Zenith README: fix errors

Signed-off-by: Solomon Hykes <[email protected]>

* fix: dagger mod use should override previous versions

Previously, dagger mod use would allow creating multiple versions of a
single module:

	{
	  "root": "",
	  "name": "foo",
	  "sdk": "go",
	  "dependencies": [
	    "github.com/<example>/daggerverse@aaa"
	    "github.com/<example>/daggerverse@bbb"
	  ]
	}

To prevent this, we can resolve all the dependencies, and then use the
dependency set based on only the path instead of the combination of path
and version.

Signed-off-by: Justin Chadwell <[email protected]>

* non-error returns, void returns, optional ctx

Signed-off-by: Alex Suraci <[email protected]>

* bump graphql for explicit scalar error handling

otherwise it's impossible to have a JSON scalar that evaluates to null
(which is how void return values are represented), since it gets treated
as an error

Signed-off-by: Alex Suraci <[email protected]>

* fix lints

Signed-off-by: Alex Suraci <[email protected]>

* skip non-working env tests

Signed-off-by: Alex Suraci <[email protected]>

* avoid panic if proxy env not set

likely an underlying bug here though; env should be set

Signed-off-by: Alex Suraci <[email protected]>

* fix services not having ProxyEnv

this used to be baked into the DAG as part of WithExec, but that moved
to Client.Solve, so we need to do the same thing here.

Signed-off-by: Alex Suraci <[email protected]>

* allow non-ctx first arg

Signed-off-by: Alex Suraci <[email protected]>

* sdk/go modules support Opts args

This is an alternative format to regular args that allows you to accept
optional args with default values.

There's a slight smell that defaults aren't applied for
function-to-function calls within the module. It might not be worth
having the default:"..." tag for that reason, but it's nice to have them
in the GraphQL schema.

Signed-off-by: Alex Suraci <[email protected]>

* refactor for gocyclo lint

Signed-off-by: Alex Suraci <[email protected]>

* add test for custom types

Signed-off-by: Alex Suraci <[email protected]>

* fix not including functions for custom types

this fix is a bit hacky (bool arg, whee); the long-term fix is to
refactor the schema so that modules can provide multiple Object types,
instead of relying on crawling the module's own functions

Signed-off-by: Alex Suraci <[email protected]>

* fix: prevent Directory.Without from failing on missing files

Other similar Without methods, such as `container.WithoutMount` do not
fail if the target is not present.

However, previously in BuildKit, the llb.WithAllowNotFound was never
explicitly required. Updating to the newer BuildKit correctly respects
this option, so we need to include llb.WithAllowNotFound directly.

Signed-off-by: Justin Chadwell <[email protected]>

* don't recursively load packages

attempting to peacefully coexist with tools like goenv and asdf, don't
think this ever needed to be recursive

Signed-off-by: Alex Suraci <[email protected]>

* fix: apply ToLowerCamel consistently

Signed-off-by: Justin Chadwell <[email protected]>

* fix + test using local modules

Signed-off-by: Alex Suraci <[email protected]>

* switch from input types to withFoo pattern

Previously functions and types were represented as input types, which
was a little inconvenient in two ways:

* You can't return an input type, so any type that needed to be returned
  had a duplicate 'regular' type definition.
* One of the input types (TypeDef) was self-referential, meaning we had
  to switch to pointers for input types, which was a breaking change for
  things like BuildArg (which still needs to be rolled back).

This commit changes TypeDef to use the more familiar withFoo style of
construction instead, and adds a TypeDefID so that it can be passed as
an input.

A possible downside here is that the module's entrypoint that registers
all the objects might involve multiple API calls to pass IDs around. I
haven't measured performance, but it's certainly hard to beat passing
all of the information in as one big precomputed type.

Signed-off-by: Alex Suraci <[email protected]>

* Make engine version overrideable

Signed-off-by: Solomon Hykes <[email protected]>

* dagger version also prints worker registry address

Signed-off-by: Solomon Hykes <[email protected]>

* debugging module failure

Signed-off-by: Alex Suraci <[email protected]>

* fix references to other objects

Signed-off-by: Alex Suraci <[email protected]>

* only unmarshal opts that are present

Signed-off-by: Alex Suraci <[email protected]>

* fix passing lists to functions

Signed-off-by: Alex Suraci <[email protected]>

* fix self-referential (chaining) types

Signed-off-by: Alex Suraci <[email protected]>

* un-weird container.Clone

this was causing panics to happen at a later time, not sure if/why it's
needed or leftover debugging

Signed-off-by: Alex Suraci <[email protected]>

* fixup remove logs

confirmed everything was ok

Signed-off-by: Alex Suraci <[email protected]>

* register multiple objects

Previously we would only register the main module, which only allowed
functions on types referenced and embedded in the module's own TypeDefs
to be registered.

Now we'll instead register each object separately, with shallow
references to other types embedded.

Along the way, fixed an issue that I was able to reproduce with
self-referential types:

  vito/dagger-gitutil@d919459

The function was being called with an empty ModuleID. I checked to see
if it was a regression and it seemed to be broken in a different way
before (circular reference in TypeDef somehow).

Signed-off-by: Alex Suraci <[email protected]>

* remove overly defensive guard

this was mostly for debugging

Signed-off-by: Alex Suraci <[email protected]>

* fix extending existing types

Signed-off-by: Alex Suraci <[email protected]>

* only stitch module constructor, not all types

This was never the intention, and seems to be breaking shykes/dagger.

I think we might just want to let users define explicit constructors or
something. Maybe by defining methods on *Client? (Ideally that'd be *DAG
or something instead.)

Signed-off-by: Alex Suraci <[email protected]>

* Add minimal Python support

Signed-off-by: Helder Correia <[email protected]>

* go codegen: preserve definition order, pretty-print

Signed-off-by: Alex Suraci <[email protected]>

* fix code that can't run anyway, explain why

Signed-off-by: Alex Suraci <[email protected]>

* roll back debugging code

Signed-off-by: Alex Suraci <[email protected]>

* Add git to the Python runtime

Signed-off-by: Helder Correia <[email protected]>

* mount dagger CLI to /bin/dagger when nesting

Motivated by the next commit, but seems like a worthwhile experiment in
its own right.

Signed-off-by: Alex Suraci <[email protected]>

* goruntime: run dagger mod sync before building

This way you don't need to commit all the generated code.

A better way to approach this would be to move this responsibility into
a pluggable runtime image, which technically we're doing, just in a
round-about way. Maybe runtimes can just be external images.

Signed-off-by: Alex Suraci <[email protected]>

* fix setting empty field description

Signed-off-by: Alex Suraci <[email protected]>

* remove now-superfluous mod sync commands

codegen now happens on-the-fly

Signed-off-by: Alex Suraci <[email protected]>

* add TESTFLAGS="-foo -bar ./baz/" engine:testcustom

Signed-off-by: Alex Suraci <[email protected]>

* test wrapping/unwrapping core types

Signed-off-by: Alex Suraci <[email protected]>

* only generate main.go if it doesn't already exist

Signed-off-by: Alex Suraci <[email protected]>

* fix a couple of module loading bugs

TestModuleGoUseLocal has been driving my crazy - it was failing in CI,
and in ./hack/make engine:test, but succeeding with ./hack/dev go test!

I had also previously seen it fail by allowing `dagger query` to hit
transitive dependencies, but it would sometimes to pass.

The latest flavor of failure is because (*Client).Dep is not defined in
the generated code for the Use module (which uses a dep called Dep). The
root cause turned out to be two bugs interacting:

* The schema stitching process was checking for pre-existing types by
  querying the currentSchemaView, which seemed to be the "" schema view,
  rather than checking the view that's being extended.

* The dagger CLI was calling .Serve on each dependency, which caused
  them to be stitched in to the "" schema view.

As a result, Dep's schema wasn't being fully generated into the view
because the stitching process saw that it was installed in the "" view.

The first fix is to simply stop calling Serve for dependencies in the
CLI. Dependencies are already served to the dependent module's schema
view at FromConfig time, so this isn't necessary for codegen. I may have
added this by mistake while figuring out how everything works. Not sure.

The second fix is to check against the destination schema view to
determine whether things are already defined, rather than checking
against the "" schema view. This just feels more correct in general. It
mostly worked before because the "" schema view and the destination
schema view always started from the schema of all core types, but
technically if someone loaded a module into the "" schema you'd get the
same breakage observed here.

Signed-off-by: Alex Suraci <[email protected]>

* fix lints

Signed-off-by: Alex Suraci <[email protected]>

* sdk/nodejs: handle reserve words, regen

now appends _ to any word that is reserved in JavaScript/TypeScript.
chiefly "function."

Signed-off-by: Alex Suraci <[email protected]>

* pythonruntime: fmt

Signed-off-by: Alex Suraci <[email protected]>

* draft some GraphQL API docs

Signed-off-by: Alex Suraci <[email protected]>

* regen rust

Signed-off-by: Alex Suraci <[email protected]>

* regen elixir sdk

had to manually revert the original changes first; SDK regen doesn't
remove no-longer-needed files (e.g. environment.ex)

Signed-off-by: Alex Suraci <[email protected]>

* sdk/nodejs: allow from and export without _

this was working before, so let's stick with it.

Signed-off-by: Alex Suraci <[email protected]>

* regen go, python, nodejs

Signed-off-by: Alex Suraci <[email protected]>

* regen java

Signed-off-by: Alex Suraci <[email protected]>

* Abandon black's preview style

Signed-off-by: Helder Correia <[email protected]>

* add basic test for extending core types

intentionally covers the smallest example: extending a core type, while
defining no additional types or functions of our own. previously this
did not work because only types discoverable by crawling the module's
functions would be added.

Signed-off-by: Alex Suraci <[email protected]>

* Add support for new scalars JSON, Void, ModuleID, FunctionID, TypeDefID in Java SDK

Signed-off-by: Jean-Christophe Sirot <[email protected]>

* refactor + test codegen

trying to move this into a higher-level API that SDK codegen, `dagger
mod sync`, and Runtimes can all use directly

Signed-off-by: Alex Suraci <[email protected]>

* dagger mod init: test and handle more situations

also generally clean up and consolidate logging/progrock usage

Signed-off-by: Alex Suraci <[email protected]>

* move querybuilder back under ./internal/

Signed-off-by: Alex Suraci <[email protected]>

* go codegen: .gitignore generated files

Signed-off-by: Alex Suraci <[email protected]>

* fix modules_test.go

Signed-off-by: Alex Suraci <[email protected]>

* refactor codegen order, .gitignore generated files

also remove previously-committed generated files along the way

Signed-off-by: Alex Suraci <[email protected]>

* fix loading not-generated package

Signed-off-by: Alex Suraci <[email protected]>

* move git tests to separate

Signed-off-by: Alex Suraci <[email protected]>

* clean up and regen modules

Signed-off-by: Alex Suraci <[email protected]>

* HACK: add cache buster

this codegen really needs to be put into the image

Signed-off-by: Alex Suraci <[email protected]>

* load non-module package, too

needed for sdk:go:generate

Signed-off-by: Alex Suraci <[email protected]>

* remove unused func

Signed-off-by: Alex Suraci <[email protected]>

* fix handling of root: .., support outer go.mod

Signed-off-by: Alex Suraci <[email protected]>

* generate base dagger.gen.go if it doesn't exist

otherwise you can end up stuck with code that refers to unknown types if
you deleted the file

Signed-off-by: Alex Suraci <[email protected]>

* fix tricky ordering, yay tests

Signed-off-by: Alex Suraci <[email protected]>

* disable crippling memoization

Signed-off-by: Solomon Hykes <[email protected]>

* module-ize codegen by moving it under sdk/go

Here's the plan: each SDK provides a module for running codegen against
user modules.

These SDK modules replace the runtimes that current live in core. Once
bootstrapped, they can be pushed to an image registry and invoked from
the CLI.

For the Go SDK this works out nicely because codegen already depended on
the SDK client, so now it can just live in the same module.

For now, the NodeJS codegen also made the trip into sdk/go/.
Theoretically this codegen could be split out into a separate module,
but right now the juice isn't worth the squeeze. The dagger.io/dagger
module is already oriented the right way dependency-wise.

Signed-off-by: Alex Suraci <[email protected]>

* use bootstrapped vito/dagger-sdk-go image

This was tricky: now when we're loading a module we _also_ need to load
its SDK module and call its function to build the runtime. Loading
modules and calling functions currently actually lives in core/schema/,
while constructing a module and setting up the runtime lives in core/,
so for now I've just hacked a callback function into
(core.Module).FromConfig, which lets me call back to core/schema/.

There's a specific interface that SDK modules must implement, currently
totally ad-hoc, worth bikeshedding:

  moduleRuntime(modSource: DirectoryID!, subPath: String): Container!

Signed-off-by: Alex Suraci <[email protected]>

* tidy up runtime bootstrapping

Previously this passed the _dependent_ module's source path + dir to the
SDK which was completely bogus. now it uses the SDK's. I'm starting to
suspect this didn't actually work before, and I was being fooled by
aggressive function caching, _or_ the fact that my 'with-dev' helper was
actually running the wrong CLI.

Now we use a special label to get the path to the module config. Not
totally sure about this. Committing mostly as a checkpoint.

Signed-off-by: Alex Suraci <[email protected]>

* avoid blank line at start of .gitignore

Signed-off-by: Alex Suraci <[email protected]>

* avoid generating bogus go.mod

Signed-off-by: Alex Suraci <[email protected]>

* Directory.asModule can be given a pre-built runtime

This is useful for bootstrapping SDKs (see next commit).

Signed-off-by: Alex Suraci <[email protected]>

* sdk/go: add bootstrapping for runtime image

We are now fully independent from the goruntime code currently living on
zenith-functions! See help.txt for details.

Signed-off-by: Alex Suraci <[email protected]>

* fully decouple dagger CLI from SDK codegen

* SDK runtime modules are now used for codegen, exposed as
  Module.generatedCode for ease of consumption
* Dagger CLI now hardcodes a mapping from SDK name ("go") to a pre-built
  SDK runtime image, currently pointing to a personal image ref. In
  practice we'll likely want to push these to tags that match the engine
  version.
* Dagger CLI now places the runtime image ref in dagger.json, which is
  the new source of truth for the module runtime.
* Merged core/moduleconfig/ and core/resolver/ into sdk/go/modules/.
  These are both critical for codegen, and make sense to expose in a
  stable library so that things like Daggerverse can use it.

Signed-off-by: Alex Suraci <[email protected]>

* sdk/go: fix generating empty object stub

this is actually just removing complexity that doesn't need to be around
anymore

Signed-off-by: Alex Suraci <[email protected]>

* sdk/go: build image on linux/amd64 and linux/arm64

Signed-off-by: Alex Suraci <[email protected]>

* fix constructing container from ID dropping platform

Signed-off-by: Alex Suraci <[email protected]>

* refactor sdk name => runtime flow, fix backwards compat

Signed-off-by: Alex Suraci <[email protected]>

* cache internal module calls

With SDKs as modules, this VERY quickly stacks up!

Caches the call to load the module, and the calls to the SDK runtime.
Everything else remains uncached. dagger mod sync is back to sub-0.5s.

Signed-off-by: Alex Suraci <[email protected]>

* silence that pesky version compatibility check

* Skip the entire call when connecting internally, to save time
* Log at Debug level for remaining cases where it makes sense to keep
  the check. If I'm already developing, I don't need to be warned about
  it all the time.

Signed-off-by: Alex Suraci <[email protected]>

* fix zero-ing out SDKRuntime when no SDK name set

Signed-off-by: Alex Suraci <[email protected]>

* show progress during codegen

kinda neat; directly uses progrock.sock for dagger mod sync, and just
uses local console output for on-the-fly codegen to avoid noise

Signed-off-by: Alex Suraci <[email protected]>

* add GeneratedCode type so codegen can give VCS hints

Now that codegen happens remotely, it doesn't make sense at all for it
to attempt to automate your local git repository. It also is hokey for
each SDK to concern itself with all the different kinds of VCSes. Git is
obviously dominant today, but there's no reason to make it the only
option at the SDK layer.

Instead SDKs now return a GeneratedCode type which lists file paths to
ignore and/or file paths to mark as generated. The CLI picks these up
and takes it from there.

Adding a whole new ID-able type took a bit of boilerplate, but it seems
worth it, and hopefully this pattern becomes cheaper with v2 IDs.

Signed-off-by: Alex Suraci <[email protected]>

* fix: don't use --vcs flag

not a thing anymore

Signed-off-by: Alex Suraci <[email protected]>

* Bust Function runtime cache once per-session.

Using a timestamp to bust function execution results in every call to a
function resulting in the full DAG of "internal" function calls (i.e.
calls to other functions from the implementation of one function) to be
walked along every possible path, which has exponential time complexity
and thus can cause genuine performance problems.

Now we instead use the server ID, which is randomly generated once per
session, to bust so that we still cache within the context of a single
session and thus avoid the poor time complexity.

Signed-off-by: Erik Sipsma <[email protected]>

* remove dead code

Signed-off-by: Alex Suraci <[email protected]>

* fix a couple of tests

Signed-off-by: Alex Suraci <[email protected]>

* fix gitignore path already there check

Signed-off-by: Alex Suraci <[email protected]>

* fix up go/nodejs codegen

Signed-off-by: Alex Suraci <[email protected]>

* bump sdk

Signed-off-by: Alex Suraci <[email protected]>

* regen python and java, fix python lint

Signed-off-by: Alex Suraci <[email protected]>

* Handle field parameters colliding with java keywords by prepending with a '_'.
Upgrade `TestWithDatabase` sample code with the new Service API

Signed-off-by: Jean-Christophe Sirot <[email protected]>

* fix: consistent errors for non-existent module directory

Previously, when a module was not provided for the dagger query command
using the `-m` flag, the error message did not indicate that the module
did not exist even when it was requested by the user.

This patch reworks the logic - dagger query will now always error if the
module provided by `-m` did not exist, but will keep the desired
behaviour that it should not error if the current directory is not a
module.

Signed-off-by: Justin Chadwell <[email protected]>

* fix: dagger mod init should require sdk and name args

We were previously calling the wrong function to do this.

Signed-off-by: Justin Chadwell <[email protected]>

* Add `dagger call` command

This is very WIP, just publishing so others can hack on it. Only supports "top-level" (from type that matches current module) functions without arguments and only tested functions that return a string.

Added `ParentName` to `core.Function` to fix a direct `dagger.Function.Call`. It used to work but is failing due to recent changes while unmarshaling input. However, since we plan to make a chained call, it's better to build a query instead of calling the functions directly.

See TODO list at the top for follow-ups.

Signed-off-by: Helder Correia <[email protected]>

* Small linting fix

Signed-off-by: Helder Correia <[email protected]>

* backport dagger shell

Signed-off-by: Erik Sipsma <[email protected]>

* chore: dagger shell branch: fix conflicts

Signed-off-by: grouville <[email protected]>

* fix: mount the correct dependency sub-folder

Without this, we can end up caching the wrong top-level directory.

Signed-off-by: Justin Chadwell <[email protected]>

* cleanup egregious stuff from dagger shell impl

Signed-off-by: Erik Sipsma <[email protected]>

* fix go sdk lints

Signed-off-by: Erik Sipsma <[email protected]>

* appease engine lints

Signed-off-by: Erik Sipsma <[email protected]>

* fix missed engine lint

Signed-off-by: Erik Sipsma <[email protected]>

* upgrade go+golangci to see if it fixes bizarre lint fail

Signed-off-by: Erik Sipsma <[email protected]>

* fix gitignore of sdk/go/runtime

Signed-off-by: Erik Sipsma <[email protected]>

* fix + test using multiple modules

two bug fixes:

1. dagger mod use incorrectly deduped on path alone, instead of also
   considering the subpath
1. a fun mutation bug in the schema was causing all sorts of fun module
   identity crises

Signed-off-by: Alex Suraci <[email protected]>

* fix go sdk tests

Signed-off-by: Erik Sipsma <[email protected]>

* fix elixer sdk lints

Signed-off-by: Erik Sipsma <[email protected]>

* appease residual lints

Signed-off-by: Erik Sipsma <[email protected]>

* upgrade sphinx-rtd-theme to see if it fixes read-the-docs build

Signed-off-by: Erik Sipsma <[email protected]>

* use session: prefix for blobsource

Signed-off-by: Erik Sipsma <[email protected]>

* add explicit requirements.txt for python docs

As of a few days ago, readthedocs requires you to explicitly set
dependencies in a requirements.txt:
https://blog.readthedocs.com/defaulting-latest-build-tools/

Signed-off-by: Erik Sipsma <[email protected]>

* stop pointerizing input types

this was needed to avoid dependency cycles in self-referential input
types, but we don't have those anymore, in favor of just always using
objects and passing them in by their ID.

Signed-off-by: Alex Suraci <[email protected]>

* use a hyper specific tag

just trying things on

Signed-off-by: Alex Suraci <[email protected]>

* regen go sdk

Signed-off-by: Alex Suraci <[email protected]>

* regen nodejs sdk

Signed-off-by: Alex Suraci <[email protected]>

* fix up tests (botched merge somewhere)

Signed-off-by: Alex Suraci <[email protected]>

* updated services docs for pr-5557

Signed-off-by: Jenn Allen <[email protected]>

* apply docs suggestions

thanks!

Co-authored-by: vikram-dagger <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>

* Updated services guides

Signed-off-by: Vikram Vaswani <[email protected]>

* Lint fix

Signed-off-by: Vikram Vaswani <[email protected]>

* Update docs/current/guides/snippets/build-test-publish-php/dagger.php

Co-authored-by: Alex Suraci <[email protected]>
Signed-off-by: vikram-dagger <[email protected]>

* Update docs/current/guides/757394-use-service-containers.md

Co-authored-by: Alex Suraci <[email protected]>
Signed-off-by: vikram-dagger <[email protected]>

* services: adopt new IDable patterns

Signed-off-by: Alex Suraci <[email protected]>

* regen SDKs

Signed-off-by: Alex Suraci <[email protected]>

* bump go sdk

Signed-off-by: Alex Suraci <[email protected]>

* fix newly added test

Signed-off-by: Alex Suraci <[email protected]>

* Updated examples and content

Signed-off-by: Vikram Vaswani <[email protected]>

* Lint fix

Signed-off-by: Vikram Vaswani <[email protected]>

* Lint fix

Signed-off-by: Vikram Vaswani <[email protected]>

* Updated filename and paths

Signed-off-by: Vikram Vaswani <[email protected]>

* Copy edit

Signed-off-by: Vikram Vaswani <[email protected]>

* Code update

Signed-off-by: Vikram Vaswani <[email protected]>

* docs tweaks

* compromise on Foo.barBaz syntax for referring to APIs
* fix what I think was a sentence ordering glitch ('select first port'
  applies to Endpoint specifically)
* turn Host.unixSocket tip into a guidepost instead of pointing out
  internal implementation details

Signed-off-by: Alex Suraci <[email protected]>

* Container.service -> Container.asService

Signed-off-by: Alex Suraci <[email protected]>

* make python lint happy

Signed-off-by: Alex Suraci <[email protected]>

* fix awkward gofmt formatting

Signed-off-by: Alex Suraci <[email protected]>

* Added code samples

Signed-off-by: Vikram Vaswani <[email protected]>

* Lint fixes

Signed-off-by: Vikram Vaswani <[email protected]>

* comment out incorrect code in example

Signed-off-by: Vikram Vaswani <[email protected]>

* Lint fix

Signed-off-by: Vikram Vaswani <[email protected]>

* Lint fix

Signed-off-by: Vikram Vaswani <[email protected]>

* Create guide expose-host-services-to-container for the node SDK

Signed-off-by: jffarge <[email protected]>

* Create a Node.js SDK guide for start-stop-services

Signed-off-by: jffarge <[email protected]>

* Remove unused fetch library

Signed-off-by: jffarge <[email protected]>

* rename main.go to main_test.go for to test

Signed-off-by: Alex Suraci <[email protected]>

* Added Python snippets

Signed-off-by: Vikram Vaswani <[email protected]>

* decouple core from internal/mage

this doesn't work when there are breaking changes (noted in two
comments)

Signed-off-by: Alex Suraci <[email protected]>

* regen SDKs

Signed-off-by: Alex Suraci <[email protected]>

* Revert "decouple core from internal/mage"

This reverts commit 1807036.

Signed-off-by: Alex Suraci <[email protected]>

* internal/mage: move consts into separate package

Signed-off-by: Alex Suraci <[email protected]>

* sdk/go: fix go.mod

Signed-off-by: Alex Suraci <[email protected]>

* undo main_test.go rename

misinterpreted the failure, and this actually causes ci failure

Signed-off-by: Alex Suraci <[email protected]>

* tidy

Signed-off-by: Alex Suraci <[email protected]>

* fix docs link

Signed-off-by: Alex Suraci <[email protected]>

* add a couple of awaits

Signed-off-by: Alex Suraci <[email protected]>

* services docs: v0.8.8 -> v0.9.0

Signed-off-by: Alex Suraci <[email protected]>

---------

Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Solomon Hykes <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Vikram Vaswani <[email protected]>
Signed-off-by: kpenfound <[email protected]>
Signed-off-by: Justin Chadwell <[email protected]>
Signed-off-by: Helder Correia <[email protected]>
Signed-off-by: Jean-Christophe Sirot <[email protected]>
Signed-off-by: grouville <[email protected]>
Signed-off-by: Jenn Allen <[email protected]>
Signed-off-by: vikram-dagger <[email protected]>
Signed-off-by: jffarge <[email protected]>
Co-authored-by: Solomon Hykes <[email protected]>
Co-authored-by: Erik Sipsma <[email protected]>
Co-authored-by: Vikram Vaswani <[email protected]>
Co-authored-by: kpenfound <[email protected]>
Co-authored-by: Justin Chadwell <[email protected]>
Co-authored-by: Solomon Hykes <[email protected]>
Co-authored-by: Helder Correia <[email protected]>
Co-authored-by: Jean-Christophe Sirot <[email protected]>
Co-authored-by: grouville <[email protected]>
Co-authored-by: Jenn Allen <[email protected]>
Co-authored-by: vikram-dagger <[email protected]>
Co-authored-by: jffarge <[email protected]>
schlapzz pushed a commit to schlapzz/dagger that referenced this pull request Nov 24, 2023
… via gateway (dagger#5557)

* h2c: reuse buf, set to 32k (same as io.Copy)

Signed-off-by: Alex Suraci <[email protected]>

* c2h: don't treat dial errors as fatal

Signed-off-by: Alex Suraci <[email protected]>

* c2h: set timeout for container release

matched 30 seconds to a timeout we set elsewhere on the same thing

Signed-off-by: Alex Suraci <[email protected]>

* Service.Clone: clone ports too

Signed-off-by: Alex Suraci <[email protected]>

* multierror -> errors.Join

Signed-off-by: Alex Suraci <[email protected]>

* h2c: cancel on server close

Signed-off-by: Alex Suraci <[email protected]>

* un-globalize AllServices

and get rid of WithServices because generic methods aren't supported and
wrappers are annoying anyway

Signed-off-by: Alex Suraci <[email protected]>

* fix premature cancel()

Signed-off-by: Alex Suraci <[email protected]>

* split Services out into a separate file, add godoc

lots of tricky behavior, worth documenting

Signed-off-by: Alex Suraci <[email protected]>

* elixir SDK: support INPUT_OBJECT

unclear why this is needed now, when we already have BuildArg

Signed-off-by: Alex Suraci <[email protected]>

* add changelog

Signed-off-by: Alex Suraci <[email protected]>

* make services no longer experimental

Couldn't find any instances on GitHub of anyone disabling this, and
there are no known open issues.

Code Search query:

    _EXPERIMENTAL_DAGGER_SERVICES_DNS AND (NOT "Currently experimental" OR "to running the Dagger Engine")

Signed-off-by: Alex Suraci <[email protected]>

* regen SDKs

Signed-off-by: Alex Suraci <[email protected]>

* disable engine-in-engine-dev for now

Signed-off-by: Alex Suraci <[email protected]>

* fix progrock deprecations/removals

Signed-off-by: Alex Suraci <[email protected]>

* testdata/nested -> testdata/nested-c2c

Signed-off-by: Alex Suraci <[email protected]>

* tests: client.Close cleanups

Signed-off-by: Alex Suraci <[email protected]>

* Zenith episode two: revenge of the function

Signed-off-by: Solomon Hykes <[email protected]>

* core: baseline core schema implementation for envs+checks.

Signed-off-by: Erik Sipsma <[email protected]>

* WIP module+function graphql schemas

Signed-off-by: Erik Sipsma <[email protected]>

* WIP modules+functions implementation

Signed-off-by: Erik Sipsma <[email protected]>

* WIP go sdk updates

Signed-off-by: Erik Sipsma <[email protected]>

* base working functions w/ go sdk

Signed-off-by: Erik Sipsma <[email protected]>

* update module test connect usage

Signed-off-by: Alex Suraci <[email protected]>

* disable depguard lint

not sure why we would want this, it fails locally on innocuous imports

Signed-off-by: Alex Suraci <[email protected]>

* disable unused param linters

These have mostly just been frustrating and unhelpful, usually resulting
in worse code than before.

Signed-off-by: Alex Suraci <[email protected]>

* fix up lints

Signed-off-by: Alex Suraci <[email protected]>

* support id-able types as inputs; extending core types

Signed-off-by: Erik Sipsma <[email protected]>

* fix support for chainable types

Signed-off-by: Erik Sipsma <[email protected]>

* ignore non-fatal compile errors

These we're causing annoying situations where you change a function
signature in user code, run `dagger mod sync` and then codegen gets a
compilation error because the old main func is incompatible with the new
signature and hasn't been updated yet.

Just ignoring these sorts of errors avoids this situation and doesn't
really cause any harm. We can still try parse the code and generate from
there. If the end result is still not compilable, then it just won't be
runnable.

Signed-off-by: Erik Sipsma <[email protected]>

* flesh out zenith intro instructions, add demo mod

zenith/ is now has an .envrc, making it suitable as a temporary
playground for writing Zenith modules

Signed-off-by: Alex Suraci <[email protected]>

* bump Go runtime to 1.21

otherwise fresh mods created with 1.21 fail on 'go 1.21.0' in go.mod

Signed-off-by: Alex Suraci <[email protected]>

* query: fix --progress=plain requirement

Signed-off-by: Alex Suraci <[email protected]>

* fix sdk/go unit tests

Signed-off-by: Alex Suraci <[email protected]>

* codegen: generate querybuilder/ package

fixes go mod replace issue

Signed-off-by: Alex Suraci <[email protected]>

* mod init: bootstrap Go module

This is a really delicate dance. For whatever reason Go doesn't like
these go.mod/go.sum files hoisted over from sdk/go/ and requires you to
run `go mod tidy`, otherwise it complains about entries missing from
go.sum, which is confusing because it works just fine for the SDK.

So the order of operations is:

* Detect if a main package exists.
* If it doesn't, write an initial main.go file before we even start
  doing codegen, otherwise the initial codegen won't have anything to
  process.
* Run code generation.
* Write initial go.mod/go.sum files with a sane default Go module name
  based on the outer module.
  * If no outer module is found, the bare Dagger module name is used and
    a warning is printed.
* Run go mod tidy.

The last step is critical; without it, dagger mod sync will error on the
same errors mentioned in the first paragraph.

Signed-off-by: Alex Suraci <[email protected]>

* support multiple passes for codegen

There's a chicken/egg problem with running codegen and generating stub
templates. If the template refers to a type like Container, the
introspection will have no idea what that refers to on the first pass.
So we need to do one pass to generate all the base types, and then
another pass to generate from the stub.

Signed-off-by: Alex Suraci <[email protected]>

* fix post-merge compilation errors

Signed-off-by: Alex Suraci <[email protected]>

* un-break cmd/client-gen

Signed-off-by: Alex Suraci <[email protected]>

* re-bump progrock for ioctl fix

Signed-off-by: Alex Suraci <[email protected]>

* respect existing .gitattributes

Signed-off-by: Alex Suraci <[email protected]>

* update core/integration for input pointer change

not completely sure if we want this, rolling with it for now

pros:

* everything is always a pointer, don't need to special-case input types
  vs regular types

cons:

* breaking change
* plain input types don't feel as intuitive as pointers

Signed-off-by: Alex Suraci <[email protected]>

* codegen: respect existing go.mod

Signed-off-by: Alex Suraci <[email protected]>

* listen: add --allow-cors

makes it easy to use off-the-shelf GraphQL inspectors

Signed-off-by: Alex Suraci <[email protected]>

* support non-local module dependencies

Signed-off-by: Alex Suraci <[email protected]>

* fix TypeDef { kind } resolving to 'null'

Signed-off-by: Alex Suraci <[email protected]>

* fix uninterruptible codegen

Signed-off-by: Alex Suraci <[email protected]>

* query: unfocus by default

Signed-off-by: Alex Suraci <[email protected]>

* bump progrock to avoid printing TUI to redirected stderr

Signed-off-by: Alex Suraci <[email protected]>

* use a single strcase package

Signed-off-by: Alex Suraci <[email protected]>

* fix module dependencies not loading

(this is thanks to a flying Erik)

Signed-off-by: Alex Suraci <[email protected]>

* Module: expose sdk, dependencies, source dir

To be used in Da Daggerverse.

Signed-off-by: Alex Suraci <[email protected]>

* dagger mod extend -> use

Signed-off-by: Alex Suraci <[email protected]>

* fix always getting description of first func

Signed-off-by: Alex Suraci <[email protected]>

* expose dependency configs

this helps daggerverse crawl a module recursively, since otherwise it
can't know how people should fetch the module

Signed-off-by: Alex Suraci <[email protected]>

* new module ref format, resolve at use time

The new format is Go module style:

  github.com/foo/bar/subpath@version

In dagger.json, the version will _always_ be a commit. The CLI accepts
any ref; it will be resolved by dagger mod use.

This format might change again, since there are gotchas that make this
hard to support in the general case (e.g. GitLab's arbitrarily-nested
repo URIs). but this is easier on the eyes. We probably also want to
stick with semver tags rather than commits. I'll figure that out next.

It would be nice if there was an easy-on-the-eyes scheme that was
totally unambiguous as to whether the provided ref is a branch, tag, or
commit, and which part is the repo and which part is the subpath.

Signed-off-by: Alex Suraci <[email protected]>

* fix uninterruptible package loading

Signed-off-by: Alex Suraci <[email protected]>

* thread ctx through to template packages.Load too

Signed-off-by: Alex Suraci <[email protected]>

* fix a couple of rogue filepath.Dirs

Signed-off-by: Alex Suraci <[email protected]>

* support distinguishing git commit from desired tag

in practice these are both just commits until semver tags are supported

Signed-off-by: Alex Suraci <[email protected]>

* fix -m with git ref

Signed-off-by: Alex Suraci <[email protected]>

* Added example to README

Signed-off-by: Vikram Vaswani <[email protected]>

* Fixed indentation in README example

Signed-off-by: Vikram Vaswani <[email protected]>

* tweak git docs

Signed-off-by: kpenfound <[email protected]>

* revise README

* avoid ./zenith/zenith
* avoid reusing Vito module name for 'create your own' flow
* add caveat for extending core types

Signed-off-by: Alex Suraci <[email protected]>

* Zenith README: chaining example

Signed-off-by: Solomon Hykes <[email protected]>

* Zenith README: fix errors

Signed-off-by: Solomon Hykes <[email protected]>

* fix: dagger mod use should override previous versions

Previously, dagger mod use would allow creating multiple versions of a
single module:

	{
	  "root": "",
	  "name": "foo",
	  "sdk": "go",
	  "dependencies": [
	    "github.com/<example>/daggerverse@aaa"
	    "github.com/<example>/daggerverse@bbb"
	  ]
	}

To prevent this, we can resolve all the dependencies, and then use the
dependency set based on only the path instead of the combination of path
and version.

Signed-off-by: Justin Chadwell <[email protected]>

* non-error returns, void returns, optional ctx

Signed-off-by: Alex Suraci <[email protected]>

* bump graphql for explicit scalar error handling

otherwise it's impossible to have a JSON scalar that evaluates to null
(which is how void return values are represented), since it gets treated
as an error

Signed-off-by: Alex Suraci <[email protected]>

* fix lints

Signed-off-by: Alex Suraci <[email protected]>

* skip non-working env tests

Signed-off-by: Alex Suraci <[email protected]>

* avoid panic if proxy env not set

likely an underlying bug here though; env should be set

Signed-off-by: Alex Suraci <[email protected]>

* fix services not having ProxyEnv

this used to be baked into the DAG as part of WithExec, but that moved
to Client.Solve, so we need to do the same thing here.

Signed-off-by: Alex Suraci <[email protected]>

* allow non-ctx first arg

Signed-off-by: Alex Suraci <[email protected]>

* sdk/go modules support Opts args

This is an alternative format to regular args that allows you to accept
optional args with default values.

There's a slight smell that defaults aren't applied for
function-to-function calls within the module. It might not be worth
having the default:"..." tag for that reason, but it's nice to have them
in the GraphQL schema.

Signed-off-by: Alex Suraci <[email protected]>

* refactor for gocyclo lint

Signed-off-by: Alex Suraci <[email protected]>

* add test for custom types

Signed-off-by: Alex Suraci <[email protected]>

* fix not including functions for custom types

this fix is a bit hacky (bool arg, whee); the long-term fix is to
refactor the schema so that modules can provide multiple Object types,
instead of relying on crawling the module's own functions

Signed-off-by: Alex Suraci <[email protected]>

* fix: prevent Directory.Without from failing on missing files

Other similar Without methods, such as `container.WithoutMount` do not
fail if the target is not present.

However, previously in BuildKit, the llb.WithAllowNotFound was never
explicitly required. Updating to the newer BuildKit correctly respects
this option, so we need to include llb.WithAllowNotFound directly.

Signed-off-by: Justin Chadwell <[email protected]>

* don't recursively load packages

attempting to peacefully coexist with tools like goenv and asdf, don't
think this ever needed to be recursive

Signed-off-by: Alex Suraci <[email protected]>

* fix: apply ToLowerCamel consistently

Signed-off-by: Justin Chadwell <[email protected]>

* fix + test using local modules

Signed-off-by: Alex Suraci <[email protected]>

* switch from input types to withFoo pattern

Previously functions and types were represented as input types, which
was a little inconvenient in two ways:

* You can't return an input type, so any type that needed to be returned
  had a duplicate 'regular' type definition.
* One of the input types (TypeDef) was self-referential, meaning we had
  to switch to pointers for input types, which was a breaking change for
  things like BuildArg (which still needs to be rolled back).

This commit changes TypeDef to use the more familiar withFoo style of
construction instead, and adds a TypeDefID so that it can be passed as
an input.

A possible downside here is that the module's entrypoint that registers
all the objects might involve multiple API calls to pass IDs around. I
haven't measured performance, but it's certainly hard to beat passing
all of the information in as one big precomputed type.

Signed-off-by: Alex Suraci <[email protected]>

* Make engine version overrideable

Signed-off-by: Solomon Hykes <[email protected]>

* dagger version also prints worker registry address

Signed-off-by: Solomon Hykes <[email protected]>

* debugging module failure

Signed-off-by: Alex Suraci <[email protected]>

* fix references to other objects

Signed-off-by: Alex Suraci <[email protected]>

* only unmarshal opts that are present

Signed-off-by: Alex Suraci <[email protected]>

* fix passing lists to functions

Signed-off-by: Alex Suraci <[email protected]>

* fix self-referential (chaining) types

Signed-off-by: Alex Suraci <[email protected]>

* un-weird container.Clone

this was causing panics to happen at a later time, not sure if/why it's
needed or leftover debugging

Signed-off-by: Alex Suraci <[email protected]>

* fixup remove logs

confirmed everything was ok

Signed-off-by: Alex Suraci <[email protected]>

* register multiple objects

Previously we would only register the main module, which only allowed
functions on types referenced and embedded in the module's own TypeDefs
to be registered.

Now we'll instead register each object separately, with shallow
references to other types embedded.

Along the way, fixed an issue that I was able to reproduce with
self-referential types:

  vito/dagger-gitutil@d919459

The function was being called with an empty ModuleID. I checked to see
if it was a regression and it seemed to be broken in a different way
before (circular reference in TypeDef somehow).

Signed-off-by: Alex Suraci <[email protected]>

* remove overly defensive guard

this was mostly for debugging

Signed-off-by: Alex Suraci <[email protected]>

* fix extending existing types

Signed-off-by: Alex Suraci <[email protected]>

* only stitch module constructor, not all types

This was never the intention, and seems to be breaking shykes/dagger.

I think we might just want to let users define explicit constructors or
something. Maybe by defining methods on *Client? (Ideally that'd be *DAG
or something instead.)

Signed-off-by: Alex Suraci <[email protected]>

* Add minimal Python support

Signed-off-by: Helder Correia <[email protected]>

* go codegen: preserve definition order, pretty-print

Signed-off-by: Alex Suraci <[email protected]>

* fix code that can't run anyway, explain why

Signed-off-by: Alex Suraci <[email protected]>

* roll back debugging code

Signed-off-by: Alex Suraci <[email protected]>

* Add git to the Python runtime

Signed-off-by: Helder Correia <[email protected]>

* mount dagger CLI to /bin/dagger when nesting

Motivated by the next commit, but seems like a worthwhile experiment in
its own right.

Signed-off-by: Alex Suraci <[email protected]>

* goruntime: run dagger mod sync before building

This way you don't need to commit all the generated code.

A better way to approach this would be to move this responsibility into
a pluggable runtime image, which technically we're doing, just in a
round-about way. Maybe runtimes can just be external images.

Signed-off-by: Alex Suraci <[email protected]>

* fix setting empty field description

Signed-off-by: Alex Suraci <[email protected]>

* remove now-superfluous mod sync commands

codegen now happens on-the-fly

Signed-off-by: Alex Suraci <[email protected]>

* add TESTFLAGS="-foo -bar ./baz/" engine:testcustom

Signed-off-by: Alex Suraci <[email protected]>

* test wrapping/unwrapping core types

Signed-off-by: Alex Suraci <[email protected]>

* only generate main.go if it doesn't already exist

Signed-off-by: Alex Suraci <[email protected]>

* fix a couple of module loading bugs

TestModuleGoUseLocal has been driving my crazy - it was failing in CI,
and in ./hack/make engine:test, but succeeding with ./hack/dev go test!

I had also previously seen it fail by allowing `dagger query` to hit
transitive dependencies, but it would sometimes to pass.

The latest flavor of failure is because (*Client).Dep is not defined in
the generated code for the Use module (which uses a dep called Dep). The
root cause turned out to be two bugs interacting:

* The schema stitching process was checking for pre-existing types by
  querying the currentSchemaView, which seemed to be the "" schema view,
  rather than checking the view that's being extended.

* The dagger CLI was calling .Serve on each dependency, which caused
  them to be stitched in to the "" schema view.

As a result, Dep's schema wasn't being fully generated into the view
because the stitching process saw that it was installed in the "" view.

The first fix is to simply stop calling Serve for dependencies in the
CLI. Dependencies are already served to the dependent module's schema
view at FromConfig time, so this isn't necessary for codegen. I may have
added this by mistake while figuring out how everything works. Not sure.

The second fix is to check against the destination schema view to
determine whether things are already defined, rather than checking
against the "" schema view. This just feels more correct in general. It
mostly worked before because the "" schema view and the destination
schema view always started from the schema of all core types, but
technically if someone loaded a module into the "" schema you'd get the
same breakage observed here.

Signed-off-by: Alex Suraci <[email protected]>

* fix lints

Signed-off-by: Alex Suraci <[email protected]>

* sdk/nodejs: handle reserve words, regen

now appends _ to any word that is reserved in JavaScript/TypeScript.
chiefly "function."

Signed-off-by: Alex Suraci <[email protected]>

* pythonruntime: fmt

Signed-off-by: Alex Suraci <[email protected]>

* draft some GraphQL API docs

Signed-off-by: Alex Suraci <[email protected]>

* regen rust

Signed-off-by: Alex Suraci <[email protected]>

* regen elixir sdk

had to manually revert the original changes first; SDK regen doesn't
remove no-longer-needed files (e.g. environment.ex)

Signed-off-by: Alex Suraci <[email protected]>

* sdk/nodejs: allow from and export without _

this was working before, so let's stick with it.

Signed-off-by: Alex Suraci <[email protected]>

* regen go, python, nodejs

Signed-off-by: Alex Suraci <[email protected]>

* regen java

Signed-off-by: Alex Suraci <[email protected]>

* Abandon black's preview style

Signed-off-by: Helder Correia <[email protected]>

* add basic test for extending core types

intentionally covers the smallest example: extending a core type, while
defining no additional types or functions of our own. previously this
did not work because only types discoverable by crawling the module's
functions would be added.

Signed-off-by: Alex Suraci <[email protected]>

* Add support for new scalars JSON, Void, ModuleID, FunctionID, TypeDefID in Java SDK

Signed-off-by: Jean-Christophe Sirot <[email protected]>

* refactor + test codegen

trying to move this into a higher-level API that SDK codegen, `dagger
mod sync`, and Runtimes can all use directly

Signed-off-by: Alex Suraci <[email protected]>

* dagger mod init: test and handle more situations

also generally clean up and consolidate logging/progrock usage

Signed-off-by: Alex Suraci <[email protected]>

* move querybuilder back under ./internal/

Signed-off-by: Alex Suraci <[email protected]>

* go codegen: .gitignore generated files

Signed-off-by: Alex Suraci <[email protected]>

* fix modules_test.go

Signed-off-by: Alex Suraci <[email protected]>

* refactor codegen order, .gitignore generated files

also remove previously-committed generated files along the way

Signed-off-by: Alex Suraci <[email protected]>

* fix loading not-generated package

Signed-off-by: Alex Suraci <[email protected]>

* move git tests to separate

Signed-off-by: Alex Suraci <[email protected]>

* clean up and regen modules

Signed-off-by: Alex Suraci <[email protected]>

* HACK: add cache buster

this codegen really needs to be put into the image

Signed-off-by: Alex Suraci <[email protected]>

* load non-module package, too

needed for sdk:go:generate

Signed-off-by: Alex Suraci <[email protected]>

* remove unused func

Signed-off-by: Alex Suraci <[email protected]>

* fix handling of root: .., support outer go.mod

Signed-off-by: Alex Suraci <[email protected]>

* generate base dagger.gen.go if it doesn't exist

otherwise you can end up stuck with code that refers to unknown types if
you deleted the file

Signed-off-by: Alex Suraci <[email protected]>

* fix tricky ordering, yay tests

Signed-off-by: Alex Suraci <[email protected]>

* disable crippling memoization

Signed-off-by: Solomon Hykes <[email protected]>

* module-ize codegen by moving it under sdk/go

Here's the plan: each SDK provides a module for running codegen against
user modules.

These SDK modules replace the runtimes that current live in core. Once
bootstrapped, they can be pushed to an image registry and invoked from
the CLI.

For the Go SDK this works out nicely because codegen already depended on
the SDK client, so now it can just live in the same module.

For now, the NodeJS codegen also made the trip into sdk/go/.
Theoretically this codegen could be split out into a separate module,
but right now the juice isn't worth the squeeze. The dagger.io/dagger
module is already oriented the right way dependency-wise.

Signed-off-by: Alex Suraci <[email protected]>

* use bootstrapped vito/dagger-sdk-go image

This was tricky: now when we're loading a module we _also_ need to load
its SDK module and call its function to build the runtime. Loading
modules and calling functions currently actually lives in core/schema/,
while constructing a module and setting up the runtime lives in core/,
so for now I've just hacked a callback function into
(core.Module).FromConfig, which lets me call back to core/schema/.

There's a specific interface that SDK modules must implement, currently
totally ad-hoc, worth bikeshedding:

  moduleRuntime(modSource: DirectoryID!, subPath: String): Container!

Signed-off-by: Alex Suraci <[email protected]>

* tidy up runtime bootstrapping

Previously this passed the _dependent_ module's source path + dir to the
SDK which was completely bogus. now it uses the SDK's. I'm starting to
suspect this didn't actually work before, and I was being fooled by
aggressive function caching, _or_ the fact that my 'with-dev' helper was
actually running the wrong CLI.

Now we use a special label to get the path to the module config. Not
totally sure about this. Committing mostly as a checkpoint.

Signed-off-by: Alex Suraci <[email protected]>

* avoid blank line at start of .gitignore

Signed-off-by: Alex Suraci <[email protected]>

* avoid generating bogus go.mod

Signed-off-by: Alex Suraci <[email protected]>

* Directory.asModule can be given a pre-built runtime

This is useful for bootstrapping SDKs (see next commit).

Signed-off-by: Alex Suraci <[email protected]>

* sdk/go: add bootstrapping for runtime image

We are now fully independent from the goruntime code currently living on
zenith-functions! See help.txt for details.

Signed-off-by: Alex Suraci <[email protected]>

* fully decouple dagger CLI from SDK codegen

* SDK runtime modules are now used for codegen, exposed as
  Module.generatedCode for ease of consumption
* Dagger CLI now hardcodes a mapping from SDK name ("go") to a pre-built
  SDK runtime image, currently pointing to a personal image ref. In
  practice we'll likely want to push these to tags that match the engine
  version.
* Dagger CLI now places the runtime image ref in dagger.json, which is
  the new source of truth for the module runtime.
* Merged core/moduleconfig/ and core/resolver/ into sdk/go/modules/.
  These are both critical for codegen, and make sense to expose in a
  stable library so that things like Daggerverse can use it.

Signed-off-by: Alex Suraci <[email protected]>

* sdk/go: fix generating empty object stub

this is actually just removing complexity that doesn't need to be around
anymore

Signed-off-by: Alex Suraci <[email protected]>

* sdk/go: build image on linux/amd64 and linux/arm64

Signed-off-by: Alex Suraci <[email protected]>

* fix constructing container from ID dropping platform

Signed-off-by: Alex Suraci <[email protected]>

* refactor sdk name => runtime flow, fix backwards compat

Signed-off-by: Alex Suraci <[email protected]>

* cache internal module calls

With SDKs as modules, this VERY quickly stacks up!

Caches the call to load the module, and the calls to the SDK runtime.
Everything else remains uncached. dagger mod sync is back to sub-0.5s.

Signed-off-by: Alex Suraci <[email protected]>

* silence that pesky version compatibility check

* Skip the entire call when connecting internally, to save time
* Log at Debug level for remaining cases where it makes sense to keep
  the check. If I'm already developing, I don't need to be warned about
  it all the time.

Signed-off-by: Alex Suraci <[email protected]>

* fix zero-ing out SDKRuntime when no SDK name set

Signed-off-by: Alex Suraci <[email protected]>

* show progress during codegen

kinda neat; directly uses progrock.sock for dagger mod sync, and just
uses local console output for on-the-fly codegen to avoid noise

Signed-off-by: Alex Suraci <[email protected]>

* add GeneratedCode type so codegen can give VCS hints

Now that codegen happens remotely, it doesn't make sense at all for it
to attempt to automate your local git repository. It also is hokey for
each SDK to concern itself with all the different kinds of VCSes. Git is
obviously dominant today, but there's no reason to make it the only
option at the SDK layer.

Instead SDKs now return a GeneratedCode type which lists file paths to
ignore and/or file paths to mark as generated. The CLI picks these up
and takes it from there.

Adding a whole new ID-able type took a bit of boilerplate, but it seems
worth it, and hopefully this pattern becomes cheaper with v2 IDs.

Signed-off-by: Alex Suraci <[email protected]>

* fix: don't use --vcs flag

not a thing anymore

Signed-off-by: Alex Suraci <[email protected]>

* Bust Function runtime cache once per-session.

Using a timestamp to bust function execution results in every call to a
function resulting in the full DAG of "internal" function calls (i.e.
calls to other functions from the implementation of one function) to be
walked along every possible path, which has exponential time complexity
and thus can cause genuine performance problems.

Now we instead use the server ID, which is randomly generated once per
session, to bust so that we still cache within the context of a single
session and thus avoid the poor time complexity.

Signed-off-by: Erik Sipsma <[email protected]>

* remove dead code

Signed-off-by: Alex Suraci <[email protected]>

* fix a couple of tests

Signed-off-by: Alex Suraci <[email protected]>

* fix gitignore path already there check

Signed-off-by: Alex Suraci <[email protected]>

* fix up go/nodejs codegen

Signed-off-by: Alex Suraci <[email protected]>

* bump sdk

Signed-off-by: Alex Suraci <[email protected]>

* regen python and java, fix python lint

Signed-off-by: Alex Suraci <[email protected]>

* Handle field parameters colliding with java keywords by prepending with a '_'.
Upgrade `TestWithDatabase` sample code with the new Service API

Signed-off-by: Jean-Christophe Sirot <[email protected]>

* fix: consistent errors for non-existent module directory

Previously, when a module was not provided for the dagger query command
using the `-m` flag, the error message did not indicate that the module
did not exist even when it was requested by the user.

This patch reworks the logic - dagger query will now always error if the
module provided by `-m` did not exist, but will keep the desired
behaviour that it should not error if the current directory is not a
module.

Signed-off-by: Justin Chadwell <[email protected]>

* fix: dagger mod init should require sdk and name args

We were previously calling the wrong function to do this.

Signed-off-by: Justin Chadwell <[email protected]>

* Add `dagger call` command

This is very WIP, just publishing so others can hack on it. Only supports "top-level" (from type that matches current module) functions without arguments and only tested functions that return a string.

Added `ParentName` to `core.Function` to fix a direct `dagger.Function.Call`. It used to work but is failing due to recent changes while unmarshaling input. However, since we plan to make a chained call, it's better to build a query instead of calling the functions directly.

See TODO list at the top for follow-ups.

Signed-off-by: Helder Correia <[email protected]>

* Small linting fix

Signed-off-by: Helder Correia <[email protected]>

* backport dagger shell

Signed-off-by: Erik Sipsma <[email protected]>

* chore: dagger shell branch: fix conflicts

Signed-off-by: grouville <[email protected]>

* fix: mount the correct dependency sub-folder

Without this, we can end up caching the wrong top-level directory.

Signed-off-by: Justin Chadwell <[email protected]>

* cleanup egregious stuff from dagger shell impl

Signed-off-by: Erik Sipsma <[email protected]>

* fix go sdk lints

Signed-off-by: Erik Sipsma <[email protected]>

* appease engine lints

Signed-off-by: Erik Sipsma <[email protected]>

* fix missed engine lint

Signed-off-by: Erik Sipsma <[email protected]>

* upgrade go+golangci to see if it fixes bizarre lint fail

Signed-off-by: Erik Sipsma <[email protected]>

* fix gitignore of sdk/go/runtime

Signed-off-by: Erik Sipsma <[email protected]>

* fix + test using multiple modules

two bug fixes:

1. dagger mod use incorrectly deduped on path alone, instead of also
   considering the subpath
1. a fun mutation bug in the schema was causing all sorts of fun module
   identity crises

Signed-off-by: Alex Suraci <[email protected]>

* fix go sdk tests

Signed-off-by: Erik Sipsma <[email protected]>

* fix elixer sdk lints

Signed-off-by: Erik Sipsma <[email protected]>

* appease residual lints

Signed-off-by: Erik Sipsma <[email protected]>

* upgrade sphinx-rtd-theme to see if it fixes read-the-docs build

Signed-off-by: Erik Sipsma <[email protected]>

* use session: prefix for blobsource

Signed-off-by: Erik Sipsma <[email protected]>

* add explicit requirements.txt for python docs

As of a few days ago, readthedocs requires you to explicitly set
dependencies in a requirements.txt:
https://blog.readthedocs.com/defaulting-latest-build-tools/

Signed-off-by: Erik Sipsma <[email protected]>

* stop pointerizing input types

this was needed to avoid dependency cycles in self-referential input
types, but we don't have those anymore, in favor of just always using
objects and passing them in by their ID.

Signed-off-by: Alex Suraci <[email protected]>

* use a hyper specific tag

just trying things on

Signed-off-by: Alex Suraci <[email protected]>

* regen go sdk

Signed-off-by: Alex Suraci <[email protected]>

* regen nodejs sdk

Signed-off-by: Alex Suraci <[email protected]>

* fix up tests (botched merge somewhere)

Signed-off-by: Alex Suraci <[email protected]>

* updated services docs for pr-5557

Signed-off-by: Jenn Allen <[email protected]>

* apply docs suggestions

thanks!

Co-authored-by: vikram-dagger <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>

* Updated services guides

Signed-off-by: Vikram Vaswani <[email protected]>

* Lint fix

Signed-off-by: Vikram Vaswani <[email protected]>

* Update docs/current/guides/snippets/build-test-publish-php/dagger.php

Co-authored-by: Alex Suraci <[email protected]>
Signed-off-by: vikram-dagger <[email protected]>

* Update docs/current/guides/757394-use-service-containers.md

Co-authored-by: Alex Suraci <[email protected]>
Signed-off-by: vikram-dagger <[email protected]>

* services: adopt new IDable patterns

Signed-off-by: Alex Suraci <[email protected]>

* regen SDKs

Signed-off-by: Alex Suraci <[email protected]>

* bump go sdk

Signed-off-by: Alex Suraci <[email protected]>

* fix newly added test

Signed-off-by: Alex Suraci <[email protected]>

* Updated examples and content

Signed-off-by: Vikram Vaswani <[email protected]>

* Lint fix

Signed-off-by: Vikram Vaswani <[email protected]>

* Lint fix

Signed-off-by: Vikram Vaswani <[email protected]>

* Updated filename and paths

Signed-off-by: Vikram Vaswani <[email protected]>

* Copy edit

Signed-off-by: Vikram Vaswani <[email protected]>

* Code update

Signed-off-by: Vikram Vaswani <[email protected]>

* docs tweaks

* compromise on Foo.barBaz syntax for referring to APIs
* fix what I think was a sentence ordering glitch ('select first port'
  applies to Endpoint specifically)
* turn Host.unixSocket tip into a guidepost instead of pointing out
  internal implementation details

Signed-off-by: Alex Suraci <[email protected]>

* Container.service -> Container.asService

Signed-off-by: Alex Suraci <[email protected]>

* make python lint happy

Signed-off-by: Alex Suraci <[email protected]>

* fix awkward gofmt formatting

Signed-off-by: Alex Suraci <[email protected]>

* Added code samples

Signed-off-by: Vikram Vaswani <[email protected]>

* Lint fixes

Signed-off-by: Vikram Vaswani <[email protected]>

* comment out incorrect code in example

Signed-off-by: Vikram Vaswani <[email protected]>

* Lint fix

Signed-off-by: Vikram Vaswani <[email protected]>

* Lint fix

Signed-off-by: Vikram Vaswani <[email protected]>

* Create guide expose-host-services-to-container for the node SDK

Signed-off-by: jffarge <[email protected]>

* Create a Node.js SDK guide for start-stop-services

Signed-off-by: jffarge <[email protected]>

* Remove unused fetch library

Signed-off-by: jffarge <[email protected]>

* rename main.go to main_test.go for to test

Signed-off-by: Alex Suraci <[email protected]>

* Added Python snippets

Signed-off-by: Vikram Vaswani <[email protected]>

* decouple core from internal/mage

this doesn't work when there are breaking changes (noted in two
comments)

Signed-off-by: Alex Suraci <[email protected]>

* regen SDKs

Signed-off-by: Alex Suraci <[email protected]>

* Revert "decouple core from internal/mage"

This reverts commit 1807036.

Signed-off-by: Alex Suraci <[email protected]>

* internal/mage: move consts into separate package

Signed-off-by: Alex Suraci <[email protected]>

* sdk/go: fix go.mod

Signed-off-by: Alex Suraci <[email protected]>

* undo main_test.go rename

misinterpreted the failure, and this actually causes ci failure

Signed-off-by: Alex Suraci <[email protected]>

* tidy

Signed-off-by: Alex Suraci <[email protected]>

* fix docs link

Signed-off-by: Alex Suraci <[email protected]>

* add a couple of awaits

Signed-off-by: Alex Suraci <[email protected]>

* services docs: v0.8.8 -> v0.9.0

Signed-off-by: Alex Suraci <[email protected]>

---------

Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Solomon Hykes <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Vikram Vaswani <[email protected]>
Signed-off-by: kpenfound <[email protected]>
Signed-off-by: Justin Chadwell <[email protected]>
Signed-off-by: Helder Correia <[email protected]>
Signed-off-by: Jean-Christophe Sirot <[email protected]>
Signed-off-by: grouville <[email protected]>
Signed-off-by: Jenn Allen <[email protected]>
Signed-off-by: vikram-dagger <[email protected]>
Signed-off-by: jffarge <[email protected]>
Co-authored-by: Solomon Hykes <[email protected]>
Co-authored-by: Erik Sipsma <[email protected]>
Co-authored-by: Vikram Vaswani <[email protected]>
Co-authored-by: kpenfound <[email protected]>
Co-authored-by: Justin Chadwell <[email protected]>
Co-authored-by: Solomon Hykes <[email protected]>
Co-authored-by: Helder Correia <[email protected]>
Co-authored-by: Jean-Christophe Sirot <[email protected]>
Co-authored-by: grouville <[email protected]>
Co-authored-by: Jenn Allen <[email protected]>
Co-authored-by: vikram-dagger <[email protected]>
Co-authored-by: jffarge <[email protected]>
schlapzz pushed a commit to schlapzz/dagger that referenced this pull request Nov 24, 2023
… via gateway (dagger#5557)

* h2c: reuse buf, set to 32k (same as io.Copy)

Signed-off-by: Alex Suraci <[email protected]>

* c2h: don't treat dial errors as fatal

Signed-off-by: Alex Suraci <[email protected]>

* c2h: set timeout for container release

matched 30 seconds to a timeout we set elsewhere on the same thing

Signed-off-by: Alex Suraci <[email protected]>

* Service.Clone: clone ports too

Signed-off-by: Alex Suraci <[email protected]>

* multierror -> errors.Join

Signed-off-by: Alex Suraci <[email protected]>

* h2c: cancel on server close

Signed-off-by: Alex Suraci <[email protected]>

* un-globalize AllServices

and get rid of WithServices because generic methods aren't supported and
wrappers are annoying anyway

Signed-off-by: Alex Suraci <[email protected]>

* fix premature cancel()

Signed-off-by: Alex Suraci <[email protected]>

* split Services out into a separate file, add godoc

lots of tricky behavior, worth documenting

Signed-off-by: Alex Suraci <[email protected]>

* elixir SDK: support INPUT_OBJECT

unclear why this is needed now, when we already have BuildArg

Signed-off-by: Alex Suraci <[email protected]>

* add changelog

Signed-off-by: Alex Suraci <[email protected]>

* make services no longer experimental

Couldn't find any instances on GitHub of anyone disabling this, and
there are no known open issues.

Code Search query:

    _EXPERIMENTAL_DAGGER_SERVICES_DNS AND (NOT "Currently experimental" OR "to running the Dagger Engine")

Signed-off-by: Alex Suraci <[email protected]>

* regen SDKs

Signed-off-by: Alex Suraci <[email protected]>

* disable engine-in-engine-dev for now

Signed-off-by: Alex Suraci <[email protected]>

* fix progrock deprecations/removals

Signed-off-by: Alex Suraci <[email protected]>

* testdata/nested -> testdata/nested-c2c

Signed-off-by: Alex Suraci <[email protected]>

* tests: client.Close cleanups

Signed-off-by: Alex Suraci <[email protected]>

* Zenith episode two: revenge of the function

Signed-off-by: Solomon Hykes <[email protected]>

* core: baseline core schema implementation for envs+checks.

Signed-off-by: Erik Sipsma <[email protected]>

* WIP module+function graphql schemas

Signed-off-by: Erik Sipsma <[email protected]>

* WIP modules+functions implementation

Signed-off-by: Erik Sipsma <[email protected]>

* WIP go sdk updates

Signed-off-by: Erik Sipsma <[email protected]>

* base working functions w/ go sdk

Signed-off-by: Erik Sipsma <[email protected]>

* update module test connect usage

Signed-off-by: Alex Suraci <[email protected]>

* disable depguard lint

not sure why we would want this, it fails locally on innocuous imports

Signed-off-by: Alex Suraci <[email protected]>

* disable unused param linters

These have mostly just been frustrating and unhelpful, usually resulting
in worse code than before.

Signed-off-by: Alex Suraci <[email protected]>

* fix up lints

Signed-off-by: Alex Suraci <[email protected]>

* support id-able types as inputs; extending core types

Signed-off-by: Erik Sipsma <[email protected]>

* fix support for chainable types

Signed-off-by: Erik Sipsma <[email protected]>

* ignore non-fatal compile errors

These we're causing annoying situations where you change a function
signature in user code, run `dagger mod sync` and then codegen gets a
compilation error because the old main func is incompatible with the new
signature and hasn't been updated yet.

Just ignoring these sorts of errors avoids this situation and doesn't
really cause any harm. We can still try parse the code and generate from
there. If the end result is still not compilable, then it just won't be
runnable.

Signed-off-by: Erik Sipsma <[email protected]>

* flesh out zenith intro instructions, add demo mod

zenith/ is now has an .envrc, making it suitable as a temporary
playground for writing Zenith modules

Signed-off-by: Alex Suraci <[email protected]>

* bump Go runtime to 1.21

otherwise fresh mods created with 1.21 fail on 'go 1.21.0' in go.mod

Signed-off-by: Alex Suraci <[email protected]>

* query: fix --progress=plain requirement

Signed-off-by: Alex Suraci <[email protected]>

* fix sdk/go unit tests

Signed-off-by: Alex Suraci <[email protected]>

* codegen: generate querybuilder/ package

fixes go mod replace issue

Signed-off-by: Alex Suraci <[email protected]>

* mod init: bootstrap Go module

This is a really delicate dance. For whatever reason Go doesn't like
these go.mod/go.sum files hoisted over from sdk/go/ and requires you to
run `go mod tidy`, otherwise it complains about entries missing from
go.sum, which is confusing because it works just fine for the SDK.

So the order of operations is:

* Detect if a main package exists.
* If it doesn't, write an initial main.go file before we even start
  doing codegen, otherwise the initial codegen won't have anything to
  process.
* Run code generation.
* Write initial go.mod/go.sum files with a sane default Go module name
  based on the outer module.
  * If no outer module is found, the bare Dagger module name is used and
    a warning is printed.
* Run go mod tidy.

The last step is critical; without it, dagger mod sync will error on the
same errors mentioned in the first paragraph.

Signed-off-by: Alex Suraci <[email protected]>

* support multiple passes for codegen

There's a chicken/egg problem with running codegen and generating stub
templates. If the template refers to a type like Container, the
introspection will have no idea what that refers to on the first pass.
So we need to do one pass to generate all the base types, and then
another pass to generate from the stub.

Signed-off-by: Alex Suraci <[email protected]>

* fix post-merge compilation errors

Signed-off-by: Alex Suraci <[email protected]>

* un-break cmd/client-gen

Signed-off-by: Alex Suraci <[email protected]>

* re-bump progrock for ioctl fix

Signed-off-by: Alex Suraci <[email protected]>

* respect existing .gitattributes

Signed-off-by: Alex Suraci <[email protected]>

* update core/integration for input pointer change

not completely sure if we want this, rolling with it for now

pros:

* everything is always a pointer, don't need to special-case input types
  vs regular types

cons:

* breaking change
* plain input types don't feel as intuitive as pointers

Signed-off-by: Alex Suraci <[email protected]>

* codegen: respect existing go.mod

Signed-off-by: Alex Suraci <[email protected]>

* listen: add --allow-cors

makes it easy to use off-the-shelf GraphQL inspectors

Signed-off-by: Alex Suraci <[email protected]>

* support non-local module dependencies

Signed-off-by: Alex Suraci <[email protected]>

* fix TypeDef { kind } resolving to 'null'

Signed-off-by: Alex Suraci <[email protected]>

* fix uninterruptible codegen

Signed-off-by: Alex Suraci <[email protected]>

* query: unfocus by default

Signed-off-by: Alex Suraci <[email protected]>

* bump progrock to avoid printing TUI to redirected stderr

Signed-off-by: Alex Suraci <[email protected]>

* use a single strcase package

Signed-off-by: Alex Suraci <[email protected]>

* fix module dependencies not loading

(this is thanks to a flying Erik)

Signed-off-by: Alex Suraci <[email protected]>

* Module: expose sdk, dependencies, source dir

To be used in Da Daggerverse.

Signed-off-by: Alex Suraci <[email protected]>

* dagger mod extend -> use

Signed-off-by: Alex Suraci <[email protected]>

* fix always getting description of first func

Signed-off-by: Alex Suraci <[email protected]>

* expose dependency configs

this helps daggerverse crawl a module recursively, since otherwise it
can't know how people should fetch the module

Signed-off-by: Alex Suraci <[email protected]>

* new module ref format, resolve at use time

The new format is Go module style:

  github.com/foo/bar/subpath@version

In dagger.json, the version will _always_ be a commit. The CLI accepts
any ref; it will be resolved by dagger mod use.

This format might change again, since there are gotchas that make this
hard to support in the general case (e.g. GitLab's arbitrarily-nested
repo URIs). but this is easier on the eyes. We probably also want to
stick with semver tags rather than commits. I'll figure that out next.

It would be nice if there was an easy-on-the-eyes scheme that was
totally unambiguous as to whether the provided ref is a branch, tag, or
commit, and which part is the repo and which part is the subpath.

Signed-off-by: Alex Suraci <[email protected]>

* fix uninterruptible package loading

Signed-off-by: Alex Suraci <[email protected]>

* thread ctx through to template packages.Load too

Signed-off-by: Alex Suraci <[email protected]>

* fix a couple of rogue filepath.Dirs

Signed-off-by: Alex Suraci <[email protected]>

* support distinguishing git commit from desired tag

in practice these are both just commits until semver tags are supported

Signed-off-by: Alex Suraci <[email protected]>

* fix -m with git ref

Signed-off-by: Alex Suraci <[email protected]>

* Added example to README

Signed-off-by: Vikram Vaswani <[email protected]>

* Fixed indentation in README example

Signed-off-by: Vikram Vaswani <[email protected]>

* tweak git docs

Signed-off-by: kpenfound <[email protected]>

* revise README

* avoid ./zenith/zenith
* avoid reusing Vito module name for 'create your own' flow
* add caveat for extending core types

Signed-off-by: Alex Suraci <[email protected]>

* Zenith README: chaining example

Signed-off-by: Solomon Hykes <[email protected]>

* Zenith README: fix errors

Signed-off-by: Solomon Hykes <[email protected]>

* fix: dagger mod use should override previous versions

Previously, dagger mod use would allow creating multiple versions of a
single module:

	{
	  "root": "",
	  "name": "foo",
	  "sdk": "go",
	  "dependencies": [
	    "github.com/<example>/daggerverse@aaa"
	    "github.com/<example>/daggerverse@bbb"
	  ]
	}

To prevent this, we can resolve all the dependencies, and then use the
dependency set based on only the path instead of the combination of path
and version.

Signed-off-by: Justin Chadwell <[email protected]>

* non-error returns, void returns, optional ctx

Signed-off-by: Alex Suraci <[email protected]>

* bump graphql for explicit scalar error handling

otherwise it's impossible to have a JSON scalar that evaluates to null
(which is how void return values are represented), since it gets treated
as an error

Signed-off-by: Alex Suraci <[email protected]>

* fix lints

Signed-off-by: Alex Suraci <[email protected]>

* skip non-working env tests

Signed-off-by: Alex Suraci <[email protected]>

* avoid panic if proxy env not set

likely an underlying bug here though; env should be set

Signed-off-by: Alex Suraci <[email protected]>

* fix services not having ProxyEnv

this used to be baked into the DAG as part of WithExec, but that moved
to Client.Solve, so we need to do the same thing here.

Signed-off-by: Alex Suraci <[email protected]>

* allow non-ctx first arg

Signed-off-by: Alex Suraci <[email protected]>

* sdk/go modules support Opts args

This is an alternative format to regular args that allows you to accept
optional args with default values.

There's a slight smell that defaults aren't applied for
function-to-function calls within the module. It might not be worth
having the default:"..." tag for that reason, but it's nice to have them
in the GraphQL schema.

Signed-off-by: Alex Suraci <[email protected]>

* refactor for gocyclo lint

Signed-off-by: Alex Suraci <[email protected]>

* add test for custom types

Signed-off-by: Alex Suraci <[email protected]>

* fix not including functions for custom types

this fix is a bit hacky (bool arg, whee); the long-term fix is to
refactor the schema so that modules can provide multiple Object types,
instead of relying on crawling the module's own functions

Signed-off-by: Alex Suraci <[email protected]>

* fix: prevent Directory.Without from failing on missing files

Other similar Without methods, such as `container.WithoutMount` do not
fail if the target is not present.

However, previously in BuildKit, the llb.WithAllowNotFound was never
explicitly required. Updating to the newer BuildKit correctly respects
this option, so we need to include llb.WithAllowNotFound directly.

Signed-off-by: Justin Chadwell <[email protected]>

* don't recursively load packages

attempting to peacefully coexist with tools like goenv and asdf, don't
think this ever needed to be recursive

Signed-off-by: Alex Suraci <[email protected]>

* fix: apply ToLowerCamel consistently

Signed-off-by: Justin Chadwell <[email protected]>

* fix + test using local modules

Signed-off-by: Alex Suraci <[email protected]>

* switch from input types to withFoo pattern

Previously functions and types were represented as input types, which
was a little inconvenient in two ways:

* You can't return an input type, so any type that needed to be returned
  had a duplicate 'regular' type definition.
* One of the input types (TypeDef) was self-referential, meaning we had
  to switch to pointers for input types, which was a breaking change for
  things like BuildArg (which still needs to be rolled back).

This commit changes TypeDef to use the more familiar withFoo style of
construction instead, and adds a TypeDefID so that it can be passed as
an input.

A possible downside here is that the module's entrypoint that registers
all the objects might involve multiple API calls to pass IDs around. I
haven't measured performance, but it's certainly hard to beat passing
all of the information in as one big precomputed type.

Signed-off-by: Alex Suraci <[email protected]>

* Make engine version overrideable

Signed-off-by: Solomon Hykes <[email protected]>

* dagger version also prints worker registry address

Signed-off-by: Solomon Hykes <[email protected]>

* debugging module failure

Signed-off-by: Alex Suraci <[email protected]>

* fix references to other objects

Signed-off-by: Alex Suraci <[email protected]>

* only unmarshal opts that are present

Signed-off-by: Alex Suraci <[email protected]>

* fix passing lists to functions

Signed-off-by: Alex Suraci <[email protected]>

* fix self-referential (chaining) types

Signed-off-by: Alex Suraci <[email protected]>

* un-weird container.Clone

this was causing panics to happen at a later time, not sure if/why it's
needed or leftover debugging

Signed-off-by: Alex Suraci <[email protected]>

* fixup remove logs

confirmed everything was ok

Signed-off-by: Alex Suraci <[email protected]>

* register multiple objects

Previously we would only register the main module, which only allowed
functions on types referenced and embedded in the module's own TypeDefs
to be registered.

Now we'll instead register each object separately, with shallow
references to other types embedded.

Along the way, fixed an issue that I was able to reproduce with
self-referential types:

  vito/dagger-gitutil@d919459

The function was being called with an empty ModuleID. I checked to see
if it was a regression and it seemed to be broken in a different way
before (circular reference in TypeDef somehow).

Signed-off-by: Alex Suraci <[email protected]>

* remove overly defensive guard

this was mostly for debugging

Signed-off-by: Alex Suraci <[email protected]>

* fix extending existing types

Signed-off-by: Alex Suraci <[email protected]>

* only stitch module constructor, not all types

This was never the intention, and seems to be breaking shykes/dagger.

I think we might just want to let users define explicit constructors or
something. Maybe by defining methods on *Client? (Ideally that'd be *DAG
or something instead.)

Signed-off-by: Alex Suraci <[email protected]>

* Add minimal Python support

Signed-off-by: Helder Correia <[email protected]>

* go codegen: preserve definition order, pretty-print

Signed-off-by: Alex Suraci <[email protected]>

* fix code that can't run anyway, explain why

Signed-off-by: Alex Suraci <[email protected]>

* roll back debugging code

Signed-off-by: Alex Suraci <[email protected]>

* Add git to the Python runtime

Signed-off-by: Helder Correia <[email protected]>

* mount dagger CLI to /bin/dagger when nesting

Motivated by the next commit, but seems like a worthwhile experiment in
its own right.

Signed-off-by: Alex Suraci <[email protected]>

* goruntime: run dagger mod sync before building

This way you don't need to commit all the generated code.

A better way to approach this would be to move this responsibility into
a pluggable runtime image, which technically we're doing, just in a
round-about way. Maybe runtimes can just be external images.

Signed-off-by: Alex Suraci <[email protected]>

* fix setting empty field description

Signed-off-by: Alex Suraci <[email protected]>

* remove now-superfluous mod sync commands

codegen now happens on-the-fly

Signed-off-by: Alex Suraci <[email protected]>

* add TESTFLAGS="-foo -bar ./baz/" engine:testcustom

Signed-off-by: Alex Suraci <[email protected]>

* test wrapping/unwrapping core types

Signed-off-by: Alex Suraci <[email protected]>

* only generate main.go if it doesn't already exist

Signed-off-by: Alex Suraci <[email protected]>

* fix a couple of module loading bugs

TestModuleGoUseLocal has been driving my crazy - it was failing in CI,
and in ./hack/make engine:test, but succeeding with ./hack/dev go test!

I had also previously seen it fail by allowing `dagger query` to hit
transitive dependencies, but it would sometimes to pass.

The latest flavor of failure is because (*Client).Dep is not defined in
the generated code for the Use module (which uses a dep called Dep). The
root cause turned out to be two bugs interacting:

* The schema stitching process was checking for pre-existing types by
  querying the currentSchemaView, which seemed to be the "" schema view,
  rather than checking the view that's being extended.

* The dagger CLI was calling .Serve on each dependency, which caused
  them to be stitched in to the "" schema view.

As a result, Dep's schema wasn't being fully generated into the view
because the stitching process saw that it was installed in the "" view.

The first fix is to simply stop calling Serve for dependencies in the
CLI. Dependencies are already served to the dependent module's schema
view at FromConfig time, so this isn't necessary for codegen. I may have
added this by mistake while figuring out how everything works. Not sure.

The second fix is to check against the destination schema view to
determine whether things are already defined, rather than checking
against the "" schema view. This just feels more correct in general. It
mostly worked before because the "" schema view and the destination
schema view always started from the schema of all core types, but
technically if someone loaded a module into the "" schema you'd get the
same breakage observed here.

Signed-off-by: Alex Suraci <[email protected]>

* fix lints

Signed-off-by: Alex Suraci <[email protected]>

* sdk/nodejs: handle reserve words, regen

now appends _ to any word that is reserved in JavaScript/TypeScript.
chiefly "function."

Signed-off-by: Alex Suraci <[email protected]>

* pythonruntime: fmt

Signed-off-by: Alex Suraci <[email protected]>

* draft some GraphQL API docs

Signed-off-by: Alex Suraci <[email protected]>

* regen rust

Signed-off-by: Alex Suraci <[email protected]>

* regen elixir sdk

had to manually revert the original changes first; SDK regen doesn't
remove no-longer-needed files (e.g. environment.ex)

Signed-off-by: Alex Suraci <[email protected]>

* sdk/nodejs: allow from and export without _

this was working before, so let's stick with it.

Signed-off-by: Alex Suraci <[email protected]>

* regen go, python, nodejs

Signed-off-by: Alex Suraci <[email protected]>

* regen java

Signed-off-by: Alex Suraci <[email protected]>

* Abandon black's preview style

Signed-off-by: Helder Correia <[email protected]>

* add basic test for extending core types

intentionally covers the smallest example: extending a core type, while
defining no additional types or functions of our own. previously this
did not work because only types discoverable by crawling the module's
functions would be added.

Signed-off-by: Alex Suraci <[email protected]>

* Add support for new scalars JSON, Void, ModuleID, FunctionID, TypeDefID in Java SDK

Signed-off-by: Jean-Christophe Sirot <[email protected]>

* refactor + test codegen

trying to move this into a higher-level API that SDK codegen, `dagger
mod sync`, and Runtimes can all use directly

Signed-off-by: Alex Suraci <[email protected]>

* dagger mod init: test and handle more situations

also generally clean up and consolidate logging/progrock usage

Signed-off-by: Alex Suraci <[email protected]>

* move querybuilder back under ./internal/

Signed-off-by: Alex Suraci <[email protected]>

* go codegen: .gitignore generated files

Signed-off-by: Alex Suraci <[email protected]>

* fix modules_test.go

Signed-off-by: Alex Suraci <[email protected]>

* refactor codegen order, .gitignore generated files

also remove previously-committed generated files along the way

Signed-off-by: Alex Suraci <[email protected]>

* fix loading not-generated package

Signed-off-by: Alex Suraci <[email protected]>

* move git tests to separate

Signed-off-by: Alex Suraci <[email protected]>

* clean up and regen modules

Signed-off-by: Alex Suraci <[email protected]>

* HACK: add cache buster

this codegen really needs to be put into the image

Signed-off-by: Alex Suraci <[email protected]>

* load non-module package, too

needed for sdk:go:generate

Signed-off-by: Alex Suraci <[email protected]>

* remove unused func

Signed-off-by: Alex Suraci <[email protected]>

* fix handling of root: .., support outer go.mod

Signed-off-by: Alex Suraci <[email protected]>

* generate base dagger.gen.go if it doesn't exist

otherwise you can end up stuck with code that refers to unknown types if
you deleted the file

Signed-off-by: Alex Suraci <[email protected]>

* fix tricky ordering, yay tests

Signed-off-by: Alex Suraci <[email protected]>

* disable crippling memoization

Signed-off-by: Solomon Hykes <[email protected]>

* module-ize codegen by moving it under sdk/go

Here's the plan: each SDK provides a module for running codegen against
user modules.

These SDK modules replace the runtimes that current live in core. Once
bootstrapped, they can be pushed to an image registry and invoked from
the CLI.

For the Go SDK this works out nicely because codegen already depended on
the SDK client, so now it can just live in the same module.

For now, the NodeJS codegen also made the trip into sdk/go/.
Theoretically this codegen could be split out into a separate module,
but right now the juice isn't worth the squeeze. The dagger.io/dagger
module is already oriented the right way dependency-wise.

Signed-off-by: Alex Suraci <[email protected]>

* use bootstrapped vito/dagger-sdk-go image

This was tricky: now when we're loading a module we _also_ need to load
its SDK module and call its function to build the runtime. Loading
modules and calling functions currently actually lives in core/schema/,
while constructing a module and setting up the runtime lives in core/,
so for now I've just hacked a callback function into
(core.Module).FromConfig, which lets me call back to core/schema/.

There's a specific interface that SDK modules must implement, currently
totally ad-hoc, worth bikeshedding:

  moduleRuntime(modSource: DirectoryID!, subPath: String): Container!

Signed-off-by: Alex Suraci <[email protected]>

* tidy up runtime bootstrapping

Previously this passed the _dependent_ module's source path + dir to the
SDK which was completely bogus. now it uses the SDK's. I'm starting to
suspect this didn't actually work before, and I was being fooled by
aggressive function caching, _or_ the fact that my 'with-dev' helper was
actually running the wrong CLI.

Now we use a special label to get the path to the module config. Not
totally sure about this. Committing mostly as a checkpoint.

Signed-off-by: Alex Suraci <[email protected]>

* avoid blank line at start of .gitignore

Signed-off-by: Alex Suraci <[email protected]>

* avoid generating bogus go.mod

Signed-off-by: Alex Suraci <[email protected]>

* Directory.asModule can be given a pre-built runtime

This is useful for bootstrapping SDKs (see next commit).

Signed-off-by: Alex Suraci <[email protected]>

* sdk/go: add bootstrapping for runtime image

We are now fully independent from the goruntime code currently living on
zenith-functions! See help.txt for details.

Signed-off-by: Alex Suraci <[email protected]>

* fully decouple dagger CLI from SDK codegen

* SDK runtime modules are now used for codegen, exposed as
  Module.generatedCode for ease of consumption
* Dagger CLI now hardcodes a mapping from SDK name ("go") to a pre-built
  SDK runtime image, currently pointing to a personal image ref. In
  practice we'll likely want to push these to tags that match the engine
  version.
* Dagger CLI now places the runtime image ref in dagger.json, which is
  the new source of truth for the module runtime.
* Merged core/moduleconfig/ and core/resolver/ into sdk/go/modules/.
  These are both critical for codegen, and make sense to expose in a
  stable library so that things like Daggerverse can use it.

Signed-off-by: Alex Suraci <[email protected]>

* sdk/go: fix generating empty object stub

this is actually just removing complexity that doesn't need to be around
anymore

Signed-off-by: Alex Suraci <[email protected]>

* sdk/go: build image on linux/amd64 and linux/arm64

Signed-off-by: Alex Suraci <[email protected]>

* fix constructing container from ID dropping platform

Signed-off-by: Alex Suraci <[email protected]>

* refactor sdk name => runtime flow, fix backwards compat

Signed-off-by: Alex Suraci <[email protected]>

* cache internal module calls

With SDKs as modules, this VERY quickly stacks up!

Caches the call to load the module, and the calls to the SDK runtime.
Everything else remains uncached. dagger mod sync is back to sub-0.5s.

Signed-off-by: Alex Suraci <[email protected]>

* silence that pesky version compatibility check

* Skip the entire call when connecting internally, to save time
* Log at Debug level for remaining cases where it makes sense to keep
  the check. If I'm already developing, I don't need to be warned about
  it all the time.

Signed-off-by: Alex Suraci <[email protected]>

* fix zero-ing out SDKRuntime when no SDK name set

Signed-off-by: Alex Suraci <[email protected]>

* show progress during codegen

kinda neat; directly uses progrock.sock for dagger mod sync, and just
uses local console output for on-the-fly codegen to avoid noise

Signed-off-by: Alex Suraci <[email protected]>

* add GeneratedCode type so codegen can give VCS hints

Now that codegen happens remotely, it doesn't make sense at all for it
to attempt to automate your local git repository. It also is hokey for
each SDK to concern itself with all the different kinds of VCSes. Git is
obviously dominant today, but there's no reason to make it the only
option at the SDK layer.

Instead SDKs now return a GeneratedCode type which lists file paths to
ignore and/or file paths to mark as generated. The CLI picks these up
and takes it from there.

Adding a whole new ID-able type took a bit of boilerplate, but it seems
worth it, and hopefully this pattern becomes cheaper with v2 IDs.

Signed-off-by: Alex Suraci <[email protected]>

* fix: don't use --vcs flag

not a thing anymore

Signed-off-by: Alex Suraci <[email protected]>

* Bust Function runtime cache once per-session.

Using a timestamp to bust function execution results in every call to a
function resulting in the full DAG of "internal" function calls (i.e.
calls to other functions from the implementation of one function) to be
walked along every possible path, which has exponential time complexity
and thus can cause genuine performance problems.

Now we instead use the server ID, which is randomly generated once per
session, to bust so that we still cache within the context of a single
session and thus avoid the poor time complexity.

Signed-off-by: Erik Sipsma <[email protected]>

* remove dead code

Signed-off-by: Alex Suraci <[email protected]>

* fix a couple of tests

Signed-off-by: Alex Suraci <[email protected]>

* fix gitignore path already there check

Signed-off-by: Alex Suraci <[email protected]>

* fix up go/nodejs codegen

Signed-off-by: Alex Suraci <[email protected]>

* bump sdk

Signed-off-by: Alex Suraci <[email protected]>

* regen python and java, fix python lint

Signed-off-by: Alex Suraci <[email protected]>

* Handle field parameters colliding with java keywords by prepending with a '_'.
Upgrade `TestWithDatabase` sample code with the new Service API

Signed-off-by: Jean-Christophe Sirot <[email protected]>

* fix: consistent errors for non-existent module directory

Previously, when a module was not provided for the dagger query command
using the `-m` flag, the error message did not indicate that the module
did not exist even when it was requested by the user.

This patch reworks the logic - dagger query will now always error if the
module provided by `-m` did not exist, but will keep the desired
behaviour that it should not error if the current directory is not a
module.

Signed-off-by: Justin Chadwell <[email protected]>

* fix: dagger mod init should require sdk and name args

We were previously calling the wrong function to do this.

Signed-off-by: Justin Chadwell <[email protected]>

* Add `dagger call` command

This is very WIP, just publishing so others can hack on it. Only supports "top-level" (from type that matches current module) functions without arguments and only tested functions that return a string.

Added `ParentName` to `core.Function` to fix a direct `dagger.Function.Call`. It used to work but is failing due to recent changes while unmarshaling input. However, since we plan to make a chained call, it's better to build a query instead of calling the functions directly.

See TODO list at the top for follow-ups.

Signed-off-by: Helder Correia <[email protected]>

* Small linting fix

Signed-off-by: Helder Correia <[email protected]>

* backport dagger shell

Signed-off-by: Erik Sipsma <[email protected]>

* chore: dagger shell branch: fix conflicts

Signed-off-by: grouville <[email protected]>

* fix: mount the correct dependency sub-folder

Without this, we can end up caching the wrong top-level directory.

Signed-off-by: Justin Chadwell <[email protected]>

* cleanup egregious stuff from dagger shell impl

Signed-off-by: Erik Sipsma <[email protected]>

* fix go sdk lints

Signed-off-by: Erik Sipsma <[email protected]>

* appease engine lints

Signed-off-by: Erik Sipsma <[email protected]>

* fix missed engine lint

Signed-off-by: Erik Sipsma <[email protected]>

* upgrade go+golangci to see if it fixes bizarre lint fail

Signed-off-by: Erik Sipsma <[email protected]>

* fix gitignore of sdk/go/runtime

Signed-off-by: Erik Sipsma <[email protected]>

* fix + test using multiple modules

two bug fixes:

1. dagger mod use incorrectly deduped on path alone, instead of also
   considering the subpath
1. a fun mutation bug in the schema was causing all sorts of fun module
   identity crises

Signed-off-by: Alex Suraci <[email protected]>

* fix go sdk tests

Signed-off-by: Erik Sipsma <[email protected]>

* fix elixer sdk lints

Signed-off-by: Erik Sipsma <[email protected]>

* appease residual lints

Signed-off-by: Erik Sipsma <[email protected]>

* upgrade sphinx-rtd-theme to see if it fixes read-the-docs build

Signed-off-by: Erik Sipsma <[email protected]>

* use session: prefix for blobsource

Signed-off-by: Erik Sipsma <[email protected]>

* add explicit requirements.txt for python docs

As of a few days ago, readthedocs requires you to explicitly set
dependencies in a requirements.txt:
https://blog.readthedocs.com/defaulting-latest-build-tools/

Signed-off-by: Erik Sipsma <[email protected]>

* stop pointerizing input types

this was needed to avoid dependency cycles in self-referential input
types, but we don't have those anymore, in favor of just always using
objects and passing them in by their ID.

Signed-off-by: Alex Suraci <[email protected]>

* use a hyper specific tag

just trying things on

Signed-off-by: Alex Suraci <[email protected]>

* regen go sdk

Signed-off-by: Alex Suraci <[email protected]>

* regen nodejs sdk

Signed-off-by: Alex Suraci <[email protected]>

* fix up tests (botched merge somewhere)

Signed-off-by: Alex Suraci <[email protected]>

* updated services docs for pr-5557

Signed-off-by: Jenn Allen <[email protected]>

* apply docs suggestions

thanks!

Co-authored-by: vikram-dagger <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>

* Updated services guides

Signed-off-by: Vikram Vaswani <[email protected]>

* Lint fix

Signed-off-by: Vikram Vaswani <[email protected]>

* Update docs/current/guides/snippets/build-test-publish-php/dagger.php

Co-authored-by: Alex Suraci <[email protected]>
Signed-off-by: vikram-dagger <[email protected]>

* Update docs/current/guides/757394-use-service-containers.md

Co-authored-by: Alex Suraci <[email protected]>
Signed-off-by: vikram-dagger <[email protected]>

* services: adopt new IDable patterns

Signed-off-by: Alex Suraci <[email protected]>

* regen SDKs

Signed-off-by: Alex Suraci <[email protected]>

* bump go sdk

Signed-off-by: Alex Suraci <[email protected]>

* fix newly added test

Signed-off-by: Alex Suraci <[email protected]>

* Updated examples and content

Signed-off-by: Vikram Vaswani <[email protected]>

* Lint fix

Signed-off-by: Vikram Vaswani <[email protected]>

* Lint fix

Signed-off-by: Vikram Vaswani <[email protected]>

* Updated filename and paths

Signed-off-by: Vikram Vaswani <[email protected]>

* Copy edit

Signed-off-by: Vikram Vaswani <[email protected]>

* Code update

Signed-off-by: Vikram Vaswani <[email protected]>

* docs tweaks

* compromise on Foo.barBaz syntax for referring to APIs
* fix what I think was a sentence ordering glitch ('select first port'
  applies to Endpoint specifically)
* turn Host.unixSocket tip into a guidepost instead of pointing out
  internal implementation details

Signed-off-by: Alex Suraci <[email protected]>

* Container.service -> Container.asService

Signed-off-by: Alex Suraci <[email protected]>

* make python lint happy

Signed-off-by: Alex Suraci <[email protected]>

* fix awkward gofmt formatting

Signed-off-by: Alex Suraci <[email protected]>

* Added code samples

Signed-off-by: Vikram Vaswani <[email protected]>

* Lint fixes

Signed-off-by: Vikram Vaswani <[email protected]>

* comment out incorrect code in example

Signed-off-by: Vikram Vaswani <[email protected]>

* Lint fix

Signed-off-by: Vikram Vaswani <[email protected]>

* Lint fix

Signed-off-by: Vikram Vaswani <[email protected]>

* Create guide expose-host-services-to-container for the node SDK

Signed-off-by: jffarge <[email protected]>

* Create a Node.js SDK guide for start-stop-services

Signed-off-by: jffarge <[email protected]>

* Remove unused fetch library

Signed-off-by: jffarge <[email protected]>

* rename main.go to main_test.go for to test

Signed-off-by: Alex Suraci <[email protected]>

* Added Python snippets

Signed-off-by: Vikram Vaswani <[email protected]>

* decouple core from internal/mage

this doesn't work when there are breaking changes (noted in two
comments)

Signed-off-by: Alex Suraci <[email protected]>

* regen SDKs

Signed-off-by: Alex Suraci <[email protected]>

* Revert "decouple core from internal/mage"

This reverts commit 1807036.

Signed-off-by: Alex Suraci <[email protected]>

* internal/mage: move consts into separate package

Signed-off-by: Alex Suraci <[email protected]>

* sdk/go: fix go.mod

Signed-off-by: Alex Suraci <[email protected]>

* undo main_test.go rename

misinterpreted the failure, and this actually causes ci failure

Signed-off-by: Alex Suraci <[email protected]>

* tidy

Signed-off-by: Alex Suraci <[email protected]>

* fix docs link

Signed-off-by: Alex Suraci <[email protected]>

* add a couple of awaits

Signed-off-by: Alex Suraci <[email protected]>

* services docs: v0.8.8 -> v0.9.0

Signed-off-by: Alex Suraci <[email protected]>

---------

Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Solomon Hykes <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Vikram Vaswani <[email protected]>
Signed-off-by: kpenfound <[email protected]>
Signed-off-by: Justin Chadwell <[email protected]>
Signed-off-by: Helder Correia <[email protected]>
Signed-off-by: Jean-Christophe Sirot <[email protected]>
Signed-off-by: grouville <[email protected]>
Signed-off-by: Jenn Allen <[email protected]>
Signed-off-by: vikram-dagger <[email protected]>
Signed-off-by: jffarge <[email protected]>
Co-authored-by: Solomon Hykes <[email protected]>
Co-authored-by: Erik Sipsma <[email protected]>
Co-authored-by: Vikram Vaswani <[email protected]>
Co-authored-by: kpenfound <[email protected]>
Co-authored-by: Justin Chadwell <[email protected]>
Co-authored-by: Solomon Hykes <[email protected]>
Co-authored-by: Helder Correia <[email protected]>
Co-authored-by: Jean-Christophe Sirot <[email protected]>
Co-authored-by: grouville <[email protected]>
Co-authored-by: Jenn Allen <[email protected]>
Co-authored-by: vikram-dagger <[email protected]>
Co-authored-by: jffarge <[email protected]>
schlapzz pushed a commit to schlapzz/dagger that referenced this pull request Nov 24, 2023
… via gateway (dagger#5557)

* h2c: reuse buf, set to 32k (same as io.Copy)

Signed-off-by: Alex Suraci <[email protected]>

* c2h: don't treat dial errors as fatal

Signed-off-by: Alex Suraci <[email protected]>

* c2h: set timeout for container release

matched 30 seconds to a timeout we set elsewhere on the same thing

Signed-off-by: Alex Suraci <[email protected]>

* Service.Clone: clone ports too

Signed-off-by: Alex Suraci <[email protected]>

* multierror -> errors.Join

Signed-off-by: Alex Suraci <[email protected]>

* h2c: cancel on server close

Signed-off-by: Alex Suraci <[email protected]>

* un-globalize AllServices

and get rid of WithServices because generic methods aren't supported and
wrappers are annoying anyway

Signed-off-by: Alex Suraci <[email protected]>

* fix premature cancel()

Signed-off-by: Alex Suraci <[email protected]>

* split Services out into a separate file, add godoc

lots of tricky behavior, worth documenting

Signed-off-by: Alex Suraci <[email protected]>

* elixir SDK: support INPUT_OBJECT

unclear why this is needed now, when we already have BuildArg

Signed-off-by: Alex Suraci <[email protected]>

* add changelog

Signed-off-by: Alex Suraci <[email protected]>

* make services no longer experimental

Couldn't find any instances on GitHub of anyone disabling this, and
there are no known open issues.

Code Search query:

    _EXPERIMENTAL_DAGGER_SERVICES_DNS AND (NOT "Currently experimental" OR "to running the Dagger Engine")

Signed-off-by: Alex Suraci <[email protected]>

* regen SDKs

Signed-off-by: Alex Suraci <[email protected]>

* disable engine-in-engine-dev for now

Signed-off-by: Alex Suraci <[email protected]>

* fix progrock deprecations/removals

Signed-off-by: Alex Suraci <[email protected]>

* testdata/nested -> testdata/nested-c2c

Signed-off-by: Alex Suraci <[email protected]>

* tests: client.Close cleanups

Signed-off-by: Alex Suraci <[email protected]>

* Zenith episode two: revenge of the function

Signed-off-by: Solomon Hykes <[email protected]>

* core: baseline core schema implementation for envs+checks.

Signed-off-by: Erik Sipsma <[email protected]>

* WIP module+function graphql schemas

Signed-off-by: Erik Sipsma <[email protected]>

* WIP modules+functions implementation

Signed-off-by: Erik Sipsma <[email protected]>

* WIP go sdk updates

Signed-off-by: Erik Sipsma <[email protected]>

* base working functions w/ go sdk

Signed-off-by: Erik Sipsma <[email protected]>

* update module test connect usage

Signed-off-by: Alex Suraci <[email protected]>

* disable depguard lint

not sure why we would want this, it fails locally on innocuous imports

Signed-off-by: Alex Suraci <[email protected]>

* disable unused param linters

These have mostly just been frustrating and unhelpful, usually resulting
in worse code than before.

Signed-off-by: Alex Suraci <[email protected]>

* fix up lints

Signed-off-by: Alex Suraci <[email protected]>

* support id-able types as inputs; extending core types

Signed-off-by: Erik Sipsma <[email protected]>

* fix support for chainable types

Signed-off-by: Erik Sipsma <[email protected]>

* ignore non-fatal compile errors

These we're causing annoying situations where you change a function
signature in user code, run `dagger mod sync` and then codegen gets a
compilation error because the old main func is incompatible with the new
signature and hasn't been updated yet.

Just ignoring these sorts of errors avoids this situation and doesn't
really cause any harm. We can still try parse the code and generate from
there. If the end result is still not compilable, then it just won't be
runnable.

Signed-off-by: Erik Sipsma <[email protected]>

* flesh out zenith intro instructions, add demo mod

zenith/ is now has an .envrc, making it suitable as a temporary
playground for writing Zenith modules

Signed-off-by: Alex Suraci <[email protected]>

* bump Go runtime to 1.21

otherwise fresh mods created with 1.21 fail on 'go 1.21.0' in go.mod

Signed-off-by: Alex Suraci <[email protected]>

* query: fix --progress=plain requirement

Signed-off-by: Alex Suraci <[email protected]>

* fix sdk/go unit tests

Signed-off-by: Alex Suraci <[email protected]>

* codegen: generate querybuilder/ package

fixes go mod replace issue

Signed-off-by: Alex Suraci <[email protected]>

* mod init: bootstrap Go module

This is a really delicate dance. For whatever reason Go doesn't like
these go.mod/go.sum files hoisted over from sdk/go/ and requires you to
run `go mod tidy`, otherwise it complains about entries missing from
go.sum, which is confusing because it works just fine for the SDK.

So the order of operations is:

* Detect if a main package exists.
* If it doesn't, write an initial main.go file before we even start
  doing codegen, otherwise the initial codegen won't have anything to
  process.
* Run code generation.
* Write initial go.mod/go.sum files with a sane default Go module name
  based on the outer module.
  * If no outer module is found, the bare Dagger module name is used and
    a warning is printed.
* Run go mod tidy.

The last step is critical; without it, dagger mod sync will error on the
same errors mentioned in the first paragraph.

Signed-off-by: Alex Suraci <[email protected]>

* support multiple passes for codegen

There's a chicken/egg problem with running codegen and generating stub
templates. If the template refers to a type like Container, the
introspection will have no idea what that refers to on the first pass.
So we need to do one pass to generate all the base types, and then
another pass to generate from the stub.

Signed-off-by: Alex Suraci <[email protected]>

* fix post-merge compilation errors

Signed-off-by: Alex Suraci <[email protected]>

* un-break cmd/client-gen

Signed-off-by: Alex Suraci <[email protected]>

* re-bump progrock for ioctl fix

Signed-off-by: Alex Suraci <[email protected]>

* respect existing .gitattributes

Signed-off-by: Alex Suraci <[email protected]>

* update core/integration for input pointer change

not completely sure if we want this, rolling with it for now

pros:

* everything is always a pointer, don't need to special-case input types
  vs regular types

cons:

* breaking change
* plain input types don't feel as intuitive as pointers

Signed-off-by: Alex Suraci <[email protected]>

* codegen: respect existing go.mod

Signed-off-by: Alex Suraci <[email protected]>

* listen: add --allow-cors

makes it easy to use off-the-shelf GraphQL inspectors

Signed-off-by: Alex Suraci <[email protected]>

* support non-local module dependencies

Signed-off-by: Alex Suraci <[email protected]>

* fix TypeDef { kind } resolving to 'null'

Signed-off-by: Alex Suraci <[email protected]>

* fix uninterruptible codegen

Signed-off-by: Alex Suraci <[email protected]>

* query: unfocus by default

Signed-off-by: Alex Suraci <[email protected]>

* bump progrock to avoid printing TUI to redirected stderr

Signed-off-by: Alex Suraci <[email protected]>

* use a single strcase package

Signed-off-by: Alex Suraci <[email protected]>

* fix module dependencies not loading

(this is thanks to a flying Erik)

Signed-off-by: Alex Suraci <[email protected]>

* Module: expose sdk, dependencies, source dir

To be used in Da Daggerverse.

Signed-off-by: Alex Suraci <[email protected]>

* dagger mod extend -> use

Signed-off-by: Alex Suraci <[email protected]>

* fix always getting description of first func

Signed-off-by: Alex Suraci <[email protected]>

* expose dependency configs

this helps daggerverse crawl a module recursively, since otherwise it
can't know how people should fetch the module

Signed-off-by: Alex Suraci <[email protected]>

* new module ref format, resolve at use time

The new format is Go module style:

  github.com/foo/bar/subpath@version

In dagger.json, the version will _always_ be a commit. The CLI accepts
any ref; it will be resolved by dagger mod use.

This format might change again, since there are gotchas that make this
hard to support in the general case (e.g. GitLab's arbitrarily-nested
repo URIs). but this is easier on the eyes. We probably also want to
stick with semver tags rather than commits. I'll figure that out next.

It would be nice if there was an easy-on-the-eyes scheme that was
totally unambiguous as to whether the provided ref is a branch, tag, or
commit, and which part is the repo and which part is the subpath.

Signed-off-by: Alex Suraci <[email protected]>

* fix uninterruptible package loading

Signed-off-by: Alex Suraci <[email protected]>

* thread ctx through to template packages.Load too

Signed-off-by: Alex Suraci <[email protected]>

* fix a couple of rogue filepath.Dirs

Signed-off-by: Alex Suraci <[email protected]>

* support distinguishing git commit from desired tag

in practice these are both just commits until semver tags are supported

Signed-off-by: Alex Suraci <[email protected]>

* fix -m with git ref

Signed-off-by: Alex Suraci <[email protected]>

* Added example to README

Signed-off-by: Vikram Vaswani <[email protected]>

* Fixed indentation in README example

Signed-off-by: Vikram Vaswani <[email protected]>

* tweak git docs

Signed-off-by: kpenfound <[email protected]>

* revise README

* avoid ./zenith/zenith
* avoid reusing Vito module name for 'create your own' flow
* add caveat for extending core types

Signed-off-by: Alex Suraci <[email protected]>

* Zenith README: chaining example

Signed-off-by: Solomon Hykes <[email protected]>

* Zenith README: fix errors

Signed-off-by: Solomon Hykes <[email protected]>

* fix: dagger mod use should override previous versions

Previously, dagger mod use would allow creating multiple versions of a
single module:

	{
	  "root": "",
	  "name": "foo",
	  "sdk": "go",
	  "dependencies": [
	    "github.com/<example>/daggerverse@aaa"
	    "github.com/<example>/daggerverse@bbb"
	  ]
	}

To prevent this, we can resolve all the dependencies, and then use the
dependency set based on only the path instead of the combination of path
and version.

Signed-off-by: Justin Chadwell <[email protected]>

* non-error returns, void returns, optional ctx

Signed-off-by: Alex Suraci <[email protected]>

* bump graphql for explicit scalar error handling

otherwise it's impossible to have a JSON scalar that evaluates to null
(which is how void return values are represented), since it gets treated
as an error

Signed-off-by: Alex Suraci <[email protected]>

* fix lints

Signed-off-by: Alex Suraci <[email protected]>

* skip non-working env tests

Signed-off-by: Alex Suraci <[email protected]>

* avoid panic if proxy env not set

likely an underlying bug here though; env should be set

Signed-off-by: Alex Suraci <[email protected]>

* fix services not having ProxyEnv

this used to be baked into the DAG as part of WithExec, but that moved
to Client.Solve, so we need to do the same thing here.

Signed-off-by: Alex Suraci <[email protected]>

* allow non-ctx first arg

Signed-off-by: Alex Suraci <[email protected]>

* sdk/go modules support Opts args

This is an alternative format to regular args that allows you to accept
optional args with default values.

There's a slight smell that defaults aren't applied for
function-to-function calls within the module. It might not be worth
having the default:"..." tag for that reason, but it's nice to have them
in the GraphQL schema.

Signed-off-by: Alex Suraci <[email protected]>

* refactor for gocyclo lint

Signed-off-by: Alex Suraci <[email protected]>

* add test for custom types

Signed-off-by: Alex Suraci <[email protected]>

* fix not including functions for custom types

this fix is a bit hacky (bool arg, whee); the long-term fix is to
refactor the schema so that modules can provide multiple Object types,
instead of relying on crawling the module's own functions

Signed-off-by: Alex Suraci <[email protected]>

* fix: prevent Directory.Without from failing on missing files

Other similar Without methods, such as `container.WithoutMount` do not
fail if the target is not present.

However, previously in BuildKit, the llb.WithAllowNotFound was never
explicitly required. Updating to the newer BuildKit correctly respects
this option, so we need to include llb.WithAllowNotFound directly.

Signed-off-by: Justin Chadwell <[email protected]>

* don't recursively load packages

attempting to peacefully coexist with tools like goenv and asdf, don't
think this ever needed to be recursive

Signed-off-by: Alex Suraci <[email protected]>

* fix: apply ToLowerCamel consistently

Signed-off-by: Justin Chadwell <[email protected]>

* fix + test using local modules

Signed-off-by: Alex Suraci <[email protected]>

* switch from input types to withFoo pattern

Previously functions and types were represented as input types, which
was a little inconvenient in two ways:

* You can't return an input type, so any type that needed to be returned
  had a duplicate 'regular' type definition.
* One of the input types (TypeDef) was self-referential, meaning we had
  to switch to pointers for input types, which was a breaking change for
  things like BuildArg (which still needs to be rolled back).

This commit changes TypeDef to use the more familiar withFoo style of
construction instead, and adds a TypeDefID so that it can be passed as
an input.

A possible downside here is that the module's entrypoint that registers
all the objects might involve multiple API calls to pass IDs around. I
haven't measured performance, but it's certainly hard to beat passing
all of the information in as one big precomputed type.

Signed-off-by: Alex Suraci <[email protected]>

* Make engine version overrideable

Signed-off-by: Solomon Hykes <[email protected]>

* dagger version also prints worker registry address

Signed-off-by: Solomon Hykes <[email protected]>

* debugging module failure

Signed-off-by: Alex Suraci <[email protected]>

* fix references to other objects

Signed-off-by: Alex Suraci <[email protected]>

* only unmarshal opts that are present

Signed-off-by: Alex Suraci <[email protected]>

* fix passing lists to functions

Signed-off-by: Alex Suraci <[email protected]>

* fix self-referential (chaining) types

Signed-off-by: Alex Suraci <[email protected]>

* un-weird container.Clone

this was causing panics to happen at a later time, not sure if/why it's
needed or leftover debugging

Signed-off-by: Alex Suraci <[email protected]>

* fixup remove logs

confirmed everything was ok

Signed-off-by: Alex Suraci <[email protected]>

* register multiple objects

Previously we would only register the main module, which only allowed
functions on types referenced and embedded in the module's own TypeDefs
to be registered.

Now we'll instead register each object separately, with shallow
references to other types embedded.

Along the way, fixed an issue that I was able to reproduce with
self-referential types:

  vito/dagger-gitutil@d919459

The function was being called with an empty ModuleID. I checked to see
if it was a regression and it seemed to be broken in a different way
before (circular reference in TypeDef somehow).

Signed-off-by: Alex Suraci <[email protected]>

* remove overly defensive guard

this was mostly for debugging

Signed-off-by: Alex Suraci <[email protected]>

* fix extending existing types

Signed-off-by: Alex Suraci <[email protected]>

* only stitch module constructor, not all types

This was never the intention, and seems to be breaking shykes/dagger.

I think we might just want to let users define explicit constructors or
something. Maybe by defining methods on *Client? (Ideally that'd be *DAG
or something instead.)

Signed-off-by: Alex Suraci <[email protected]>

* Add minimal Python support

Signed-off-by: Helder Correia <[email protected]>

* go codegen: preserve definition order, pretty-print

Signed-off-by: Alex Suraci <[email protected]>

* fix code that can't run anyway, explain why

Signed-off-by: Alex Suraci <[email protected]>

* roll back debugging code

Signed-off-by: Alex Suraci <[email protected]>

* Add git to the Python runtime

Signed-off-by: Helder Correia <[email protected]>

* mount dagger CLI to /bin/dagger when nesting

Motivated by the next commit, but seems like a worthwhile experiment in
its own right.

Signed-off-by: Alex Suraci <[email protected]>

* goruntime: run dagger mod sync before building

This way you don't need to commit all the generated code.

A better way to approach this would be to move this responsibility into
a pluggable runtime image, which technically we're doing, just in a
round-about way. Maybe runtimes can just be external images.

Signed-off-by: Alex Suraci <[email protected]>

* fix setting empty field description

Signed-off-by: Alex Suraci <[email protected]>

* remove now-superfluous mod sync commands

codegen now happens on-the-fly

Signed-off-by: Alex Suraci <[email protected]>

* add TESTFLAGS="-foo -bar ./baz/" engine:testcustom

Signed-off-by: Alex Suraci <[email protected]>

* test wrapping/unwrapping core types

Signed-off-by: Alex Suraci <[email protected]>

* only generate main.go if it doesn't already exist

Signed-off-by: Alex Suraci <[email protected]>

* fix a couple of module loading bugs

TestModuleGoUseLocal has been driving my crazy - it was failing in CI,
and in ./hack/make engine:test, but succeeding with ./hack/dev go test!

I had also previously seen it fail by allowing `dagger query` to hit
transitive dependencies, but it would sometimes to pass.

The latest flavor of failure is because (*Client).Dep is not defined in
the generated code for the Use module (which uses a dep called Dep). The
root cause turned out to be two bugs interacting:

* The schema stitching process was checking for pre-existing types by
  querying the currentSchemaView, which seemed to be the "" schema view,
  rather than checking the view that's being extended.

* The dagger CLI was calling .Serve on each dependency, which caused
  them to be stitched in to the "" schema view.

As a result, Dep's schema wasn't being fully generated into the view
because the stitching process saw that it was installed in the "" view.

The first fix is to simply stop calling Serve for dependencies in the
CLI. Dependencies are already served to the dependent module's schema
view at FromConfig time, so this isn't necessary for codegen. I may have
added this by mistake while figuring out how everything works. Not sure.

The second fix is to check against the destination schema view to
determine whether things are already defined, rather than checking
against the "" schema view. This just feels more correct in general. It
mostly worked before because the "" schema view and the destination
schema view always started from the schema of all core types, but
technically if someone loaded a module into the "" schema you'd get the
same breakage observed here.

Signed-off-by: Alex Suraci <[email protected]>

* fix lints

Signed-off-by: Alex Suraci <[email protected]>

* sdk/nodejs: handle reserve words, regen

now appends _ to any word that is reserved in JavaScript/TypeScript.
chiefly "function."

Signed-off-by: Alex Suraci <[email protected]>

* pythonruntime: fmt

Signed-off-by: Alex Suraci <[email protected]>

* draft some GraphQL API docs

Signed-off-by: Alex Suraci <[email protected]>

* regen rust

Signed-off-by: Alex Suraci <[email protected]>

* regen elixir sdk

had to manually revert the original changes first; SDK regen doesn't
remove no-longer-needed files (e.g. environment.ex)

Signed-off-by: Alex Suraci <[email protected]>

* sdk/nodejs: allow from and export without _

this was working before, so let's stick with it.

Signed-off-by: Alex Suraci <[email protected]>

* regen go, python, nodejs

Signed-off-by: Alex Suraci <[email protected]>

* regen java

Signed-off-by: Alex Suraci <[email protected]>

* Abandon black's preview style

Signed-off-by: Helder Correia <[email protected]>

* add basic test for extending core types

intentionally covers the smallest example: extending a core type, while
defining no additional types or functions of our own. previously this
did not work because only types discoverable by crawling the module's
functions would be added.

Signed-off-by: Alex Suraci <[email protected]>

* Add support for new scalars JSON, Void, ModuleID, FunctionID, TypeDefID in Java SDK

Signed-off-by: Jean-Christophe Sirot <[email protected]>

* refactor + test codegen

trying to move this into a higher-level API that SDK codegen, `dagger
mod sync`, and Runtimes can all use directly

Signed-off-by: Alex Suraci <[email protected]>

* dagger mod init: test and handle more situations

also generally clean up and consolidate logging/progrock usage

Signed-off-by: Alex Suraci <[email protected]>

* move querybuilder back under ./internal/

Signed-off-by: Alex Suraci <[email protected]>

* go codegen: .gitignore generated files

Signed-off-by: Alex Suraci <[email protected]>

* fix modules_test.go

Signed-off-by: Alex Suraci <[email protected]>

* refactor codegen order, .gitignore generated files

also remove previously-committed generated files along the way

Signed-off-by: Alex Suraci <[email protected]>

* fix loading not-generated package

Signed-off-by: Alex Suraci <[email protected]>

* move git tests to separate

Signed-off-by: Alex Suraci <[email protected]>

* clean up and regen modules

Signed-off-by: Alex Suraci <[email protected]>

* HACK: add cache buster

this codegen really needs to be put into the image

Signed-off-by: Alex Suraci <[email protected]>

* load non-module package, too

needed for sdk:go:generate

Signed-off-by: Alex Suraci <[email protected]>

* remove unused func

Signed-off-by: Alex Suraci <[email protected]>

* fix handling of root: .., support outer go.mod

Signed-off-by: Alex Suraci <[email protected]>

* generate base dagger.gen.go if it doesn't exist

otherwise you can end up stuck with code that refers to unknown types if
you deleted the file

Signed-off-by: Alex Suraci <[email protected]>

* fix tricky ordering, yay tests

Signed-off-by: Alex Suraci <[email protected]>

* disable crippling memoization

Signed-off-by: Solomon Hykes <[email protected]>

* module-ize codegen by moving it under sdk/go

Here's the plan: each SDK provides a module for running codegen against
user modules.

These SDK modules replace the runtimes that current live in core. Once
bootstrapped, they can be pushed to an image registry and invoked from
the CLI.

For the Go SDK this works out nicely because codegen already depended on
the SDK client, so now it can just live in the same module.

For now, the NodeJS codegen also made the trip into sdk/go/.
Theoretically this codegen could be split out into a separate module,
but right now the juice isn't worth the squeeze. The dagger.io/dagger
module is already oriented the right way dependency-wise.

Signed-off-by: Alex Suraci <[email protected]>

* use bootstrapped vito/dagger-sdk-go image

This was tricky: now when we're loading a module we _also_ need to load
its SDK module and call its function to build the runtime. Loading
modules and calling functions currently actually lives in core/schema/,
while constructing a module and setting up the runtime lives in core/,
so for now I've just hacked a callback function into
(core.Module).FromConfig, which lets me call back to core/schema/.

There's a specific interface that SDK modules must implement, currently
totally ad-hoc, worth bikeshedding:

  moduleRuntime(modSource: DirectoryID!, subPath: String): Container!

Signed-off-by: Alex Suraci <[email protected]>

* tidy up runtime bootstrapping

Previously this passed the _dependent_ module's source path + dir to the
SDK which was completely bogus. now it uses the SDK's. I'm starting to
suspect this didn't actually work before, and I was being fooled by
aggressive function caching, _or_ the fact that my 'with-dev' helper was
actually running the wrong CLI.

Now we use a special label to get the path to the module config. Not
totally sure about this. Committing mostly as a checkpoint.

Signed-off-by: Alex Suraci <[email protected]>

* avoid blank line at start of .gitignore

Signed-off-by: Alex Suraci <[email protected]>

* avoid generating bogus go.mod

Signed-off-by: Alex Suraci <[email protected]>

* Directory.asModule can be given a pre-built runtime

This is useful for bootstrapping SDKs (see next commit).

Signed-off-by: Alex Suraci <[email protected]>

* sdk/go: add bootstrapping for runtime image

We are now fully independent from the goruntime code currently living on
zenith-functions! See help.txt for details.

Signed-off-by: Alex Suraci <[email protected]>

* fully decouple dagger CLI from SDK codegen

* SDK runtime modules are now used for codegen, exposed as
  Module.generatedCode for ease of consumption
* Dagger CLI now hardcodes a mapping from SDK name ("go") to a pre-built
  SDK runtime image, currently pointing to a personal image ref. In
  practice we'll likely want to push these to tags that match the engine
  version.
* Dagger CLI now places the runtime image ref in dagger.json, which is
  the new source of truth for the module runtime.
* Merged core/moduleconfig/ and core/resolver/ into sdk/go/modules/.
  These are both critical for codegen, and make sense to expose in a
  stable library so that things like Daggerverse can use it.

Signed-off-by: Alex Suraci <[email protected]>

* sdk/go: fix generating empty object stub

this is actually just removing complexity that doesn't need to be around
anymore

Signed-off-by: Alex Suraci <[email protected]>

* sdk/go: build image on linux/amd64 and linux/arm64

Signed-off-by: Alex Suraci <[email protected]>

* fix constructing container from ID dropping platform

Signed-off-by: Alex Suraci <[email protected]>

* refactor sdk name => runtime flow, fix backwards compat

Signed-off-by: Alex Suraci <[email protected]>

* cache internal module calls

With SDKs as modules, this VERY quickly stacks up!

Caches the call to load the module, and the calls to the SDK runtime.
Everything else remains uncached. dagger mod sync is back to sub-0.5s.

Signed-off-by: Alex Suraci <[email protected]>

* silence that pesky version compatibility check

* Skip the entire call when connecting internally, to save time
* Log at Debug level for remaining cases where it makes sense to keep
  the check. If I'm already developing, I don't need to be warned about
  it all the time.

Signed-off-by: Alex Suraci <[email protected]>

* fix zero-ing out SDKRuntime when no SDK name set

Signed-off-by: Alex Suraci <[email protected]>

* show progress during codegen

kinda neat; directly uses progrock.sock for dagger mod sync, and just
uses local console output for on-the-fly codegen to avoid noise

Signed-off-by: Alex Suraci <[email protected]>

* add GeneratedCode type so codegen can give VCS hints

Now that codegen happens remotely, it doesn't make sense at all for it
to attempt to automate your local git repository. It also is hokey for
each SDK to concern itself with all the different kinds of VCSes. Git is
obviously dominant today, but there's no reason to make it the only
option at the SDK layer.

Instead SDKs now return a GeneratedCode type which lists file paths to
ignore and/or file paths to mark as generated. The CLI picks these up
and takes it from there.

Adding a whole new ID-able type took a bit of boilerplate, but it seems
worth it, and hopefully this pattern becomes cheaper with v2 IDs.

Signed-off-by: Alex Suraci <[email protected]>

* fix: don't use --vcs flag

not a thing anymore

Signed-off-by: Alex Suraci <[email protected]>

* Bust Function runtime cache once per-session.

Using a timestamp to bust function execution results in every call to a
function resulting in the full DAG of "internal" function calls (i.e.
calls to other functions from the implementation of one function) to be
walked along every possible path, which has exponential time complexity
and thus can cause genuine performance problems.

Now we instead use the server ID, which is randomly generated once per
session, to bust so that we still cache within the context of a single
session and thus avoid the poor time complexity.

Signed-off-by: Erik Sipsma <[email protected]>

* remove dead code

Signed-off-by: Alex Suraci <[email protected]>

* fix a couple of tests

Signed-off-by: Alex Suraci <[email protected]>

* fix gitignore path already there check

Signed-off-by: Alex Suraci <[email protected]>

* fix up go/nodejs codegen

Signed-off-by: Alex Suraci <[email protected]>

* bump sdk

Signed-off-by: Alex Suraci <[email protected]>

* regen python and java, fix python lint

Signed-off-by: Alex Suraci <[email protected]>

* Handle field parameters colliding with java keywords by prepending with a '_'.
Upgrade `TestWithDatabase` sample code with the new Service API

Signed-off-by: Jean-Christophe Sirot <[email protected]>

* fix: consistent errors for non-existent module directory

Previously, when a module was not provided for the dagger query command
using the `-m` flag, the error message did not indicate that the module
did not exist even when it was requested by the user.

This patch reworks the logic - dagger query will now always error if the
module provided by `-m` did not exist, but will keep the desired
behaviour that it should not error if the current directory is not a
module.

Signed-off-by: Justin Chadwell <[email protected]>

* fix: dagger mod init should require sdk and name args

We were previously calling the wrong function to do this.

Signed-off-by: Justin Chadwell <[email protected]>

* Add `dagger call` command

This is very WIP, just publishing so others can hack on it. Only supports "top-level" (from type that matches current module) functions without arguments and only tested functions that return a string.

Added `ParentName` to `core.Function` to fix a direct `dagger.Function.Call`. It used to work but is failing due to recent changes while unmarshaling input. However, since we plan to make a chained call, it's better to build a query instead of calling the functions directly.

See TODO list at the top for follow-ups.

Signed-off-by: Helder Correia <[email protected]>

* Small linting fix

Signed-off-by: Helder Correia <[email protected]>

* backport dagger shell

Signed-off-by: Erik Sipsma <[email protected]>

* chore: dagger shell branch: fix conflicts

Signed-off-by: grouville <[email protected]>

* fix: mount the correct dependency sub-folder

Without this, we can end up caching the wrong top-level directory.

Signed-off-by: Justin Chadwell <[email protected]>

* cleanup egregious stuff from dagger shell impl

Signed-off-by: Erik Sipsma <[email protected]>

* fix go sdk lints

Signed-off-by: Erik Sipsma <[email protected]>

* appease engine lints

Signed-off-by: Erik Sipsma <[email protected]>

* fix missed engine lint

Signed-off-by: Erik Sipsma <[email protected]>

* upgrade go+golangci to see if it fixes bizarre lint fail

Signed-off-by: Erik Sipsma <[email protected]>

* fix gitignore of sdk/go/runtime

Signed-off-by: Erik Sipsma <[email protected]>

* fix + test using multiple modules

two bug fixes:

1. dagger mod use incorrectly deduped on path alone, instead of also
   considering the subpath
1. a fun mutation bug in the schema was causing all sorts of fun module
   identity crises

Signed-off-by: Alex Suraci <[email protected]>

* fix go sdk tests

Signed-off-by: Erik Sipsma <[email protected]>

* fix elixer sdk lints

Signed-off-by: Erik Sipsma <[email protected]>

* appease residual lints

Signed-off-by: Erik Sipsma <[email protected]>

* upgrade sphinx-rtd-theme to see if it fixes read-the-docs build

Signed-off-by: Erik Sipsma <[email protected]>

* use session: prefix for blobsource

Signed-off-by: Erik Sipsma <[email protected]>

* add explicit requirements.txt for python docs

As of a few days ago, readthedocs requires you to explicitly set
dependencies in a requirements.txt:
https://blog.readthedocs.com/defaulting-latest-build-tools/

Signed-off-by: Erik Sipsma <[email protected]>

* stop pointerizing input types

this was needed to avoid dependency cycles in self-referential input
types, but we don't have those anymore, in favor of just always using
objects and passing them in by their ID.

Signed-off-by: Alex Suraci <[email protected]>

* use a hyper specific tag

just trying things on

Signed-off-by: Alex Suraci <[email protected]>

* regen go sdk

Signed-off-by: Alex Suraci <[email protected]>

* regen nodejs sdk

Signed-off-by: Alex Suraci <[email protected]>

* fix up tests (botched merge somewhere)

Signed-off-by: Alex Suraci <[email protected]>

* updated services docs for pr-5557

Signed-off-by: Jenn Allen <[email protected]>

* apply docs suggestions

thanks!

Co-authored-by: vikram-dagger <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>

* Updated services guides

Signed-off-by: Vikram Vaswani <[email protected]>

* Lint fix

Signed-off-by: Vikram Vaswani <[email protected]>

* Update docs/current/guides/snippets/build-test-publish-php/dagger.php

Co-authored-by: Alex Suraci <[email protected]>
Signed-off-by: vikram-dagger <[email protected]>

* Update docs/current/guides/757394-use-service-containers.md

Co-authored-by: Alex Suraci <[email protected]>
Signed-off-by: vikram-dagger <[email protected]>

* services: adopt new IDable patterns

Signed-off-by: Alex Suraci <[email protected]>

* regen SDKs

Signed-off-by: Alex Suraci <[email protected]>

* bump go sdk

Signed-off-by: Alex Suraci <[email protected]>

* fix newly added test

Signed-off-by: Alex Suraci <[email protected]>

* Updated examples and content

Signed-off-by: Vikram Vaswani <[email protected]>

* Lint fix

Signed-off-by: Vikram Vaswani <[email protected]>

* Lint fix

Signed-off-by: Vikram Vaswani <[email protected]>

* Updated filename and paths

Signed-off-by: Vikram Vaswani <[email protected]>

* Copy edit

Signed-off-by: Vikram Vaswani <[email protected]>

* Code update

Signed-off-by: Vikram Vaswani <[email protected]>

* docs tweaks

* compromise on Foo.barBaz syntax for referring to APIs
* fix what I think was a sentence ordering glitch ('select first port'
  applies to Endpoint specifically)
* turn Host.unixSocket tip into a guidepost instead of pointing out
  internal implementation details

Signed-off-by: Alex Suraci <[email protected]>

* Container.service -> Container.asService

Signed-off-by: Alex Suraci <[email protected]>

* make python lint happy

Signed-off-by: Alex Suraci <[email protected]>

* fix awkward gofmt formatting

Signed-off-by: Alex Suraci <[email protected]>

* Added code samples

Signed-off-by: Vikram Vaswani <[email protected]>

* Lint fixes

Signed-off-by: Vikram Vaswani <[email protected]>

* comment out incorrect code in example

Signed-off-by: Vikram Vaswani <[email protected]>

* Lint fix

Signed-off-by: Vikram Vaswani <[email protected]>

* Lint fix

Signed-off-by: Vikram Vaswani <[email protected]>

* Create guide expose-host-services-to-container for the node SDK

Signed-off-by: jffarge <[email protected]>

* Create a Node.js SDK guide for start-stop-services

Signed-off-by: jffarge <[email protected]>

* Remove unused fetch library

Signed-off-by: jffarge <[email protected]>

* rename main.go to main_test.go for to test

Signed-off-by: Alex Suraci <[email protected]>

* Added Python snippets

Signed-off-by: Vikram Vaswani <[email protected]>

* decouple core from internal/mage

this doesn't work when there are breaking changes (noted in two
comments)

Signed-off-by: Alex Suraci <[email protected]>

* regen SDKs

Signed-off-by: Alex Suraci <[email protected]>

* Revert "decouple core from internal/mage"

This reverts commit 1807036.

Signed-off-by: Alex Suraci <[email protected]>

* internal/mage: move consts into separate package

Signed-off-by: Alex Suraci <[email protected]>

* sdk/go: fix go.mod

Signed-off-by: Alex Suraci <[email protected]>

* undo main_test.go rename

misinterpreted the failure, and this actually causes ci failure

Signed-off-by: Alex Suraci <[email protected]>

* tidy

Signed-off-by: Alex Suraci <[email protected]>

* fix docs link

Signed-off-by: Alex Suraci <[email protected]>

* add a couple of awaits

Signed-off-by: Alex Suraci <[email protected]>

* services docs: v0.8.8 -> v0.9.0

Signed-off-by: Alex Suraci <[email protected]>

---------

Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Solomon Hykes <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Vikram Vaswani <[email protected]>
Signed-off-by: kpenfound <[email protected]>
Signed-off-by: Justin Chadwell <[email protected]>
Signed-off-by: Helder Correia <[email protected]>
Signed-off-by: Jean-Christophe Sirot <[email protected]>
Signed-off-by: grouville <[email protected]>
Signed-off-by: Jenn Allen <[email protected]>
Signed-off-by: vikram-dagger <[email protected]>
Signed-off-by: jffarge <[email protected]>
Co-authored-by: Solomon Hykes <[email protected]>
Co-authored-by: Erik Sipsma <[email protected]>
Co-authored-by: Vikram Vaswani <[email protected]>
Co-authored-by: kpenfound <[email protected]>
Co-authored-by: Justin Chadwell <[email protected]>
Co-authored-by: Solomon Hykes <[email protected]>
Co-authored-by: Helder Correia <[email protected]>
Co-authored-by: Jean-Christophe Sirot <[email protected]>
Co-authored-by: grouville <[email protected]>
Co-authored-by: Jenn Allen <[email protected]>
Co-authored-by: vikram-dagger <[email protected]>
Co-authored-by: jffarge <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/breaking Breaking Change

Projects

None yet

Development

Successfully merging this pull request may close these issues.