1use crate::{JwtBundleError, JwtSvidError, SpiffeIdError, X509BundleError, X509SvidError};
7use thiserror::Error;
8use url::ParseError;
9
10#[derive(Debug, Error)]
13#[non_exhaustive]
14pub enum GrpcClientError {
15 #[error("missing endpoint socket address environment variable (SPIFFE_ENDPOINT_SOCKET)")]
17 MissingEndpointSocketPath,
18
19 #[error("received an empty response from the GRPC client")]
21 EmptyResponse,
22
23 #[error("invalid endpoint socket path")]
25 InvalidEndpointSocketPath(#[from] SocketPathError),
26
27 #[error("failed to process X509Svid response")]
29 InvalidX509Svid(#[from] X509SvidError),
30
31 #[error("failed to process JwtSvid response")]
33 InvalidJwtSvid(#[from] JwtSvidError),
34
35 #[error("failed to process X509Bundle response")]
37 InvalidX509Bundle(#[from] X509BundleError),
38
39 #[error("failed to process JwtBundle response")]
41 InvalidJwtBundle(#[from] JwtBundleError),
42
43 #[error("invalid trust domain in bundles response")]
45 InvalidTrustDomain(#[from] SpiffeIdError),
46
47 #[error("error response from the GRPC client")]
49 Grpc(#[from] tonic::Status),
50
51 #[error("error creating transport channel to the GRPC client")]
53 Transport(#[from] tonic::transport::Error),
54}
55
56#[derive(Debug, Error, PartialEq, Copy, Clone)]
59#[non_exhaustive]
60pub enum SocketPathError {
61 #[error("workload endpoint socket URI must have a tcp:// or unix:// scheme")]
63 InvalidScheme,
64
65 #[error("workload endpoint unix socket URI must include a path")]
67 UnixAddressEmptyPath,
68
69 #[error("workload endpoint tcp socket URI must not include a path")]
71 TcpAddressNonEmptyPath,
72
73 #[error("workload endpoint socket URI must not include query values")]
75 HasQueryValues,
76
77 #[error("workload endpoint socket URI must not include a fragment")]
79 HasFragment,
80
81 #[error("workload endpoint socket URI must not include user info")]
83 HasUserInfo,
84
85 #[error("workload endpoint tcp socket URI must include a host")]
87 TcpEmptyHost,
88
89 #[error("workload endpoint tcp socket URI host component must be an IP:port")]
91 TcpAddressNoIpPort,
92
93 #[error("workload endpoint socket is not a valid URI")]
95 Parse(#[from] ParseError),
96}