mirror of
https://github.com/Noratrieb/terustform.git
synced 2026-01-14 16:35:11 +01:00
56 lines
1.6 KiB
Rust
56 lines
1.6 KiB
Rust
mod client;
|
|
mod resources;
|
|
|
|
use std::collections::HashMap;
|
|
|
|
use eyre::Context;
|
|
use terustform::{
|
|
datasource::DataSource, provider::Provider, resource::Resource, DResult, EyreExt, Schema, Value,
|
|
};
|
|
|
|
#[tokio::main]
|
|
async fn main() -> eyre::Result<()> {
|
|
terustform::start(ExampleProvider {}).await
|
|
}
|
|
|
|
pub struct ExampleProvider {}
|
|
|
|
impl Provider for ExampleProvider {
|
|
type Data = client::CorsClient;
|
|
fn name(&self) -> String {
|
|
"corsschool".to_owned()
|
|
}
|
|
|
|
fn schema(&self) -> Schema {
|
|
Schema {
|
|
description: "uwu".to_owned(),
|
|
attributes: HashMap::new(),
|
|
}
|
|
}
|
|
|
|
async fn configure(&self, _config: Value) -> DResult<Self::Data> {
|
|
let username = std::env::var("CORSSCHOOL_USERNAME")
|
|
.wrap_err("CORSSCHOOL_USERNAME environment variable not set")
|
|
.eyre_to_tf()?;
|
|
let password = std::env::var("CORSSCHOOL_PASSWORD")
|
|
.wrap_err("CORSSCHOOL_PASSWORD environment variable not set")
|
|
.eyre_to_tf()?;
|
|
let client = client::CorsClient::new(username, password)
|
|
.await
|
|
.wrap_err("failed to create client")
|
|
.eyre_to_tf()?;
|
|
Ok(client)
|
|
}
|
|
|
|
fn data_sources(&self) -> terustform::provider::DataSources<Self> {
|
|
vec![
|
|
resources::kitty::ExampleDataSource::erase(),
|
|
resources::hugo::HugoDataSource::erase(),
|
|
resources::class_data_source::ClassDataSource::erase(),
|
|
]
|
|
}
|
|
|
|
fn resources(&self) -> terustform::provider::Resources<Self> {
|
|
vec![resources::class_resource::ClassResource::erase()]
|
|
}
|
|
}
|