Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: supportAllowWildCard and AllowNotFound #7437

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions core/integration/directory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,13 @@
require.NoError(t, err)
require.Equal(t, []string{"some-dir", "some-file"}, entries)

// Test without dir with allow not found = false
_, err = dir1.
WithoutDirectory("non-existant", dagger.DirectoryWithoutDirectoryOpts{AllowNotFound: false}).

Check failure on line 526 in core/integration/directory_test.go

View workflow job for this annotation

GitHub Actions / lint / dagger-runner-v2

`existant` is a misspelling of `existent` (misspell)

Check failure on line 526 in core/integration/directory_test.go

View workflow job for this annotation

GitHub Actions / lint / dagger-runner-v2

`existant` is a misspelling of `existent` (misspell)
Copy link
Member

Choose a reason for hiding this comment

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

@TomChv this is your issue.

In go, the empty struct defaults to false - therefore, we have the API constraint today that all boolean options must default to false.

What you need is to invert the option, to something like MustExist: true, so that the default is false.

Entries(ctx)

require.Error(t, err)

dir := c.Directory().
WithNewFile("foo.txt", "foo").
WithNewFile("a/bar.txt", "bar").
Expand Down Expand Up @@ -550,6 +557,12 @@
require.NoError(t, err)
require.Equal(t, []string{"data.json"}, entries)

_, err = dir.
WithoutDirectory("b/*.txt", dagger.DirectoryWithoutDirectoryOpts{AllowWildCard: false}).
Entries(ctx)

require.Error(t, err)

entries, err = dir.
WithoutFile("c/*a1*").
Entries(ctx, dagger.DirectoryEntriesOpts{Path: "c"})
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ require (
github.com/opencontainers/runc v1.1.12
github.com/opencontainers/runtime-spec v1.2.0
github.com/pelletier/go-toml v1.9.5
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
github.com/pkg/errors v0.9.1
github.com/prometheus/procfs v0.12.0
github.com/psanford/memfs v0.0.0-20230130182539-4dbf7e3e865e
Expand Down Expand Up @@ -263,7 +263,6 @@ require (
go.opentelemetry.io/otel/metric v1.26.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
Expand Down
5 changes: 0 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -824,8 +824,6 @@ golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4Iltr
golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20210810183815-faf39c7919d5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.17.0 h1:6m3ZPmLEFdVxKKWnKq4VqZ60gutO35zm+zrAHVmHyDQ=
golang.org/x/oauth2 v0.17.0/go.mod h1:OzPDGQiuQMguemayvdylqddI7qcD9lnSDb+1FiwQ5HA=
golang.org/x/oauth2 v0.19.0 h1:9+E/EZBCbTLNrbN35fHv/a/d/mOBatymz1zbtQrXpIg=
golang.org/x/oauth2 v0.19.0/go.mod h1:vYi7skDa1x015PmRRYZ7+s1cWyPgrPiSYRe4rnsexc8=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand Down Expand Up @@ -914,7 +912,6 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
Expand Down Expand Up @@ -999,8 +996,6 @@ google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM=
google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
Expand Down
26 changes: 20 additions & 6 deletions sdk/elixir/lib/dagger/gen/directory.ex

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 38 additions & 2 deletions sdk/go/dagger.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 18 additions & 2 deletions sdk/php/generated/Directory.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 26 additions & 2 deletions sdk/python/src/dagger/client/gen.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 70 additions & 0 deletions sdk/rust/crates/dagger-sdk/src/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3341,6 +3341,24 @@ pub struct DirectoryWithNewFileOpts {
#[builder(setter(into, strip_option), default)]
pub permissions: Option<isize>,
}
#[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<bool>,
/// Allow wildcards in the path (e.g., "*.txt").
#[builder(setter(into, strip_option), default)]
pub allow_wild_card: Option<bool>,
}
#[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<bool>,
/// Allow wildcards in the path (e.g., "*.txt").
#[builder(setter(into, strip_option), default)]
pub allow_wild_card: Option<bool>,
}
impl Directory {
/// Load the directory as a Dagger module
///
Expand Down Expand Up @@ -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 <func>_opts to use
pub fn without_directory(&self, path: impl Into<String>) -> Directory {
let mut query = self.selection.select("withoutDirectory");
query = query.arg("path", path.into());
Expand All @@ -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 <func>_opts to use
pub fn without_directory_opts(
&self,
path: impl Into<String>,
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 <func>_opts to use
pub fn without_file(&self, path: impl Into<String>) -> Directory {
let mut query = self.selection.select("withoutFile");
query = query.arg("path", path.into());
Expand All @@ -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 <func>_opts to use
pub fn without_file_opts(
&self,
path: impl Into<String>,
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 {
Expand Down