mirror of
https://github.com/Noratrieb/terustform.git
synced 2026-01-14 16:35:11 +01:00
Fix clippy lints
This commit is contained in:
parent
60de4d5ba8
commit
bd90f5c978
5 changed files with 22 additions and 22 deletions
|
|
@ -65,5 +65,5 @@ async fn do_request(req: RequestBuilder) -> Result<Response> {
|
|||
return Err(err).wrap_err(text);
|
||||
}
|
||||
|
||||
Ok(res.error_for_status().wrap_err("failed to get class")?)
|
||||
res.error_for_status().wrap_err("failed to get class")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ impl DataSource for ClassDataSource {
|
|||
|
||||
let class = self
|
||||
.client
|
||||
.get_class(&model.id.expect_known(AttrPath::attr("id"))?)
|
||||
.get_class(model.id.expect_known(AttrPath::attr("id"))?)
|
||||
.await
|
||||
.wrap_err("failed to get class")
|
||||
.eyre_to_tf()?;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use crate::{values::Type, AttrPathSegment, Attribute, Diagnostics, Mode, Schema}
|
|||
use super::grpc::tfplugin6;
|
||||
|
||||
impl Schema {
|
||||
pub(crate) fn to_tfplugin(self) -> tfplugin6::Schema {
|
||||
pub(crate) fn into_tfplugin(self) -> tfplugin6::Schema {
|
||||
tfplugin6::Schema {
|
||||
version: 1,
|
||||
block: Some(tfplugin6::schema::Block {
|
||||
|
|
@ -11,7 +11,7 @@ impl Schema {
|
|||
attributes: self
|
||||
.attributes
|
||||
.into_iter()
|
||||
.map(|(name, attr)| attr.to_tfplugin(name))
|
||||
.map(|(name, attr)| attr.into_tfplugin(name))
|
||||
.collect(),
|
||||
block_types: vec![],
|
||||
description: self.description,
|
||||
|
|
@ -23,7 +23,7 @@ impl Schema {
|
|||
}
|
||||
|
||||
impl Attribute {
|
||||
pub(crate) fn to_tfplugin(self, name: String) -> tfplugin6::schema::Attribute {
|
||||
pub(crate) fn into_tfplugin(self, name: String) -> tfplugin6::schema::Attribute {
|
||||
let mut attr = tfplugin6::schema::Attribute {
|
||||
name,
|
||||
r#type: vec![],
|
||||
|
|
@ -71,7 +71,7 @@ impl Attribute {
|
|||
}
|
||||
|
||||
impl Diagnostics {
|
||||
pub(crate) fn to_tfplugin_diags(self) -> Vec<tfplugin6::Diagnostic> {
|
||||
pub(crate) fn into_tfplugin_diags(self) -> Vec<tfplugin6::Diagnostic> {
|
||||
self.diags
|
||||
.into_iter()
|
||||
.map(|err| tfplugin6::Diagnostic {
|
||||
|
|
|
|||
|
|
@ -87,17 +87,17 @@ impl<P: Provider> ProviderHandler<P> {
|
|||
mk_ds,
|
||||
mk_rs,
|
||||
} => (provider, mk_ds, mk_rs),
|
||||
ProviderState::Failed { diags } => return diags.clone().to_tfplugin_diags(),
|
||||
ProviderState::Failed { diags } => return diags.clone().into_tfplugin_diags(),
|
||||
ProviderState::Configured { .. } => unreachable!("called configure twice"),
|
||||
};
|
||||
let config = match parse_dynamic_value(config, &provider.schema().typ()) {
|
||||
Ok(config) => config,
|
||||
Err(errs) => return errs.to_tfplugin_diags(),
|
||||
Err(errs) => return errs.into_tfplugin_diags(),
|
||||
};
|
||||
|
||||
let data = match provider.configure(config).await {
|
||||
Ok(data) => data,
|
||||
Err(errs) => return errs.to_tfplugin_diags(),
|
||||
Err(errs) => return errs.into_tfplugin_diags(),
|
||||
};
|
||||
let mut diags = vec![];
|
||||
|
||||
|
|
@ -109,7 +109,7 @@ impl<P: Provider> ProviderHandler<P> {
|
|||
Ok(ds) => {
|
||||
data_sources.insert(ds_name.clone(), ds);
|
||||
}
|
||||
Err(errs) => diags.extend(errs.to_tfplugin_diags()),
|
||||
Err(errs) => diags.extend(errs.into_tfplugin_diags()),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -121,7 +121,7 @@ impl<P: Provider> ProviderHandler<P> {
|
|||
Ok(rs) => {
|
||||
resources.insert(rs_name.clone(), rs);
|
||||
}
|
||||
Err(errs) => diags.extend(errs.to_tfplugin_diags()),
|
||||
Err(errs) => diags.extend(errs.into_tfplugin_diags()),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -146,7 +146,7 @@ impl<P: Provider> ProviderHandler<P> {
|
|||
return Schemas {
|
||||
resources: HashMap::new(),
|
||||
data_sources: HashMap::new(),
|
||||
diagnostics: diags.clone().to_tfplugin_diags(),
|
||||
diagnostics: diags.clone().into_tfplugin_diags(),
|
||||
}
|
||||
}
|
||||
ProviderState::Configured { .. } => {
|
||||
|
|
@ -157,14 +157,14 @@ impl<P: Provider> ProviderHandler<P> {
|
|||
.iter()
|
||||
.map(|(name, ds)| {
|
||||
tracing::debug!(?name, "Initializing data source");
|
||||
(name.to_owned(), ds.schema.clone().to_tfplugin())
|
||||
(name.to_owned(), ds.schema.clone().into_tfplugin())
|
||||
})
|
||||
.collect::<HashMap<String, tfplugin6::Schema>>();
|
||||
let resources = mk_rs
|
||||
.iter()
|
||||
.map(|(name, ds)| {
|
||||
tracing::debug!(?name, "Initializing resources");
|
||||
(name.to_owned(), ds.schema.clone().to_tfplugin())
|
||||
(name.to_owned(), ds.schema.clone().into_tfplugin())
|
||||
})
|
||||
.collect::<HashMap<String, tfplugin6::Schema>>();
|
||||
|
||||
|
|
@ -187,7 +187,7 @@ impl<P: Provider> ProviderHandler<P> {
|
|||
unreachable!("must be set up before calling data sources")
|
||||
}
|
||||
ProviderState::Failed { diags } => {
|
||||
return (None, diags.clone().to_tfplugin_diags())
|
||||
return (None, diags.clone().into_tfplugin_diags())
|
||||
}
|
||||
ProviderState::Configured {
|
||||
data_sources,
|
||||
|
|
@ -201,7 +201,7 @@ impl<P: Provider> ProviderHandler<P> {
|
|||
let config = match parse_dynamic_value(config, &typ) {
|
||||
Ok(value) => value,
|
||||
Err(errs) => {
|
||||
return (None, errs.to_tfplugin_diags());
|
||||
return (None, errs.into_tfplugin_diags());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -214,7 +214,7 @@ impl<P: Provider> ProviderHandler<P> {
|
|||
}),
|
||||
vec![],
|
||||
),
|
||||
Err(errs) => (None, errs.to_tfplugin_diags()),
|
||||
Err(errs) => (None, errs.into_tfplugin_diags()),
|
||||
};
|
||||
|
||||
(state, diagnostics)
|
||||
|
|
|
|||
|
|
@ -300,7 +300,7 @@ impl Value {
|
|||
let len = mp::read_array_len(rd)?;
|
||||
|
||||
let elems = (0..len)
|
||||
.map(|_| Value::msg_unpack_inner(rd, &elem))
|
||||
.map(|_| Value::msg_unpack_inner(rd, elem))
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
ValueKind::List(elems)
|
||||
}
|
||||
|
|
@ -310,7 +310,7 @@ impl Value {
|
|||
let elems = (0..len)
|
||||
.map(|_| -> DResult<_> {
|
||||
let key = read_string(rd)?;
|
||||
let value = Value::msg_unpack_inner(rd, &elem)?;
|
||||
let value = Value::msg_unpack_inner(rd, elem)?;
|
||||
Ok((key, value))
|
||||
})
|
||||
.collect::<DResult<BTreeMap<_, _>>>()?;
|
||||
|
|
@ -320,7 +320,7 @@ impl Value {
|
|||
let len = mp::read_array_len(rd)?;
|
||||
|
||||
let elems = (0..len)
|
||||
.map(|_| Value::msg_unpack_inner(rd, &elem))
|
||||
.map(|_| Value::msg_unpack_inner(rd, elem))
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
ValueKind::Set(elems)
|
||||
}
|
||||
|
|
@ -341,7 +341,7 @@ impl Value {
|
|||
let typ = attrs.get(&key).ok_or_else(|| {
|
||||
Diagnostic::error_string(format!("unexpected attribute: '{key}'"))
|
||||
})?;
|
||||
let value = Value::msg_unpack_inner(rd, &typ)?;
|
||||
let value = Value::msg_unpack_inner(rd, typ)?;
|
||||
Ok((key, value))
|
||||
})
|
||||
.collect::<DResult<BTreeMap<_, _>>>()?;
|
||||
|
|
@ -359,7 +359,7 @@ impl Value {
|
|||
|
||||
let elems = elems
|
||||
.iter()
|
||||
.map(|typ| Value::msg_unpack_inner(rd, &typ))
|
||||
.map(|typ| Value::msg_unpack_inner(rd, typ))
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
ValueKind::Tuple(elems)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue