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);
|
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
|
let class = self
|
||||||
.client
|
.client
|
||||||
.get_class(&model.id.expect_known(AttrPath::attr("id"))?)
|
.get_class(model.id.expect_known(AttrPath::attr("id"))?)
|
||||||
.await
|
.await
|
||||||
.wrap_err("failed to get class")
|
.wrap_err("failed to get class")
|
||||||
.eyre_to_tf()?;
|
.eyre_to_tf()?;
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use crate::{values::Type, AttrPathSegment, Attribute, Diagnostics, Mode, Schema}
|
||||||
use super::grpc::tfplugin6;
|
use super::grpc::tfplugin6;
|
||||||
|
|
||||||
impl Schema {
|
impl Schema {
|
||||||
pub(crate) fn to_tfplugin(self) -> tfplugin6::Schema {
|
pub(crate) fn into_tfplugin(self) -> tfplugin6::Schema {
|
||||||
tfplugin6::Schema {
|
tfplugin6::Schema {
|
||||||
version: 1,
|
version: 1,
|
||||||
block: Some(tfplugin6::schema::Block {
|
block: Some(tfplugin6::schema::Block {
|
||||||
|
|
@ -11,7 +11,7 @@ impl Schema {
|
||||||
attributes: self
|
attributes: self
|
||||||
.attributes
|
.attributes
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(name, attr)| attr.to_tfplugin(name))
|
.map(|(name, attr)| attr.into_tfplugin(name))
|
||||||
.collect(),
|
.collect(),
|
||||||
block_types: vec![],
|
block_types: vec![],
|
||||||
description: self.description,
|
description: self.description,
|
||||||
|
|
@ -23,7 +23,7 @@ impl Schema {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Attribute {
|
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 {
|
let mut attr = tfplugin6::schema::Attribute {
|
||||||
name,
|
name,
|
||||||
r#type: vec![],
|
r#type: vec![],
|
||||||
|
|
@ -71,7 +71,7 @@ impl Attribute {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Diagnostics {
|
impl Diagnostics {
|
||||||
pub(crate) fn to_tfplugin_diags(self) -> Vec<tfplugin6::Diagnostic> {
|
pub(crate) fn into_tfplugin_diags(self) -> Vec<tfplugin6::Diagnostic> {
|
||||||
self.diags
|
self.diags
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|err| tfplugin6::Diagnostic {
|
.map(|err| tfplugin6::Diagnostic {
|
||||||
|
|
|
||||||
|
|
@ -87,17 +87,17 @@ impl<P: Provider> ProviderHandler<P> {
|
||||||
mk_ds,
|
mk_ds,
|
||||||
mk_rs,
|
mk_rs,
|
||||||
} => (provider, 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"),
|
ProviderState::Configured { .. } => unreachable!("called configure twice"),
|
||||||
};
|
};
|
||||||
let config = match parse_dynamic_value(config, &provider.schema().typ()) {
|
let config = match parse_dynamic_value(config, &provider.schema().typ()) {
|
||||||
Ok(config) => config,
|
Ok(config) => config,
|
||||||
Err(errs) => return errs.to_tfplugin_diags(),
|
Err(errs) => return errs.into_tfplugin_diags(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let data = match provider.configure(config).await {
|
let data = match provider.configure(config).await {
|
||||||
Ok(data) => data,
|
Ok(data) => data,
|
||||||
Err(errs) => return errs.to_tfplugin_diags(),
|
Err(errs) => return errs.into_tfplugin_diags(),
|
||||||
};
|
};
|
||||||
let mut diags = vec![];
|
let mut diags = vec![];
|
||||||
|
|
||||||
|
|
@ -109,7 +109,7 @@ impl<P: Provider> ProviderHandler<P> {
|
||||||
Ok(ds) => {
|
Ok(ds) => {
|
||||||
data_sources.insert(ds_name.clone(), 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) => {
|
Ok(rs) => {
|
||||||
resources.insert(rs_name.clone(), 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 {
|
return Schemas {
|
||||||
resources: HashMap::new(),
|
resources: HashMap::new(),
|
||||||
data_sources: HashMap::new(),
|
data_sources: HashMap::new(),
|
||||||
diagnostics: diags.clone().to_tfplugin_diags(),
|
diagnostics: diags.clone().into_tfplugin_diags(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ProviderState::Configured { .. } => {
|
ProviderState::Configured { .. } => {
|
||||||
|
|
@ -157,14 +157,14 @@ impl<P: Provider> ProviderHandler<P> {
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(name, ds)| {
|
.map(|(name, ds)| {
|
||||||
tracing::debug!(?name, "Initializing data source");
|
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>>();
|
.collect::<HashMap<String, tfplugin6::Schema>>();
|
||||||
let resources = mk_rs
|
let resources = mk_rs
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(name, ds)| {
|
.map(|(name, ds)| {
|
||||||
tracing::debug!(?name, "Initializing resources");
|
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>>();
|
.collect::<HashMap<String, tfplugin6::Schema>>();
|
||||||
|
|
||||||
|
|
@ -187,7 +187,7 @@ impl<P: Provider> ProviderHandler<P> {
|
||||||
unreachable!("must be set up before calling data sources")
|
unreachable!("must be set up before calling data sources")
|
||||||
}
|
}
|
||||||
ProviderState::Failed { diags } => {
|
ProviderState::Failed { diags } => {
|
||||||
return (None, diags.clone().to_tfplugin_diags())
|
return (None, diags.clone().into_tfplugin_diags())
|
||||||
}
|
}
|
||||||
ProviderState::Configured {
|
ProviderState::Configured {
|
||||||
data_sources,
|
data_sources,
|
||||||
|
|
@ -201,7 +201,7 @@ impl<P: Provider> ProviderHandler<P> {
|
||||||
let config = match parse_dynamic_value(config, &typ) {
|
let config = match parse_dynamic_value(config, &typ) {
|
||||||
Ok(value) => value,
|
Ok(value) => value,
|
||||||
Err(errs) => {
|
Err(errs) => {
|
||||||
return (None, errs.to_tfplugin_diags());
|
return (None, errs.into_tfplugin_diags());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -214,7 +214,7 @@ impl<P: Provider> ProviderHandler<P> {
|
||||||
}),
|
}),
|
||||||
vec![],
|
vec![],
|
||||||
),
|
),
|
||||||
Err(errs) => (None, errs.to_tfplugin_diags()),
|
Err(errs) => (None, errs.into_tfplugin_diags()),
|
||||||
};
|
};
|
||||||
|
|
||||||
(state, diagnostics)
|
(state, diagnostics)
|
||||||
|
|
|
||||||
|
|
@ -300,7 +300,7 @@ impl Value {
|
||||||
let len = mp::read_array_len(rd)?;
|
let len = mp::read_array_len(rd)?;
|
||||||
|
|
||||||
let elems = (0..len)
|
let elems = (0..len)
|
||||||
.map(|_| Value::msg_unpack_inner(rd, &elem))
|
.map(|_| Value::msg_unpack_inner(rd, elem))
|
||||||
.collect::<Result<Vec<_>, _>>()?;
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
ValueKind::List(elems)
|
ValueKind::List(elems)
|
||||||
}
|
}
|
||||||
|
|
@ -310,7 +310,7 @@ impl Value {
|
||||||
let elems = (0..len)
|
let elems = (0..len)
|
||||||
.map(|_| -> DResult<_> {
|
.map(|_| -> DResult<_> {
|
||||||
let key = read_string(rd)?;
|
let key = read_string(rd)?;
|
||||||
let value = Value::msg_unpack_inner(rd, &elem)?;
|
let value = Value::msg_unpack_inner(rd, elem)?;
|
||||||
Ok((key, value))
|
Ok((key, value))
|
||||||
})
|
})
|
||||||
.collect::<DResult<BTreeMap<_, _>>>()?;
|
.collect::<DResult<BTreeMap<_, _>>>()?;
|
||||||
|
|
@ -320,7 +320,7 @@ impl Value {
|
||||||
let len = mp::read_array_len(rd)?;
|
let len = mp::read_array_len(rd)?;
|
||||||
|
|
||||||
let elems = (0..len)
|
let elems = (0..len)
|
||||||
.map(|_| Value::msg_unpack_inner(rd, &elem))
|
.map(|_| Value::msg_unpack_inner(rd, elem))
|
||||||
.collect::<Result<Vec<_>, _>>()?;
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
ValueKind::Set(elems)
|
ValueKind::Set(elems)
|
||||||
}
|
}
|
||||||
|
|
@ -341,7 +341,7 @@ impl Value {
|
||||||
let typ = attrs.get(&key).ok_or_else(|| {
|
let typ = attrs.get(&key).ok_or_else(|| {
|
||||||
Diagnostic::error_string(format!("unexpected attribute: '{key}'"))
|
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))
|
Ok((key, value))
|
||||||
})
|
})
|
||||||
.collect::<DResult<BTreeMap<_, _>>>()?;
|
.collect::<DResult<BTreeMap<_, _>>>()?;
|
||||||
|
|
@ -359,7 +359,7 @@ impl Value {
|
||||||
|
|
||||||
let elems = elems
|
let elems = elems
|
||||||
.iter()
|
.iter()
|
||||||
.map(|typ| Value::msg_unpack_inner(rd, &typ))
|
.map(|typ| Value::msg_unpack_inner(rd, typ))
|
||||||
.collect::<Result<Vec<_>, _>>()?;
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
ValueKind::Tuple(elems)
|
ValueKind::Tuple(elems)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue