diff --git a/ci/sdk.go b/ci/sdk.go index e9b0d892ed..39eb6ab1dd 100644 --- a/ci/sdk.go +++ b/ci/sdk.go @@ -20,10 +20,36 @@ type SDK struct { Elixir *ElixirSDK // Develop the Dagger Rust SDK (experimental) Rust *RustSDK - // Develop the Dagger Java SDK (experimental) - Java *JavaSDK // Develop the Dagger PHP SDK (experimental) PHP *PHPSDK + // Develop the Dagger Java SDK (experimental) + Java *JavaSDK +} + +func (sdk *SDK) All() *AllSDK { + return &AllSDK{ + SDK: sdk, + } +} + +type sdkBase interface { + Lint(ctx context.Context) error + Test(ctx context.Context) error + Generate(ctx context.Context) (*Directory, error) + Bump(ctx context.Context, version string) (*Directory, error) +} + +func (sdk *SDK) allSDKs() []sdkBase { + return []sdkBase{ + sdk.Go, + sdk.Python, + sdk.Typescript, + sdk.Elixir, + sdk.Rust, + sdk.PHP, + // java isn't properly integrated to our release process yet + // sdk.Java, + } } func (ci *Dagger) installer(ctx context.Context, name string) (func(*Container) *Container, error) { diff --git a/ci/sdk_all.go b/ci/sdk_all.go new file mode 100644 index 0000000000..ac738f1c97 --- /dev/null +++ b/ci/sdk_all.go @@ -0,0 +1,95 @@ +package main + +import ( + "context" + + "golang.org/x/sync/errgroup" +) + +type AllSDK struct { + SDK *SDK // +private +} + +var _ sdkBase = AllSDK{} + +func (t AllSDK) Lint(ctx context.Context) error { + eg, ctx := errgroup.WithContext(ctx) + for _, sdk := range t.SDK.allSDKs() { + sdk := sdk + eg.Go(func() error { + return sdk.Lint(ctx) + }) + } + return eg.Wait() +} + +func (t AllSDK) Test(ctx context.Context) error { + eg, ctx := errgroup.WithContext(ctx) + for _, sdk := range t.SDK.allSDKs() { + sdk := sdk + eg.Go(func() error { + return sdk.Test(ctx) + }) + } + return eg.Wait() +} + +func (t AllSDK) Generate(ctx context.Context) (*Directory, error) { + eg, ctx := errgroup.WithContext(ctx) + dirs := make([]*Directory, len(t.SDK.allSDKs())) + for i, sdk := range t.SDK.allSDKs() { + i, sdk := i, sdk + eg.Go(func() error { + dir, err := sdk.Generate(ctx) + if err != nil { + return err + } + dir, err = dir.Sync(ctx) + if err != nil { + return err + } + dirs[i] = dir + return nil + }) + } + err := eg.Wait() + if err != nil { + return nil, err + } + + dir := dag.Directory() + for _, dir2 := range dirs { + dir = dir.WithDirectory("", dir2) + } + return dir, nil +} + +func (t AllSDK) Bump(ctx context.Context, version string) (*Directory, error) { + eg, ctx := errgroup.WithContext(ctx) + dirs := make([]*Directory, len(t.SDK.allSDKs())) + for i, sdk := range t.SDK.allSDKs() { + i, sdk := i, sdk + eg.Go(func() error { + dir, err := sdk.Bump(ctx, version) + if err != nil { + return err + } + dir, err = dir.Sync(ctx) + if err != nil { + return err + } + dirs[i] = dir + return nil + }) + } + err := eg.Wait() + if err != nil { + return nil, err + } + + dir := dag.Directory() + for _, dir2 := range dirs { + dir = dir.WithDirectory("", dir2) + } + return dir, nil +} diff --git a/ci/sdk_go.go b/ci/sdk_go.go index de230feae7..94ca12f5b5 100644 --- a/ci/sdk_go.go +++ b/ci/sdk_go.go @@ -100,7 +100,7 @@ func (t GoSDK) Publish( } // Bump the Go SDK's Engine dependency -func (t GoSDK) Bump(version string) (*Directory, error) { +func (t GoSDK) Bump(ctx context.Context, version string) (*Directory, error) { // trim leading v from version version = strings.TrimPrefix(version, "v") diff --git a/ci/sdk_php.go b/ci/sdk_php.go index 139016c257..3cef2feb7a 100644 --- a/ci/sdk_php.go +++ b/ci/sdk_php.go @@ -83,7 +83,7 @@ func (t PHPSDK) Publish( } // Bump the PHP SDK's Engine dependency -func (t PHPSDK) Bump(version string) (*Directory, error) { +func (t PHPSDK) Bump(ctx context.Context, version string) (*Directory, error) { version = strings.TrimPrefix(version, "v") content := fmt.Sprintf(` select("withoutDirectory") |> put_arg("path", path) + directory.selection + |> select("withoutDirectory") + |> put_arg("path", path) + |> maybe_put_arg("allowWildCard", optional_args[:allow_wild_card]) + |> maybe_put_arg("allowNotFound", optional_args[:allow_not_found]) %Dagger.Directory{ selection: selection, @@ -269,10 +276,17 @@ defmodule Dagger.Directory do end @doc "Retrieves this directory with the file at the given path removed." - @spec without_file(t(), String.t()) :: Dagger.Directory.t() - def without_file(%__MODULE__{} = directory, path) do + @spec without_file(t(), String.t(), [ + {:allow_wild_card, boolean() | nil}, + {:allow_not_found, boolean() | nil} + ]) :: Dagger.Directory.t() + def without_file(%__MODULE__{} = directory, path, optional_args \\ []) do selection = - directory.selection |> select("withoutFile") |> put_arg("path", path) + directory.selection + |> select("withoutFile") + |> put_arg("path", path) + |> maybe_put_arg("allowWildCard", optional_args[:allow_wild_card]) + |> maybe_put_arg("allowNotFound", optional_args[:allow_not_found]) %Dagger.Directory{ selection: selection, diff --git a/sdk/elixir/lib/dagger/gen/service.ex b/sdk/elixir/lib/dagger/gen/service.ex index b51a700c97..ebc5afced4 100644 --- a/sdk/elixir/lib/dagger/gen/service.ex +++ b/sdk/elixir/lib/dagger/gen/service.ex @@ -67,6 +67,15 @@ defmodule Dagger.Service do end end + @doc "Signal the service." + @spec signal(t(), Dagger.SignalTypes.t()) :: {:ok, Dagger.ServiceID.t()} | {:error, term()} + def signal(%__MODULE__{} = service, signal) do + selection = + service.selection |> select("signal") |> put_arg("signal", signal) + + execute(selection, service.client) + end + @doc """ Start the service and wait for its health checks to succeed. @@ -81,10 +90,14 @@ defmodule Dagger.Service do end @doc "Stop the service." - @spec stop(t(), [{:kill, boolean() | nil}]) :: {:ok, Dagger.ServiceID.t()} | {:error, term()} + @spec stop(t(), [{:kill, boolean() | nil}, {:signal, Dagger.SignalTypes.t() | nil}]) :: + {:ok, Dagger.ServiceID.t()} | {:error, term()} def stop(%__MODULE__{} = service, optional_args \\ []) do selection = - service.selection |> select("stop") |> maybe_put_arg("kill", optional_args[:kill]) + service.selection + |> select("stop") + |> maybe_put_arg("kill", optional_args[:kill]) + |> maybe_put_arg("signal", optional_args[:signal]) execute(selection, service.client) end diff --git a/sdk/elixir/lib/dagger/gen/signal_types.ex b/sdk/elixir/lib/dagger/gen/signal_types.ex new file mode 100644 index 0000000000..0504cbf7e3 --- /dev/null +++ b/sdk/elixir/lib/dagger/gen/signal_types.ex @@ -0,0 +1,146 @@ +# This file generated by `dagger_codegen`. Please DO NOT EDIT. +defmodule Dagger.SignalTypes do + @moduledoc "Signaltypes to be sent to processes." + + @type t() :: + :SIGABRT + | :SIGALRM + | :SIGBUS + | :SIGCHLD + | :SIGCLD + | :SIGCONT + | :SIGFPE + | :SIGHUP + | :SIGILL + | :SIGINT + | :SIGIO + | :SIGIOT + | :SIGKILL + | :SIGPIPE + | :SIGPOLL + | :SIGPROF + | :SIGPWR + | :SIGQUIT + | :SIGSEGV + | :SIGSTKFLT + | :SIGSTOP + | :SIGSYS + | :SIGTERM + | :SIGTRAP + | :SIGTSTP + | :SIGTTIN + | :SIGTTOU + | :SIGUNUSED + | :SIGURG + | :SIGUSR1 + | :SIGUSR2 + | :SIGVTALRM + | :SIGWINCH + | :SIGXCPU + | :SIGXFSZ + + @spec sigabrt() :: :SIGABRT + def sigabrt(), do: :SIGABRT + + @spec sigalrm() :: :SIGALRM + def sigalrm(), do: :SIGALRM + + @spec sigbus() :: :SIGBUS + def sigbus(), do: :SIGBUS + + @spec sigchld() :: :SIGCHLD + def sigchld(), do: :SIGCHLD + + @spec sigcld() :: :SIGCLD + def sigcld(), do: :SIGCLD + + @spec sigcont() :: :SIGCONT + def sigcont(), do: :SIGCONT + + @spec sigfpe() :: :SIGFPE + def sigfpe(), do: :SIGFPE + + @spec sighup() :: :SIGHUP + def sighup(), do: :SIGHUP + + @spec sigill() :: :SIGILL + def sigill(), do: :SIGILL + + @spec sigint() :: :SIGINT + def sigint(), do: :SIGINT + + @spec sigio() :: :SIGIO + def sigio(), do: :SIGIO + + @spec sigiot() :: :SIGIOT + def sigiot(), do: :SIGIOT + + @spec sigkill() :: :SIGKILL + def sigkill(), do: :SIGKILL + + @spec sigpipe() :: :SIGPIPE + def sigpipe(), do: :SIGPIPE + + @spec sigpoll() :: :SIGPOLL + def sigpoll(), do: :SIGPOLL + + @spec sigprof() :: :SIGPROF + def sigprof(), do: :SIGPROF + + @spec sigpwr() :: :SIGPWR + def sigpwr(), do: :SIGPWR + + @spec sigquit() :: :SIGQUIT + def sigquit(), do: :SIGQUIT + + @spec sigsegv() :: :SIGSEGV + def sigsegv(), do: :SIGSEGV + + @spec sigstkflt() :: :SIGSTKFLT + def sigstkflt(), do: :SIGSTKFLT + + @spec sigstop() :: :SIGSTOP + def sigstop(), do: :SIGSTOP + + @spec sigsys() :: :SIGSYS + def sigsys(), do: :SIGSYS + + @spec sigterm() :: :SIGTERM + def sigterm(), do: :SIGTERM + + @spec sigtrap() :: :SIGTRAP + def sigtrap(), do: :SIGTRAP + + @spec sigtstp() :: :SIGTSTP + def sigtstp(), do: :SIGTSTP + + @spec sigttin() :: :SIGTTIN + def sigttin(), do: :SIGTTIN + + @spec sigttou() :: :SIGTTOU + def sigttou(), do: :SIGTTOU + + @spec sigunused() :: :SIGUNUSED + def sigunused(), do: :SIGUNUSED + + @spec sigurg() :: :SIGURG + def sigurg(), do: :SIGURG + + @spec sigusr1() :: :SIGUSR1 + def sigusr1(), do: :SIGUSR1 + + @spec sigusr2() :: :SIGUSR2 + def sigusr2(), do: :SIGUSR2 + + @spec sigvtalrm() :: :SIGVTALRM + def sigvtalrm(), do: :SIGVTALRM + + @spec sigwinch() :: :SIGWINCH + def sigwinch(), do: :SIGWINCH + + @spec sigxcpu() :: :SIGXCPU + def sigxcpu(), do: :SIGXCPU + + @spec sigxfsz() :: :SIGXFSZ + def sigxfsz(), do: :SIGXFSZ +end diff --git a/sdk/go/dagger.gen.go b/sdk/go/dagger.gen.go index 0e51e52f0f..5cccf0108c 100644 --- a/sdk/go/dagger.gen.go +++ b/sdk/go/dagger.gen.go @@ -2234,9 +2234,27 @@ func (r *Directory) WithTimestamps(timestamp int) *Directory { } } +// DirectoryWithoutDirectoryOpts contains options for Directory.WithoutDirectory +type DirectoryWithoutDirectoryOpts struct { + // Allow wildcards in the path (e.g., "*.txt"). + AllowWildCard bool + // Allow the operation to not fail if the directory does not exist. + AllowNotFound bool +} + // Retrieves this directory with the directory at the given path removed. -func (r *Directory) WithoutDirectory(path string) *Directory { +func (r *Directory) WithoutDirectory(path string, opts ...DirectoryWithoutDirectoryOpts) *Directory { q := r.query.Select("withoutDirectory") + for i := len(opts) - 1; i >= 0; i-- { + // `allowWildCard` optional argument + if !querybuilder.IsZeroValue(opts[i].AllowWildCard) { + q = q.Arg("allowWildCard", opts[i].AllowWildCard) + } + // `allowNotFound` optional argument + if !querybuilder.IsZeroValue(opts[i].AllowNotFound) { + q = q.Arg("allowNotFound", opts[i].AllowNotFound) + } + } q = q.Arg("path", path) return &Directory{ @@ -2244,9 +2262,27 @@ func (r *Directory) WithoutDirectory(path string) *Directory { } } +// DirectoryWithoutFileOpts contains options for Directory.WithoutFile +type DirectoryWithoutFileOpts struct { + // Allow wildcards in the path (e.g., "*.txt"). + AllowWildCard bool + // Allow the operation to not fail if the directory does not exist. + AllowNotFound bool +} + // Retrieves this directory with the file at the given path removed. -func (r *Directory) WithoutFile(path string) *Directory { +func (r *Directory) WithoutFile(path string, opts ...DirectoryWithoutFileOpts) *Directory { q := r.query.Select("withoutFile") + for i := len(opts) - 1; i >= 0; i-- { + // `allowWildCard` optional argument + if !querybuilder.IsZeroValue(opts[i].AllowWildCard) { + q = q.Arg("allowWildCard", opts[i].AllowWildCard) + } + // `allowNotFound` optional argument + if !querybuilder.IsZeroValue(opts[i].AllowNotFound) { + q = q.Arg("allowNotFound", opts[i].AllowNotFound) + } + } q = q.Arg("path", path) return &Directory{ @@ -6277,6 +6313,7 @@ type Service struct { endpoint *string hostname *string id *ServiceID + signal *ServiceID start *ServiceID stop *ServiceID up *Void @@ -6409,6 +6446,14 @@ func (r *Service) Ports(ctx context.Context) ([]Port, error) { return convert(response), nil } +// Signal the service. +func (r *Service) Signal(ctx context.Context, signal SignalTypes) (*Service, error) { + q := r.query.Select("signal") + q = q.Arg("signal", signal) + + return r, q.Execute(ctx) +} + // Start the service and wait for its health checks to succeed. // // Services bound to a Container do not need to be manually started. @@ -6422,6 +6467,8 @@ func (r *Service) Start(ctx context.Context) (*Service, error) { type ServiceStopOpts struct { // Immediately kill the service without waiting for a graceful exit Kill bool + // The signal to send to the service. + Signal SignalTypes } // Stop the service. @@ -6432,6 +6479,10 @@ func (r *Service) Stop(ctx context.Context, opts ...ServiceStopOpts) (*Service, if !querybuilder.IsZeroValue(opts[i].Kill) { q = q.Arg("kill", opts[i].Kill) } + // `signal` optional argument + if !querybuilder.IsZeroValue(opts[i].Signal) { + q = q.Arg("signal", opts[i].Signal) + } } return r, q.Execute(ctx) @@ -6925,6 +6976,82 @@ const ( Udp NetworkProtocol = "UDP" ) +type SignalTypes string + +func (SignalTypes) IsEnum() {} + +const ( + Sigabrt SignalTypes = "SIGABRT" + + Sigalrm SignalTypes = "SIGALRM" + + Sigbus SignalTypes = "SIGBUS" + + Sigchld SignalTypes = "SIGCHLD" + + Sigcld SignalTypes = "SIGCLD" + + Sigcont SignalTypes = "SIGCONT" + + Sigfpe SignalTypes = "SIGFPE" + + Sighup SignalTypes = "SIGHUP" + + Sigill SignalTypes = "SIGILL" + + Sigint SignalTypes = "SIGINT" + + Sigio SignalTypes = "SIGIO" + + Sigiot SignalTypes = "SIGIOT" + + Sigkill SignalTypes = "SIGKILL" + + Sigpipe SignalTypes = "SIGPIPE" + + Sigpoll SignalTypes = "SIGPOLL" + + Sigprof SignalTypes = "SIGPROF" + + Sigpwr SignalTypes = "SIGPWR" + + Sigquit SignalTypes = "SIGQUIT" + + Sigsegv SignalTypes = "SIGSEGV" + + Sigstkflt SignalTypes = "SIGSTKFLT" + + Sigstop SignalTypes = "SIGSTOP" + + Sigsys SignalTypes = "SIGSYS" + + Sigterm SignalTypes = "SIGTERM" + + Sigtrap SignalTypes = "SIGTRAP" + + Sigtstp SignalTypes = "SIGTSTP" + + Sigttin SignalTypes = "SIGTTIN" + + Sigttou SignalTypes = "SIGTTOU" + + Sigunused SignalTypes = "SIGUNUSED" + + Sigurg SignalTypes = "SIGURG" + + Sigusr1 SignalTypes = "SIGUSR1" + + Sigusr2 SignalTypes = "SIGUSR2" + + Sigvtalrm SignalTypes = "SIGVTALRM" + + Sigwinch SignalTypes = "SIGWINCH" + + Sigxcpu SignalTypes = "SIGXCPU" + + Sigxfsz SignalTypes = "SIGXFSZ" +) + type TypeDefKind string func (TypeDefKind) IsEnum() {} diff --git a/sdk/php/generated/Directory.php b/sdk/php/generated/Directory.php index cd06a9255c..559530e6b5 100644 --- a/sdk/php/generated/Directory.php +++ b/sdk/php/generated/Directory.php @@ -244,20 +244,36 @@ public function withTimestamps(int $timestamp): Directory /** * Retrieves this directory with the directory at the given path removed. */ - public function withoutDirectory(string $path): Directory + public function withoutDirectory( + string $path, + ?bool $allowWildCard = true, + ?bool $allowNotFound = true, + ): Directory { $innerQueryBuilder = new \Dagger\Client\QueryBuilder('withoutDirectory'); $innerQueryBuilder->setArgument('path', $path); + if (null !== $allowWildCard) { + $innerQueryBuilder->setArgument('allowWildCard', $allowWildCard); + } + if (null !== $allowNotFound) { + $innerQueryBuilder->setArgument('allowNotFound', $allowNotFound); + } return new \Dagger\Directory($this->client, $this->queryBuilderChain->chain($innerQueryBuilder)); } /** * Retrieves this directory with the file at the given path removed. */ - public function withoutFile(string $path): Directory + public function withoutFile(string $path, ?bool $allowWildCard = true, ?bool $allowNotFound = true): Directory { $innerQueryBuilder = new \Dagger\Client\QueryBuilder('withoutFile'); $innerQueryBuilder->setArgument('path', $path); + if (null !== $allowWildCard) { + $innerQueryBuilder->setArgument('allowWildCard', $allowWildCard); + } + if (null !== $allowNotFound) { + $innerQueryBuilder->setArgument('allowNotFound', $allowNotFound); + } return new \Dagger\Directory($this->client, $this->queryBuilderChain->chain($innerQueryBuilder)); } } diff --git a/sdk/php/generated/Service.php b/sdk/php/generated/Service.php index fccdf6600e..f618587b65 100644 --- a/sdk/php/generated/Service.php +++ b/sdk/php/generated/Service.php @@ -59,6 +59,16 @@ public function ports(): array return (array)$this->queryLeaf($leafQueryBuilder, 'ports'); } + /** + * Signal the service. + */ + public function signal(SignalTypes $signal): ServiceId + { + $leafQueryBuilder = new \Dagger\Client\QueryBuilder('signal'); + $leafQueryBuilder->setArgument('signal', $signal); + return new \Dagger\ServiceId((string)$this->queryLeaf($leafQueryBuilder, 'signal')); + } + /** * Start the service and wait for its health checks to succeed. * @@ -73,12 +83,15 @@ public function start(): ServiceId /** * Stop the service. */ - public function stop(?bool $kill = false): ServiceId + public function stop(?bool $kill = false, ?SignalTypes $signal = null): ServiceId { $leafQueryBuilder = new \Dagger\Client\QueryBuilder('stop'); if (null !== $kill) { $leafQueryBuilder->setArgument('kill', $kill); } + if (null !== $signal) { + $leafQueryBuilder->setArgument('signal', $signal); + } return new \Dagger\ServiceId((string)$this->queryLeaf($leafQueryBuilder, 'stop')); } diff --git a/sdk/php/generated/SignalTypes.php b/sdk/php/generated/SignalTypes.php new file mode 100644 index 0000000000..006b4e2a48 --- /dev/null +++ b/sdk/php/generated/SignalTypes.php @@ -0,0 +1,51 @@ + Self: _ctx = self._select("withTimestamps", _args) return Directory(_ctx) - def without_directory(self, path: str) -> Self: + def without_directory( + self, + path: str, + *, + allow_wild_card: bool | None = True, + allow_not_found: bool | None = True, + ) -> Self: """Retrieves this directory with the directory at the given path removed. Parameters ---------- path: Location of the directory to remove (e.g., ".github/"). + allow_wild_card: + Allow wildcards in the path (e.g., "*.txt"). + allow_not_found: + Allow the operation to not fail if the directory does not exist. """ _args = [ Arg("path", path), + Arg("allowWildCard", allow_wild_card, True), + Arg("allowNotFound", allow_not_found, True), ] _ctx = self._select("withoutDirectory", _args) return Directory(_ctx) - def without_file(self, path: str) -> Self: + def without_file( + self, + path: str, + *, + allow_wild_card: bool | None = True, + allow_not_found: bool | None = True, + ) -> Self: """Retrieves this directory with the file at the given path removed. Parameters ---------- path: Location of the file to remove (e.g., "/file.txt"). + allow_wild_card: + Allow wildcards in the path (e.g., "*.txt"). + allow_not_found: + Allow the operation to not fail if the directory does not exist. """ _args = [ Arg("path", path), + Arg("allowWildCard", allow_wild_card, True), + Arg("allowNotFound", allow_not_found, True), ] _ctx = self._select("withoutFile", _args) return Directory(_ctx) @@ -6413,6 +6511,29 @@ class Response: for v in _ids ] + async def signal(self, signal: SignalTypes) -> Self: + """Signal the service. + + Parameters + ---------- + signal: + The signal to send to the service. + + Raises + ------ + ExecuteTimeoutError + If the time to execute the query exceeds the configured timeout. + QueryError + If the API returns an error. + """ + _args = [ + Arg("signal", signal), + ] + _ctx = self._select("signal", _args) + _id = await _ctx.execute(ServiceID) + _ctx = Client.from_context(_ctx)._select("loadServiceFromID", [Arg("id", _id)]) + return Service(_ctx) + async def start(self) -> Self: """Start the service and wait for its health checks to succeed. @@ -6431,13 +6552,20 @@ async def start(self) -> Self: _ctx = Client.from_context(_ctx)._select("loadServiceFromID", [Arg("id", _id)]) return Service(_ctx) - async def stop(self, *, kill: bool | None = False) -> Self: + async def stop( + self, + *, + kill: bool | None = False, + signal: SignalTypes | None = None, + ) -> Self: """Stop the service. Parameters ---------- kill: Immediately kill the service without waiting for a graceful exit + signal: + The signal to send to the service. Raises ------ @@ -6448,6 +6576,7 @@ async def stop(self, *, kill: bool | None = False) -> Self: """ _args = [ Arg("kill", kill, False), + Arg("signal", signal, None), ] _ctx = self._select("stop", _args) _id = await _ctx.execute(ServiceID) @@ -6882,6 +7011,7 @@ def with_(self, cb: Callable[["TypeDef"], "TypeDef"]) -> "TypeDef": "SecretID", "Service", "ServiceID", + "SignalTypes", "Socket", "SocketID", "Terminal", diff --git a/sdk/rust/crates/dagger-sdk/src/gen.rs b/sdk/rust/crates/dagger-sdk/src/gen.rs index 23ac836b9f..fce02e9172 100644 --- a/sdk/rust/crates/dagger-sdk/src/gen.rs +++ b/sdk/rust/crates/dagger-sdk/src/gen.rs @@ -3341,6 +3341,24 @@ pub struct DirectoryWithNewFileOpts { #[builder(setter(into, strip_option), default)] pub permissions: Option, } +#[derive(Builder, Debug, PartialEq)] +pub struct DirectoryWithoutDirectoryOpts { + /// Allow the operation to not fail if the directory does not exist. + #[builder(setter(into, strip_option), default)] + pub allow_not_found: Option, + /// Allow wildcards in the path (e.g., "*.txt"). + #[builder(setter(into, strip_option), default)] + pub allow_wild_card: Option, +} +#[derive(Builder, Debug, PartialEq)] +pub struct DirectoryWithoutFileOpts { + /// Allow the operation to not fail if the directory does not exist. + #[builder(setter(into, strip_option), default)] + pub allow_not_found: Option, + /// Allow wildcards in the path (e.g., "*.txt"). + #[builder(setter(into, strip_option), default)] + pub allow_wild_card: Option, +} impl Directory { /// Load the directory as a Dagger module /// @@ -3830,6 +3848,7 @@ impl Directory { /// # Arguments /// /// * `path` - Location of the directory to remove (e.g., ".github/"). + /// * `opt` - optional argument, see inner type for documentation, use _opts to use pub fn without_directory(&self, path: impl Into) -> Directory { let mut query = self.selection.select("withoutDirectory"); query = query.arg("path", path.into()); @@ -3839,11 +3858,37 @@ impl Directory { graphql_client: self.graphql_client.clone(), } } + /// Retrieves this directory with the directory at the given path removed. + /// + /// # Arguments + /// + /// * `path` - Location of the directory to remove (e.g., ".github/"). + /// * `opt` - optional argument, see inner type for documentation, use _opts to use + pub fn without_directory_opts( + &self, + path: impl Into, + opts: DirectoryWithoutDirectoryOpts, + ) -> Directory { + let mut query = self.selection.select("withoutDirectory"); + query = query.arg("path", path.into()); + if let Some(allow_wild_card) = opts.allow_wild_card { + query = query.arg("allowWildCard", allow_wild_card); + } + if let Some(allow_not_found) = opts.allow_not_found { + query = query.arg("allowNotFound", allow_not_found); + } + Directory { + proc: self.proc.clone(), + selection: query, + graphql_client: self.graphql_client.clone(), + } + } /// Retrieves this directory with the file at the given path removed. /// /// # Arguments /// /// * `path` - Location of the file to remove (e.g., "/file.txt"). + /// * `opt` - optional argument, see inner type for documentation, use _opts to use pub fn without_file(&self, path: impl Into) -> Directory { let mut query = self.selection.select("withoutFile"); query = query.arg("path", path.into()); @@ -3853,6 +3898,31 @@ impl Directory { graphql_client: self.graphql_client.clone(), } } + /// Retrieves this directory with the file at the given path removed. + /// + /// # Arguments + /// + /// * `path` - Location of the file to remove (e.g., "/file.txt"). + /// * `opt` - optional argument, see inner type for documentation, use _opts to use + pub fn without_file_opts( + &self, + path: impl Into, + opts: DirectoryWithoutFileOpts, + ) -> Directory { + let mut query = self.selection.select("withoutFile"); + query = query.arg("path", path.into()); + if let Some(allow_wild_card) = opts.allow_wild_card { + query = query.arg("allowWildCard", allow_wild_card); + } + if let Some(allow_not_found) = opts.allow_not_found { + query = query.arg("allowNotFound", allow_not_found); + } + Directory { + proc: self.proc.clone(), + selection: query, + graphql_client: self.graphql_client.clone(), + } + } } #[derive(Clone)] pub struct EnvVariable { @@ -6690,6 +6760,9 @@ pub struct ServiceStopOpts { /// Immediately kill the service without waiting for a graceful exit #[builder(setter(into, strip_option), default)] pub kill: Option, + /// The signal to send to the service. + #[builder(setter(into, strip_option), default)] + pub signal: Option, } #[derive(Builder, Debug, PartialEq)] pub struct ServiceUpOpts { @@ -6752,6 +6825,16 @@ impl Service { graphql_client: self.graphql_client.clone(), }]; } + /// Signal the service. + /// + /// # Arguments + /// + /// * `signal` - The signal to send to the service. + pub async fn signal(&self, signal: SignalTypes) -> Result { + let mut query = self.selection.select("signal"); + query = query.arg("signal", signal); + query.execute(self.graphql_client.clone()).await + } /// Start the service and wait for its health checks to succeed. /// Services bound to a Container do not need to be manually started. pub async fn start(&self) -> Result { @@ -6777,6 +6860,9 @@ impl Service { if let Some(kill) = opts.kill { query = query.arg("kill", kill); } + if let Some(signal) = opts.signal { + query = query.arg("signal", signal); + } query.execute(self.graphql_client.clone()).await } /// Creates a tunnel that forwards traffic from the caller's network to this service. @@ -7195,6 +7281,79 @@ pub enum NetworkProtocol { Udp, } #[derive(Serialize, Deserialize, Clone, PartialEq, Debug)] +pub enum SignalTypes { + #[serde(rename = "SIGABRT")] + Sigabrt, + #[serde(rename = "SIGALRM")] + Sigalrm, + #[serde(rename = "SIGBUS")] + Sigbus, + #[serde(rename = "SIGCHLD")] + Sigchld, + #[serde(rename = "SIGCLD")] + Sigcld, + #[serde(rename = "SIGCONT")] + Sigcont, + #[serde(rename = "SIGFPE")] + Sigfpe, + #[serde(rename = "SIGHUP")] + Sighup, + #[serde(rename = "SIGILL")] + Sigill, + #[serde(rename = "SIGINT")] + Sigint, + #[serde(rename = "SIGIO")] + Sigio, + #[serde(rename = "SIGIOT")] + Sigiot, + #[serde(rename = "SIGKILL")] + Sigkill, + #[serde(rename = "SIGPIPE")] + Sigpipe, + #[serde(rename = "SIGPOLL")] + Sigpoll, + #[serde(rename = "SIGPROF")] + Sigprof, + #[serde(rename = "SIGPWR")] + Sigpwr, + #[serde(rename = "SIGQUIT")] + Sigquit, + #[serde(rename = "SIGSEGV")] + Sigsegv, + #[serde(rename = "SIGSTKFLT")] + Sigstkflt, + #[serde(rename = "SIGSTOP")] + Sigstop, + #[serde(rename = "SIGSYS")] + Sigsys, + #[serde(rename = "SIGTERM")] + Sigterm, + #[serde(rename = "SIGTRAP")] + Sigtrap, + #[serde(rename = "SIGTSTP")] + Sigtstp, + #[serde(rename = "SIGTTIN")] + Sigttin, + #[serde(rename = "SIGTTOU")] + Sigttou, + #[serde(rename = "SIGUNUSED")] + Sigunused, + #[serde(rename = "SIGURG")] + Sigurg, + #[serde(rename = "SIGUSR1")] + Sigusr1, + #[serde(rename = "SIGUSR2")] + Sigusr2, + #[serde(rename = "SIGVTALRM")] + Sigvtalrm, + #[serde(rename = "SIGWINCH")] + Sigwinch, + #[serde(rename = "SIGXCPU")] + Sigxcpu, + #[serde(rename = "SIGXFSZ")] + Sigxfsz, +} +#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)] pub enum TypeDefKind { #[serde(rename = "BOOLEAN_KIND")] BooleanKind, diff --git a/sdk/typescript/api/client.gen.ts b/sdk/typescript/api/client.gen.ts index 37845dd5b4..ad929cfe86 100644 --- a/sdk/typescript/api/client.gen.ts +++ b/sdk/typescript/api/client.gen.ts @@ -585,6 +585,30 @@ export type DirectoryWithNewFileOpts = { permissions?: number } +export type DirectoryWithoutDirectoryOpts = { + /** + * Allow wildcards in the path (e.g., "*.txt"). + */ + allowWildCard?: boolean + + /** + * Allow the operation to not fail if the directory does not exist. + */ + allowNotFound?: boolean +} + +export type DirectoryWithoutFileOpts = { + /** + * Allow wildcards in the path (e.g., "*.txt"). + */ + allowWildCard?: boolean + + /** + * Allow the operation to not fail if the directory does not exist. + */ + allowNotFound?: boolean +} + /** * The `DirectoryID` scalar type represents an identifier for an object of type Directory. */ @@ -969,6 +993,11 @@ export type ServiceStopOpts = { * Immediately kill the service without waiting for a graceful exit */ kill?: boolean + + /** + * The signal to send to the service. + */ + signal?: SignalTypes } export type ServiceUpOpts = { @@ -990,6 +1019,46 @@ export type ServiceUpOpts = { */ export type ServiceID = string & { __ServiceID: never } +/** + * Signaltypes to be sent to processes. + */ +export enum SignalTypes { + Sigabrt = "SIGABRT", + Sigalrm = "SIGALRM", + Sigbus = "SIGBUS", + Sigchld = "SIGCHLD", + Sigcld = "SIGCLD", + Sigcont = "SIGCONT", + Sigfpe = "SIGFPE", + Sighup = "SIGHUP", + Sigill = "SIGILL", + Sigint = "SIGINT", + Sigio = "SIGIO", + Sigiot = "SIGIOT", + Sigkill = "SIGKILL", + Sigpipe = "SIGPIPE", + Sigpoll = "SIGPOLL", + Sigprof = "SIGPROF", + Sigpwr = "SIGPWR", + Sigquit = "SIGQUIT", + Sigsegv = "SIGSEGV", + Sigstkflt = "SIGSTKFLT", + Sigstop = "SIGSTOP", + Sigsys = "SIGSYS", + Sigterm = "SIGTERM", + Sigtrap = "SIGTRAP", + Sigtstp = "SIGTSTP", + Sigttin = "SIGTTIN", + Sigttou = "SIGTTOU", + Sigunused = "SIGUNUSED", + Sigurg = "SIGURG", + Sigusr1 = "SIGUSR1", + Sigusr2 = "SIGUSR2", + Sigvtalrm = "SIGVTALRM", + Sigwinch = "SIGWINCH", + Sigxcpu = "SIGXCPU", + Sigxfsz = "SIGXFSZ", +} /** * The `SocketID` scalar type represents an identifier for an object of type Socket. */ @@ -3220,14 +3289,19 @@ export class Directory extends BaseClient { /** * Retrieves this directory with the directory at the given path removed. * @param path Location of the directory to remove (e.g., ".github/"). + * @param opts.allowWildCard Allow wildcards in the path (e.g., "*.txt"). + * @param opts.allowNotFound Allow the operation to not fail if the directory does not exist. */ - withoutDirectory = (path: string): Directory => { + withoutDirectory = ( + path: string, + opts?: DirectoryWithoutDirectoryOpts, + ): Directory => { return new Directory({ queryTree: [ ...this._queryTree, { operation: "withoutDirectory", - args: { path }, + args: { path, ...opts }, }, ], ctx: this._ctx, @@ -3237,14 +3311,16 @@ export class Directory extends BaseClient { /** * Retrieves this directory with the file at the given path removed. * @param path Location of the file to remove (e.g., "/file.txt"). + * @param opts.allowWildCard Allow wildcards in the path (e.g., "*.txt"). + * @param opts.allowNotFound Allow the operation to not fail if the directory does not exist. */ - withoutFile = (path: string): Directory => { + withoutFile = (path: string, opts?: DirectoryWithoutFileOpts): Directory => { return new Directory({ queryTree: [ ...this._queryTree, { operation: "withoutFile", - args: { path }, + args: { path, ...opts }, }, ], ctx: this._ctx, @@ -8176,6 +8252,7 @@ export class Service extends BaseClient { private readonly _id?: ServiceID = undefined private readonly _endpoint?: string = undefined private readonly _hostname?: string = undefined + private readonly _signal?: ServiceID = undefined private readonly _start?: ServiceID = undefined private readonly _stop?: ServiceID = undefined private readonly _up?: Void = undefined @@ -8188,6 +8265,7 @@ export class Service extends BaseClient { _id?: ServiceID, _endpoint?: string, _hostname?: string, + _signal?: ServiceID, _start?: ServiceID, _stop?: ServiceID, _up?: Void, @@ -8197,6 +8275,7 @@ export class Service extends BaseClient { this._id = _id this._endpoint = _endpoint this._hostname = _hostname + this._signal = _signal this._start = _start this._stop = _stop this._up = _up @@ -8310,6 +8389,29 @@ export class Service extends BaseClient { ) } + /** + * Signal the service. + * @param signal The signal to send to the service. + */ + signal = async (signal: SignalTypes): Promise => { + const metadata: Metadata = { + signal: { is_enum: true }, + } + + await computeQuery( + [ + ...this._queryTree, + { + operation: "signal", + args: { signal, __metadata: metadata }, + }, + ], + await this._ctx.connection(), + ) + + return this + } + /** * Start the service and wait for its health checks to succeed. * @@ -8332,14 +8434,19 @@ export class Service extends BaseClient { /** * Stop the service. * @param opts.kill Immediately kill the service without waiting for a graceful exit + * @param opts.signal The signal to send to the service. */ stop = async (opts?: ServiceStopOpts): Promise => { + const metadata: Metadata = { + signal: { is_enum: true }, + } + await computeQuery( [ ...this._queryTree, { operation: "stop", - args: { ...opts }, + args: { ...opts, __metadata: metadata }, }, ], await this._ctx.connection(),