From 10a23b5de1f4b3396dfd0e5940120e2d06752aad Mon Sep 17 00:00:00 2001 From: vikram-dagger <112123850+vikram-dagger@users.noreply.github.com> Date: Wed, 11 Dec 2024 15:41:50 +0400 Subject: [PATCH] docs: Update code snippets for services API changes (#9113) Co-authored-by: Justin Chadwell --- .../services/bind-services/go/main.go | 5 ++-- .../services/bind-services/python/main.py | 3 +- .../bind-services/typescript/index.ts | 3 +- .../create-interdependent-services/go/main.go | 14 ++++------ .../python/main.py | 18 ++++++++---- .../typescript/index.ts | 28 ++++++++++--------- .../expose-dagger-services-to-host/go/main.go | 7 +++-- .../python/main.py | 3 +- .../typescript/index.ts | 3 +- .../expose-host-services-to-dagger/go/main.go | 2 +- .../services/persist-service-state/go/main.go | 4 +-- .../persist-service-state/python/main.py | 2 +- .../persist-service-state/typescript/index.ts | 2 +- .../services/service-lifecycle-1/go/main.go | 4 ++- .../service-lifecycle-1/python/main.py | 7 ++++- .../service-lifecycle-1/typescript/index.ts | 2 +- .../services/service-lifecycle-2/go/main.go | 4 ++- .../service-lifecycle-2/python/main.py | 7 ++++- .../service-lifecycle-2/typescript/index.ts | 2 +- .../services/service-lifecycle-3/go/main.go | 4 ++- .../service-lifecycle-3/python/main.py | 7 ++++- .../service-lifecycle-3/typescript/index.ts | 2 +- .../services/start-stop-services/go/main.go | 4 ++- .../test-against-db-service/go/main.go | 4 ++- .../test-against-db-service/python/main.py | 2 +- .../typescript/index.ts | 2 +- .../cookbook/snippets/set-env-var/go/main.go | 6 +--- .../cookbook/snippets/set-env-vars/go/main.go | 2 -- .../features/snippets/debugging-1/go/main.go | 6 +--- .../programmable-pipelines-1/go/main.go | 2 -- .../programmable-pipelines-2/go/main.go | 2 -- .../features/snippets/services-1/go/main.go | 5 +--- .../snippets/services-1/python/main.py | 3 +- .../snippets/services-1/typescript/index.ts | 3 +- .../features/snippets/services-2/go/main.go | 2 -- 35 files changed, 90 insertions(+), 86 deletions(-) diff --git a/docs/current_docs/api/snippets/services/bind-services/go/main.go b/docs/current_docs/api/snippets/services/bind-services/go/main.go index 7996d88e8f..044fdfa770 100644 --- a/docs/current_docs/api/snippets/services/bind-services/go/main.go +++ b/docs/current_docs/api/snippets/services/bind-services/go/main.go @@ -2,7 +2,7 @@ package main import ( "context" - "main/internal/dagger" + "dagger/my-module/internal/dagger" ) type MyModule struct{} @@ -13,9 +13,8 @@ func (m *MyModule) HttpService() *dagger.Service { From("python"). WithWorkdir("/srv"). WithNewFile("index.html", "Hello, world!"). - WithDefaultArgs([]string{"python", "-m", "http.server", "8080"}). WithExposedPort(8080). - AsService() + AsService(dagger.ContainerAsServiceOpts{Args: []string{"python", "-m", "http.server", "8080"}}) } // Send a request to an HTTP service and return the response diff --git a/docs/current_docs/api/snippets/services/bind-services/python/main.py b/docs/current_docs/api/snippets/services/bind-services/python/main.py index bd1f28e729..cc410f6b9d 100644 --- a/docs/current_docs/api/snippets/services/bind-services/python/main.py +++ b/docs/current_docs/api/snippets/services/bind-services/python/main.py @@ -12,9 +12,8 @@ def http_service(self) -> dagger.Service: .from_("python") .with_workdir("/srv") .with_new_file("index.html", "Hello, world!") - .with_exec(["python", "-m", "http.server", "8080"]) .with_exposed_port(8080) - .as_service() + .as_service(args=["python", "-m", "http.server", "8080"]) ) @function diff --git a/docs/current_docs/api/snippets/services/bind-services/typescript/index.ts b/docs/current_docs/api/snippets/services/bind-services/typescript/index.ts index 598ab62c3f..e9d1691ef0 100644 --- a/docs/current_docs/api/snippets/services/bind-services/typescript/index.ts +++ b/docs/current_docs/api/snippets/services/bind-services/typescript/index.ts @@ -12,9 +12,8 @@ class MyModule { .from("python") .withWorkdir("/srv") .withNewFile("index.html", "Hello, world!") - .withExec(["python", "-m", "http.server", "8080"]) .withExposedPort(8080) - .asService() + .asService({ args: ["python", "-m", "http.server", "8080"] }) } /** diff --git a/docs/current_docs/api/snippets/services/create-interdependent-services/go/main.go b/docs/current_docs/api/snippets/services/create-interdependent-services/go/main.go index 8baa6bee4f..1fd4b87318 100644 --- a/docs/current_docs/api/snippets/services/create-interdependent-services/go/main.go +++ b/docs/current_docs/api/snippets/services/create-interdependent-services/go/main.go @@ -2,7 +2,7 @@ package main import ( "context" - "main/internal/dagger" + "dagger/my-module/internal/dagger" ) type MyModule struct{} @@ -12,10 +12,8 @@ func (m *MyModule) Services(ctx context.Context) (*dagger.Service, error) { svcA := dag.Container().From("nginx"). WithExposedPort(80). - WithExec([]string{"sh", "-c", ` - nginx & while true; do curl svcb:80 && sleep 1; done - `}). - AsService().WithHostname("svca") + AsService(dagger.ContainerAsServiceOpts{Args: []string{"sh", "-c", `nginx & while true; do curl svcb:80 && sleep 1; done`}}). + WithHostname("svca") _, err := svcA.Start(ctx) if err != nil { @@ -24,10 +22,8 @@ func (m *MyModule) Services(ctx context.Context) (*dagger.Service, error) { svcB := dag.Container().From("nginx"). WithExposedPort(80). - WithExec([]string{"sh", "-c", ` -nginx & while true; do curl svca:80 && sleep 1; done - `}). - AsService().WithHostname("svcb") + AsService(dagger.ContainerAsServiceOpts{Args: []string{"sh", "-c", `nginx & while true; do curl svca:80 && sleep 1; done`}}). + WithHostname("svcb") svcB, err = svcB.Start(ctx) if err != nil { diff --git a/docs/current_docs/api/snippets/services/create-interdependent-services/python/main.py b/docs/current_docs/api/snippets/services/create-interdependent-services/python/main.py index bc110f5a4a..e07d8963e9 100644 --- a/docs/current_docs/api/snippets/services/create-interdependent-services/python/main.py +++ b/docs/current_docs/api/snippets/services/create-interdependent-services/python/main.py @@ -11,10 +11,13 @@ async def services(self) -> dagger.Service: dag.container() .from_("nginx") .with_exposed_port(80) - .with_exec( - ["sh", "-c", "nginx & while true; do curl svcb:80 && sleep 1; done"] + .as_service( + args=[ + "sh", + "-c", + "nginx & while true; do curl svcb:80 && sleep 1; done", + ] ) - .as_service() .with_hostname("svca") ) @@ -24,10 +27,13 @@ async def services(self) -> dagger.Service: dag.container() .from_("nginx") .with_exposed_port(80) - .with_exec( - ["sh", "-c", "nginx & while true; do curl svca:80 && sleep 1; done"] + .as_service( + args=[ + "sh", + "-c", + "nginx & while true; do curl svca:80 && sleep 1; done", + ] ) - .as_service() .with_hostname("svcb") ) diff --git a/docs/current_docs/api/snippets/services/create-interdependent-services/typescript/index.ts b/docs/current_docs/api/snippets/services/create-interdependent-services/typescript/index.ts index 1a94d1b719..6e75a69377 100644 --- a/docs/current_docs/api/snippets/services/create-interdependent-services/typescript/index.ts +++ b/docs/current_docs/api/snippets/services/create-interdependent-services/typescript/index.ts @@ -1,4 +1,4 @@ -import { object, func, Service } from "@dagger.io/dagger" +import { dag, object, func, Service } from "@dagger.io/dagger" @object() class MyModule { @@ -9,12 +9,13 @@ class MyModule { .container() .from("nginx") .withExposedPort(80) - .withExec([ - "sh", - "-c", - `nginx & while true; do curl svcb:80 && sleep 1; done`, - ]) - .asService() + .asService({ + args: [ + "sh", + "-c", + `nginx & while true; do curl svcb:80 && sleep 1; done`, + ], + }) .withHostname("svca") await svcA.start() @@ -23,12 +24,13 @@ class MyModule { .container() .from("nginx") .withExposedPort(80) - .withExec([ - "sh", - "-c", - `nginx & while true; do curl svca:80 && sleep 1; done`, - ]) - .asService() + .asService({ + args: [ + "sh", + "-c", + `nginx & while true; do curl svca:80 && sleep 1; done`, + ], + }) .withHostname("svcb") await svcB.start() diff --git a/docs/current_docs/api/snippets/services/expose-dagger-services-to-host/go/main.go b/docs/current_docs/api/snippets/services/expose-dagger-services-to-host/go/main.go index d0c554098f..a36e57c06e 100644 --- a/docs/current_docs/api/snippets/services/expose-dagger-services-to-host/go/main.go +++ b/docs/current_docs/api/snippets/services/expose-dagger-services-to-host/go/main.go @@ -1,6 +1,8 @@ package main -import "main/internal/dagger" +import ( + "dagger/my-module/internal/dagger" +) type MyModule struct{} @@ -10,7 +12,6 @@ func (m *MyModule) HttpService() *dagger.Service { From("python"). WithWorkdir("/srv"). WithNewFile("index.html", "Hello, world!"). - WithDefaultArgs([]string{"python", "-m", "http.server", "8080"}). WithExposedPort(8080). - AsService() + AsService(dagger.ContainerAsServiceOpts{Args: []string{"python", "-m", "http.server", "8080"}}) } diff --git a/docs/current_docs/api/snippets/services/expose-dagger-services-to-host/python/main.py b/docs/current_docs/api/snippets/services/expose-dagger-services-to-host/python/main.py index d645d8b435..5ad547d89d 100644 --- a/docs/current_docs/api/snippets/services/expose-dagger-services-to-host/python/main.py +++ b/docs/current_docs/api/snippets/services/expose-dagger-services-to-host/python/main.py @@ -12,7 +12,6 @@ def http_service(self) -> dagger.Service: .from_("python") .with_workdir("/srv") .with_new_file("index.html", "Hello, world!") - .with_exec(["python", "-m", "http.server", "8080"]) .with_exposed_port(8080) - .as_service() + .as_service(args=["python", "-m", "http.server", "8080"]) ) diff --git a/docs/current_docs/api/snippets/services/expose-dagger-services-to-host/typescript/index.ts b/docs/current_docs/api/snippets/services/expose-dagger-services-to-host/typescript/index.ts index b4d9b20ffb..4046b8f02b 100644 --- a/docs/current_docs/api/snippets/services/expose-dagger-services-to-host/typescript/index.ts +++ b/docs/current_docs/api/snippets/services/expose-dagger-services-to-host/typescript/index.ts @@ -12,8 +12,7 @@ class MyModule { .from("python") .withWorkdir("/srv") .withNewFile("index.html", "Hello, world!") - .withExec(["python", "-m", "http.server", "8080"]) .withExposedPort(8080) - .asService() + .asService({ args: ["python", "-m", "http.server", "8080"] }) } } diff --git a/docs/current_docs/api/snippets/services/expose-host-services-to-dagger/go/main.go b/docs/current_docs/api/snippets/services/expose-host-services-to-dagger/go/main.go index 43f3cfbdda..a5fded5a10 100644 --- a/docs/current_docs/api/snippets/services/expose-host-services-to-dagger/go/main.go +++ b/docs/current_docs/api/snippets/services/expose-host-services-to-dagger/go/main.go @@ -2,7 +2,7 @@ package main import ( "context" - "main/internal/dagger" + "dagger/my-module/internal/dagger" ) type MyModule struct{} diff --git a/docs/current_docs/api/snippets/services/persist-service-state/go/main.go b/docs/current_docs/api/snippets/services/persist-service-state/go/main.go index b3db98821a..63b6f6982a 100644 --- a/docs/current_docs/api/snippets/services/persist-service-state/go/main.go +++ b/docs/current_docs/api/snippets/services/persist-service-state/go/main.go @@ -3,7 +3,7 @@ package main import ( "context" - "main/internal/dagger" + "dagger/my-module/internal/dagger" ) type MyModule struct{} @@ -15,7 +15,7 @@ func (m *MyModule) Redis(ctx context.Context) *dagger.Container { WithExposedPort(6379). WithMountedCache("/data", dag.CacheVolume("my-redis")). WithWorkdir("/data"). - AsService() + AsService(dagger.ContainerAsServiceOpts{UseEntrypoint: true}) redisCLI := dag.Container(). From("redis"). diff --git a/docs/current_docs/api/snippets/services/persist-service-state/python/main.py b/docs/current_docs/api/snippets/services/persist-service-state/python/main.py index 08279ca88a..b392d0e23c 100644 --- a/docs/current_docs/api/snippets/services/persist-service-state/python/main.py +++ b/docs/current_docs/api/snippets/services/persist-service-state/python/main.py @@ -15,7 +15,7 @@ def redis(self) -> dagger.Container: .with_exposed_port(6379) .with_mounted_cache("/data", dag.cache_volume("my-redis")) .with_workdir("/data") - .as_service() + .as_service(use_entrypoint=True) ) # create Redis client container diff --git a/docs/current_docs/api/snippets/services/persist-service-state/typescript/index.ts b/docs/current_docs/api/snippets/services/persist-service-state/typescript/index.ts index 785e5bcd8f..a3804d3786 100644 --- a/docs/current_docs/api/snippets/services/persist-service-state/typescript/index.ts +++ b/docs/current_docs/api/snippets/services/persist-service-state/typescript/index.ts @@ -13,7 +13,7 @@ class MyModule { .withExposedPort(6379) .withMountedCache("/data", dag.cacheVolume("my-redis")) .withWorkdir("/data") - .asService() + .asService({ useEntrypoint: true }) const redisCLI = dag .container() diff --git a/docs/current_docs/api/snippets/services/service-lifecycle-1/go/main.go b/docs/current_docs/api/snippets/services/service-lifecycle-1/go/main.go index ecca184ba3..43eb86fdda 100644 --- a/docs/current_docs/api/snippets/services/service-lifecycle-1/go/main.go +++ b/docs/current_docs/api/snippets/services/service-lifecycle-1/go/main.go @@ -2,6 +2,8 @@ package main import ( "context" + + "dagger/my-module/internal/dagger" ) type MyModule struct{} @@ -11,7 +13,7 @@ func (m *MyModule) RedisService(ctx context.Context) (string, error) { redisSrv := dag.Container(). From("redis"). WithExposedPort(6379). - AsService() + AsService(dagger.ContainerAsServiceOpts{UseEntrypoint: true}) // create Redis client container redisCLI := dag.Container(). diff --git a/docs/current_docs/api/snippets/services/service-lifecycle-1/python/main.py b/docs/current_docs/api/snippets/services/service-lifecycle-1/python/main.py index 575760fac1..b653c38063 100644 --- a/docs/current_docs/api/snippets/services/service-lifecycle-1/python/main.py +++ b/docs/current_docs/api/snippets/services/service-lifecycle-1/python/main.py @@ -6,7 +6,12 @@ class MyModule: @function async def redis_service(self) -> str: """Creates Redis service and client.""" - redis_srv = dag.container().from_("redis").with_exposed_port(6379).as_service() + redis_srv = ( + dag.container() + .from_("redis") + .with_exposed_port(6379) + .as_service(use_entrypoint=True) + ) # create Redis client container redis_cli = ( diff --git a/docs/current_docs/api/snippets/services/service-lifecycle-1/typescript/index.ts b/docs/current_docs/api/snippets/services/service-lifecycle-1/typescript/index.ts index 840ff11992..e56986c3ce 100644 --- a/docs/current_docs/api/snippets/services/service-lifecycle-1/typescript/index.ts +++ b/docs/current_docs/api/snippets/services/service-lifecycle-1/typescript/index.ts @@ -11,7 +11,7 @@ class MyModule { .container() .from("redis") .withExposedPort(6379) - .asService() + .asService({ useEntrypoint: true }) // create Redis client container const redisCLI = dag diff --git a/docs/current_docs/api/snippets/services/service-lifecycle-2/go/main.go b/docs/current_docs/api/snippets/services/service-lifecycle-2/go/main.go index 12b9fb8c4c..ed25c0ef79 100644 --- a/docs/current_docs/api/snippets/services/service-lifecycle-2/go/main.go +++ b/docs/current_docs/api/snippets/services/service-lifecycle-2/go/main.go @@ -2,6 +2,8 @@ package main import ( "context" + + "dagger/my-module/internal/dagger" ) type MyModule struct{} @@ -11,7 +13,7 @@ func (m *MyModule) RedisService(ctx context.Context) (string, error) { redisSrv := dag.Container(). From("redis"). WithExposedPort(6379). - AsService() + AsService(dagger.ContainerAsServiceOpts{UseEntrypoint: true}) // create Redis client container redisCLI := dag.Container(). diff --git a/docs/current_docs/api/snippets/services/service-lifecycle-2/python/main.py b/docs/current_docs/api/snippets/services/service-lifecycle-2/python/main.py index 353e209ba9..8f9ac0fd58 100644 --- a/docs/current_docs/api/snippets/services/service-lifecycle-2/python/main.py +++ b/docs/current_docs/api/snippets/services/service-lifecycle-2/python/main.py @@ -6,7 +6,12 @@ class MyModule: @function async def redis_service(self) -> str: """Creates Redis service and client.""" - redis_srv = dag.container().from_("redis").with_exposed_port(6379).as_service() + redis_srv = ( + dag.container() + .from_("redis") + .with_exposed_port(6379) + .as_service(use_entrypoint=True) + ) # create Redis client container redis_cli = ( diff --git a/docs/current_docs/api/snippets/services/service-lifecycle-2/typescript/index.ts b/docs/current_docs/api/snippets/services/service-lifecycle-2/typescript/index.ts index 91a8b0a5b2..47b54a2eeb 100644 --- a/docs/current_docs/api/snippets/services/service-lifecycle-2/typescript/index.ts +++ b/docs/current_docs/api/snippets/services/service-lifecycle-2/typescript/index.ts @@ -11,7 +11,7 @@ class MyModule { .container() .from("redis") .withExposedPort(6379) - .asService() + .asService({ useEntrypoint: true }) // create Redis client container const redisCLI = dag diff --git a/docs/current_docs/api/snippets/services/service-lifecycle-3/go/main.go b/docs/current_docs/api/snippets/services/service-lifecycle-3/go/main.go index 16266c5e6c..30382dbdc6 100644 --- a/docs/current_docs/api/snippets/services/service-lifecycle-3/go/main.go +++ b/docs/current_docs/api/snippets/services/service-lifecycle-3/go/main.go @@ -2,6 +2,8 @@ package main import ( "context" + + "dagger/my-module/internal/dagger" ) type MyModule struct{} @@ -11,7 +13,7 @@ func (m *MyModule) RedisService(ctx context.Context) (string, error) { redisSrv := dag.Container(). From("redis"). WithExposedPort(6379). - AsService() + AsService(dagger.ContainerAsServiceOpts{UseEntrypoint: true}) // create Redis client container redisCLI := dag.Container(). diff --git a/docs/current_docs/api/snippets/services/service-lifecycle-3/python/main.py b/docs/current_docs/api/snippets/services/service-lifecycle-3/python/main.py index 7bee468bc5..caf0e14a61 100644 --- a/docs/current_docs/api/snippets/services/service-lifecycle-3/python/main.py +++ b/docs/current_docs/api/snippets/services/service-lifecycle-3/python/main.py @@ -6,7 +6,12 @@ class MyModule: @function async def redis_service(self) -> str: """Creates Redis service and client.""" - redis_srv = dag.container().from_("redis").with_exposed_port(6379).as_service() + redis_srv = ( + dag.container() + .from_("redis") + .with_exposed_port(6379) + .as_service(use_entrypoint=True) + ) # create Redis client container redis_cli = ( diff --git a/docs/current_docs/api/snippets/services/service-lifecycle-3/typescript/index.ts b/docs/current_docs/api/snippets/services/service-lifecycle-3/typescript/index.ts index 2c05e866b9..dd852b0797 100644 --- a/docs/current_docs/api/snippets/services/service-lifecycle-3/typescript/index.ts +++ b/docs/current_docs/api/snippets/services/service-lifecycle-3/typescript/index.ts @@ -11,7 +11,7 @@ class MyModule { .container() .from("redis") .withExposedPort(6379) - .asService() + .asService({ useEntrypoint: true }) // create Redis client container const redisCLI = dag diff --git a/docs/current_docs/api/snippets/services/start-stop-services/go/main.go b/docs/current_docs/api/snippets/services/start-stop-services/go/main.go index c123e3921e..b38c634e1c 100644 --- a/docs/current_docs/api/snippets/services/start-stop-services/go/main.go +++ b/docs/current_docs/api/snippets/services/start-stop-services/go/main.go @@ -2,6 +2,8 @@ package main import ( "context" + + "dagger/my-module/internal/dagger" ) type MyModule struct{} @@ -11,7 +13,7 @@ func (m *MyModule) RedisService(ctx context.Context) (string, error) { redisSrv := dag.Container(). From("redis"). WithExposedPort(6379). - AsService() + AsService(dagger.ContainerAsServiceOpts{UseEntrypoint: true}) // start Redis ahead of time so it stays up for the duration of the test redisSrv, err := redisSrv.Start(ctx) diff --git a/docs/current_docs/api/snippets/services/test-against-db-service/go/main.go b/docs/current_docs/api/snippets/services/test-against-db-service/go/main.go index b9038da4ef..49a6fb6a13 100644 --- a/docs/current_docs/api/snippets/services/test-against-db-service/go/main.go +++ b/docs/current_docs/api/snippets/services/test-against-db-service/go/main.go @@ -2,6 +2,8 @@ package main import ( "context" + + "dagger/my-module/internal/dagger" ) type MyModule struct{} @@ -15,7 +17,7 @@ func (m *MyModule) Test(ctx context.Context) (string, error) { WithEnvVariable("MARIADB_DATABASE", "drupal"). WithEnvVariable("MARIADB_ROOT_PASSWORD", "root"). WithExposedPort(3306). - AsService() + AsService(dagger.ContainerAsServiceOpts{UseEntrypoint: true}) // get Drupal base image // install additional dependencies diff --git a/docs/current_docs/api/snippets/services/test-against-db-service/python/main.py b/docs/current_docs/api/snippets/services/test-against-db-service/python/main.py index 71befb44ca..705f18e8f3 100644 --- a/docs/current_docs/api/snippets/services/test-against-db-service/python/main.py +++ b/docs/current_docs/api/snippets/services/test-against-db-service/python/main.py @@ -15,7 +15,7 @@ async def test(self) -> str: .with_env_variable("MARIADB_DATABASE", "drupal") .with_env_variable("MARIADB_ROOT_PASSWORD", "root") .with_exposed_port(3306) - .as_service() + .as_service(use_entrypoint=True) ) # get Drupal base image diff --git a/docs/current_docs/api/snippets/services/test-against-db-service/typescript/index.ts b/docs/current_docs/api/snippets/services/test-against-db-service/typescript/index.ts index e2211fd53d..4e3e6af276 100644 --- a/docs/current_docs/api/snippets/services/test-against-db-service/typescript/index.ts +++ b/docs/current_docs/api/snippets/services/test-against-db-service/typescript/index.ts @@ -15,7 +15,7 @@ class MyModule { .withEnvVariable("MARIADB_DATABASE", "drupal") .withEnvVariable("MARIADB_ROOT_PASSWORD", "root") .withExposedPort(3306) - .asService() + .asService({ useEntrypoint: true }) // get Drupal base image // install additional dependencies diff --git a/docs/current_docs/cookbook/snippets/set-env-var/go/main.go b/docs/current_docs/cookbook/snippets/set-env-var/go/main.go index 9e1ab357ab..ec04d44c75 100644 --- a/docs/current_docs/cookbook/snippets/set-env-var/go/main.go +++ b/docs/current_docs/cookbook/snippets/set-env-var/go/main.go @@ -1,10 +1,6 @@ package main -import ( - "context" - - "dagger.io/dagger/dag" -) +import "context" type MyModule struct{} diff --git a/docs/current_docs/cookbook/snippets/set-env-vars/go/main.go b/docs/current_docs/cookbook/snippets/set-env-vars/go/main.go index 4c44df552c..c237c0ac5a 100644 --- a/docs/current_docs/cookbook/snippets/set-env-vars/go/main.go +++ b/docs/current_docs/cookbook/snippets/set-env-vars/go/main.go @@ -4,8 +4,6 @@ import ( "context" "dagger/my-module/internal/dagger" - - "dagger.io/dagger/dag" ) type MyModule struct{} diff --git a/docs/current_docs/features/snippets/debugging-1/go/main.go b/docs/current_docs/features/snippets/debugging-1/go/main.go index 29304a6954..3e44b56a14 100644 --- a/docs/current_docs/features/snippets/debugging-1/go/main.go +++ b/docs/current_docs/features/snippets/debugging-1/go/main.go @@ -1,10 +1,6 @@ package main -import ( - "context" - - "dagger.io/dagger/dag" -) +import "context" type MyModule struct{} diff --git a/docs/current_docs/features/snippets/programmable-pipelines-1/go/main.go b/docs/current_docs/features/snippets/programmable-pipelines-1/go/main.go index a44b671d77..d96c06d351 100644 --- a/docs/current_docs/features/snippets/programmable-pipelines-1/go/main.go +++ b/docs/current_docs/features/snippets/programmable-pipelines-1/go/main.go @@ -3,8 +3,6 @@ package main import ( "context" "dagger/my-module/internal/dagger" - - "dagger.io/dagger/dag" ) type MyModule struct{} diff --git a/docs/current_docs/features/snippets/programmable-pipelines-2/go/main.go b/docs/current_docs/features/snippets/programmable-pipelines-2/go/main.go index 2e1ca076b3..2853e817d7 100644 --- a/docs/current_docs/features/snippets/programmable-pipelines-2/go/main.go +++ b/docs/current_docs/features/snippets/programmable-pipelines-2/go/main.go @@ -3,8 +3,6 @@ package main import ( "context" "dagger/my-module/internal/dagger" - - "dagger.io/dagger/dag" ) type MyModule struct{} diff --git a/docs/current_docs/features/snippets/services-1/go/main.go b/docs/current_docs/features/snippets/services-1/go/main.go index cc2b63d01a..63468b44a2 100644 --- a/docs/current_docs/features/snippets/services-1/go/main.go +++ b/docs/current_docs/features/snippets/services-1/go/main.go @@ -2,8 +2,6 @@ package main import ( "dagger/my-module/internal/dagger" - - "dagger.io/dagger/dag" ) type MyModule struct{} @@ -13,7 +11,6 @@ func (m *MyModule) HttpService() *dagger.Service { From("python"). WithWorkdir("/srv"). WithNewFile("index.html", "Hello, world!"). - WithDefaultArgs([]string{"python", "-m", "http.server", "8080"}). WithExposedPort(8080). - AsService() + AsService(dagger.ContainerAsServiceOpts{Args: []string{"python", "-m", "http.server", "8080"}}) } diff --git a/docs/current_docs/features/snippets/services-1/python/main.py b/docs/current_docs/features/snippets/services-1/python/main.py index a43d6732a2..75821d3a1c 100644 --- a/docs/current_docs/features/snippets/services-1/python/main.py +++ b/docs/current_docs/features/snippets/services-1/python/main.py @@ -11,7 +11,6 @@ def http_service(self) -> dagger.Service: .from_("python") .with_workdir("/srv") .with_new_file("index.html", "Hello, world!") - .with_exec(["python", "-m", "http.server", "8080"]) .with_exposed_port(8080) - .as_service() + .as_service(args=["python", "-m", "http.server", "8080"]) ) diff --git a/docs/current_docs/features/snippets/services-1/typescript/index.ts b/docs/current_docs/features/snippets/services-1/typescript/index.ts index ba04f8a688..ea9a09aee3 100644 --- a/docs/current_docs/features/snippets/services-1/typescript/index.ts +++ b/docs/current_docs/features/snippets/services-1/typescript/index.ts @@ -9,8 +9,7 @@ class MyModule { .from("python") .withWorkdir("/srv") .withNewFile("index.html", "Hello, world!") - .withExec(["python", "-m", "http.server", "8080"]) .withExposedPort(8080) - .asService() + .asService({ args: ["python", "-m", "http.server", "8080"] }) } } diff --git a/docs/current_docs/features/snippets/services-2/go/main.go b/docs/current_docs/features/snippets/services-2/go/main.go index 49d1133e7b..045549a4a1 100644 --- a/docs/current_docs/features/snippets/services-2/go/main.go +++ b/docs/current_docs/features/snippets/services-2/go/main.go @@ -3,8 +3,6 @@ package main import ( "context" "dagger/my-module/internal/dagger" - - "dagger.io/dagger/dag" ) type MyModule struct{}