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

custom clients do not respect Api::default_namespaced #543

Closed
clux opened this issue Jun 6, 2021 · 0 comments · Fixed by #544
Closed

custom clients do not respect Api::default_namespaced #543

clux opened this issue Jun 6, 2021 · 0 comments · Fixed by #544

Comments

@clux
Copy link
Member

clux commented Jun 6, 2021

Custom clients added in #534 rely on a private Client::new_with_default_ns use in Client::try_default.

This creates a bit of a footgun between two modes that should work the same: Client::try_default and Client::new(similar_service_stack).

Possibly we split the constructor and instead have a moving setter:

impl Client {
    fn with_default_namespace<T: Into<String>>)(mut self, ns: T) -> Self {
        self.default_ns = ns.into();
        self
    }
}

that way we can have the the comparatively easier to read:

    let config = Config::infer().await?;
    let https = config.native_tls_https_connector()?;
    let client = Client::new(
        tower::ServiceBuilder::new()
            .layer(config.base_uri_layer())
            .option_layer(config.auth_layer()?)
            .service(hyper::Client::builder().build(https))
    ).with_default_namespace(config.default_ns);

This makes the config.default_ns a more public facing var, should probably rename it as well to default_namespace.

@clux clux linked a pull request Jun 6, 2021 that will close this issue
4 tasks
@clux clux closed this as completed in #544 Jun 7, 2021
clux added a commit that referenced this issue Jun 7, 2021
* add moving with_default_ns Client setter - fixes #543

* rename Config::default_ns to Config::default_namespace

* remove Client::new_with_default_ns in favour of setter

also document

* default_namespace as required arg to avoid errors

* Update kube/src/client/mod.rs

Co-authored-by: kazk <kazk.dev@gmail.com>

Co-authored-by: kazk <kazk.dev@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant