mirror of
https://github.com/Noratrieb/terustform.git
synced 2026-01-14 08:30:13 +01:00
small improvements
This commit is contained in:
parent
bf7835162d
commit
8394e27f60
5 changed files with 19 additions and 18 deletions
|
|
@ -40,27 +40,23 @@ impl CorsClient {
|
|||
}
|
||||
|
||||
pub async fn get_hugo(&self) -> Result<String> {
|
||||
Ok(do_request(self.client.get(format!("{URL}/hugo")))
|
||||
do_request(self.client.get(format!("{URL}/hugo")))
|
||||
.await?
|
||||
.text()
|
||||
.await
|
||||
.wrap_err("failed to get hugo")?)
|
||||
.wrap_err("failed to get hugo")
|
||||
}
|
||||
|
||||
pub async fn get_class(&self, id: &str) -> Result<dto::Class> {
|
||||
Ok(
|
||||
do_request_body(self.client.get(format!("{URL}/classes/{id}")))
|
||||
.await
|
||||
.wrap_err("failed to get class")?,
|
||||
)
|
||||
do_request_body(self.client.get(format!("{URL}/classes/{id}")))
|
||||
.await
|
||||
.wrap_err("failed to get class")
|
||||
}
|
||||
|
||||
pub async fn post_class(&self, class: &dto::Class) -> Result<dto::Class> {
|
||||
Ok(
|
||||
do_request_body(self.client.post(format!("{URL}/classes")).json(class))
|
||||
.await
|
||||
.wrap_err("creating class")?,
|
||||
)
|
||||
do_request_body(self.client.post(format!("{URL}/classes")).json(class))
|
||||
.await
|
||||
.wrap_err("creating class")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -66,13 +66,13 @@ pub trait EyreExt<T> {
|
|||
|
||||
impl<T> EyreExt<T> for Result<T, eyre::Report> {
|
||||
fn eyre_to_tf(self) -> DResult<T> {
|
||||
self.map_err(|e| Diagnostic::error_string(format!("{:?}", e)).into())
|
||||
self.map_err(|e| Diagnostic::error_string(format!("{e:?}")).into())
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: std::error::Error + std::fmt::Debug> From<E> for Diagnostic {
|
||||
fn from(value: E) -> Self {
|
||||
Self::error_string(format!("{:?}", value))
|
||||
Self::error_string(format!("{value:?}"))
|
||||
}
|
||||
}
|
||||
impl<E: std::error::Error + std::fmt::Debug> From<E> for Diagnostics {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ pub fn generate_cert() -> Result<(tonic::transport::Identity, rcgen::Certificate
|
|||
];
|
||||
params.is_ca = IsCa::Ca(rcgen::BasicConstraints::Unconstrained);
|
||||
params.not_before = time::OffsetDateTime::now_utc().saturating_add(Duration::seconds(-30));
|
||||
params.not_after = time::OffsetDateTime::now_utc().saturating_add(Duration::seconds(262980));
|
||||
params.not_after = time::OffsetDateTime::now_utc().saturating_add(Duration::seconds(262_980));
|
||||
let mut dn = DistinguishedName::new();
|
||||
dn.push(DnType::OrganizationName, "HashiCorp");
|
||||
dn.push(DnType::CommonName, "localhost");
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
#![allow(unused_variables, unused_imports)]
|
||||
|
||||
|
||||
#[allow(warnings)]
|
||||
pub mod tfplugin6 {
|
||||
tonic::include_proto!("tfplugin6");
|
||||
}
|
||||
|
||||
#[allow(warnings)]
|
||||
pub mod plugin {
|
||||
tonic::include_proto!("plugin");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ impl Type {
|
|||
if !optionals.is_empty() {
|
||||
parts.push(Value::Array(
|
||||
optionals.iter().map(|v| Value::String(v.clone())).collect(),
|
||||
))
|
||||
));
|
||||
}
|
||||
|
||||
Value::Array(parts)
|
||||
|
|
@ -302,7 +302,7 @@ impl Value {
|
|||
rd.set_position(start);
|
||||
// TODO: Handle unknown values better
|
||||
// https://github.com/hashicorp/terraform/blob/main/docs/plugin-protocol/object-wire-format.md#schemaattribute-mapping-rules-for-messagepack
|
||||
if let Ok(_) = mp::read_fixext1(rd) {
|
||||
if mp::read_fixext1(rd).is_ok() {
|
||||
return Ok(Value::Unknown);
|
||||
}
|
||||
rd.set_position(start);
|
||||
|
|
@ -388,7 +388,10 @@ impl Value {
|
|||
for expected_attr in attrs.keys() {
|
||||
let is_ok = elems.contains_key(expected_attr);
|
||||
if !is_ok && !optionals.contains(expected_attr) {
|
||||
return Err(Diagnostic::error_string(format!("expected attribute '{expected_attr}', but it was not present")).into())
|
||||
return Err(Diagnostic::error_string(format!(
|
||||
"expected attribute '{expected_attr}', but it was not present"
|
||||
))
|
||||
.into());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue