use alien_error::AlienError;
pub use alien_core::{Platform, ENV_ALIEN_DEPLOYMENT_TYPE, ENV_OPERATOR_BASE_PLATFORM};
pub use bindings::{Bindings, BoundQueue};
pub use error::{ErrorData, Result};
pub use provider::BindingsProvider;
pub use traits::{
ArtifactRegistry, ArtifactRegistryCredentials, ArtifactRegistryPermissions,
AwsServiceAccountInfo, AzureServiceAccountInfo, Binding, BindingsProviderApi, Build, Container,
GcpServiceAccountInfo, ImpersonationRequest, Kv, Postgres, PostgresConnectionParams, Queue,
RegistryAuthMethod, RepositoryResponse, ServiceAccount, ServiceAccountInfo, SslMode, Storage,
Vault, Worker,
};
pub mod bindings;
pub mod error;
pub mod providers;
pub mod traits;
pub mod presigned {
pub use alien_core::presigned::*;
}
mod credential_source;
pub mod http_client;
pub mod provider;
mod refreshing;
pub fn get_current_platform() -> Result<Platform> {
let env_vars: std::collections::HashMap<String, String> = std::env::vars().collect();
get_platform_from_env(&env_vars)
}
pub fn get_platform_from_env(env: &std::collections::HashMap<String, String>) -> Result<Platform> {
let deployment_type = env.get(ENV_ALIEN_DEPLOYMENT_TYPE).ok_or_else(|| {
AlienError::new(ErrorData::EnvironmentVariableMissing {
variable_name: ENV_ALIEN_DEPLOYMENT_TYPE.to_string(),
})
})?;
deployment_type.parse().map_err(|_| {
AlienError::new(ErrorData::InvalidEnvironmentVariable {
variable_name: ENV_ALIEN_DEPLOYMENT_TYPE.to_string(),
value: deployment_type.clone(),
reason: "Cannot parse the ALIEN_DEPLOYMENT_TYPE environment variable".to_string(),
})
})
}