-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(kube-proxy): expose error to make it extensible
The plugin can then add a more human error message. Signed-off-by: Tiago Castro <tiagolobocastro@gmail.com>
- Loading branch information
1 parent
1670d8c
commit 401e460
Showing
10 changed files
with
163 additions
and
76 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/// A kube-forward error. | ||
#[derive(Debug, thiserror::Error)] | ||
#[allow(missing_docs)] | ||
pub enum Error { | ||
#[error("Service '{selector}' not found on '{namespace:?}'")] | ||
ServiceNotFound { | ||
selector: String, | ||
namespace: crate::NameSpace, | ||
}, | ||
#[error("{source}")] | ||
Kube { source: kube::Error }, | ||
#[error("{source}")] | ||
AnyHow { source: anyhow::Error }, | ||
#[error("Invalid uri: {source}")] | ||
InvalidUri { | ||
source: hyper::http::uri::InvalidUri, | ||
}, | ||
#[error("{source}")] | ||
Io { source: std::io::Error }, | ||
} | ||
|
||
impl From<anyhow::Error> for Error { | ||
fn from(source: anyhow::Error) -> Self { | ||
Self::AnyHow { source } | ||
} | ||
} | ||
|
||
impl From<kube::Error> for Error { | ||
fn from(source: kube::Error) -> Self { | ||
Self::Kube { source } | ||
} | ||
} | ||
|
||
impl From<hyper::http::uri::InvalidUri> for Error { | ||
fn from(source: hyper::http::uri::InvalidUri) -> Self { | ||
Self::InvalidUri { source } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/// A kube-proxy error. | ||
#[derive(Debug, thiserror::Error)] | ||
#[allow(missing_docs)] | ||
pub enum Error { | ||
#[error("{source}")] | ||
Forward { source: kube_forward::Error }, | ||
#[error("{source}")] | ||
Kube { source: kube::Error }, | ||
#[error("{source}")] | ||
AnyHow { source: anyhow::Error }, | ||
#[error("Invalid url: {source}")] | ||
InvalidUrl { source: url::ParseError }, | ||
#[error("Invalid uri: {source}")] | ||
InvalidUri { | ||
source: hyper::http::uri::InvalidUri, | ||
}, | ||
} | ||
|
||
impl From<kube_forward::Error> for Error { | ||
fn from(source: kube_forward::Error) -> Self { | ||
Self::Forward { source } | ||
} | ||
} | ||
|
||
impl From<anyhow::Error> for Error { | ||
fn from(source: anyhow::Error) -> Self { | ||
Self::AnyHow { source } | ||
} | ||
} | ||
|
||
impl From<kube::Error> for Error { | ||
fn from(source: kube::Error) -> Self { | ||
Self::Kube { source } | ||
} | ||
} | ||
|
||
impl From<url::ParseError> for Error { | ||
fn from(source: url::ParseError) -> Self { | ||
Self::InvalidUrl { source } | ||
} | ||
} | ||
|
||
impl From<hyper::http::uri::InvalidUri> for Error { | ||
fn from(source: hyper::http::uri::InvalidUri) -> Self { | ||
Self::InvalidUri { source } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.