Skip to content

Commit

Permalink
chore: prepare 0.2.0 release (#13)
Browse files Browse the repository at this point in the history
lemaitre-aneo authored Jun 17, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents 15e10d7 + ca2c33e commit 71b27e0
Showing 5 changed files with 55 additions and 38 deletions.
42 changes: 21 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ license = "Apache-2.0"
readme = "README.md"
name = "tf-provider"
repository = "https://github.com/aneoconsulting/tf-provider"
version = "0.2.0-beta-0"
version = "0.2.0"

[profile.release]
strip = "debuginfo"
3 changes: 2 additions & 1 deletion examples/terraform-provider-null.rs
Original file line number Diff line number Diff line change
@@ -109,8 +109,9 @@ impl Resource for NullResource {
Vec<tf_provider::AttributePath>,
)> {
let mut trigger_replace = Vec::new();

if proposed_state.triggers != prior_state.triggers {
trigger_replace.push(AttributePath::new("root"));
trigger_replace.push(AttributePath::new("triggers"));
}

Some((proposed_state, prior_private_state, trigger_replace))
19 changes: 16 additions & 3 deletions src/attribute_path.rs
Original file line number Diff line number Diff line change
@@ -39,12 +39,18 @@ impl AttributePath {
///
/// # Arguments
///
/// * `root` - Name of the root attribute
pub fn new<T: Into<Cow<'static, str>>>(root: T) -> Self {
/// * `name` - Name of the root attribute
pub fn new<T: Into<Cow<'static, str>>>(name: T) -> Self {
Self {
steps: vec![AttributePathStep::Attribute(root.into())],
steps: vec![AttributePathStep::Attribute(name.into())],
}
}

/// Create a new attribute path without any path component
pub fn root() -> Self {
Self::default()
}

/// Create a new attribute path for a function argument
///
/// # Arguments
@@ -55,6 +61,7 @@ impl AttributePath {
steps: vec![AttributePathStep::Index(index)],
}
}

/// Create a new attribute path where the attribute `.name` has been appended
///
/// # Arguments
@@ -64,6 +71,7 @@ impl AttributePath {
self.add_attribute(name);
self
}

/// Create a new attribute path where the access `["key"]` has been appended
///
/// # Arguments
@@ -73,6 +81,7 @@ impl AttributePath {
self.add_key(key);
self
}

/// Create a new attribute path where the access `[idx]` has been appended
///
/// # Arguments
@@ -92,6 +101,7 @@ impl AttributePath {
self.steps.push(AttributePathStep::Attribute(name.into()));
self
}

/// add key access to the path (ie: `["key"]`)
///
/// # Arguments
@@ -101,6 +111,7 @@ impl AttributePath {
self.steps.push(AttributePathStep::Key(key.into()));
self
}

/// add index access to the path (ie: `[idx]`)
///
/// # Arguments
@@ -110,6 +121,7 @@ impl AttributePath {
self.steps.push(AttributePathStep::Index(idx.into()));
self
}

/// Add step to the path
///
/// # Arguments
@@ -119,6 +131,7 @@ impl AttributePath {
self.steps.push(step);
self
}

/// Add multiple steps into the path
///
/// # Arguments
27 changes: 15 additions & 12 deletions src/resource.rs
Original file line number Diff line number Diff line change
@@ -174,8 +174,8 @@ pub trait Resource: Send + Sync {
///
/// # Remarks
///
/// The return is ignored if there is an error in diagnostics.
/// If the return is [`None`], an ad-hoc error is added to diagnostics.
/// Return must be [`Some`] if the resource was created, even if there was errors while creating the resource.
async fn create<'a>(
&self,
diags: &mut Diagnostics,
@@ -198,8 +198,8 @@ pub trait Resource: Send + Sync {
///
/// # Remarks
///
/// The return is ignored if there is an error in diagnostics.
/// If the return is [`None`], an ad-hoc error is added to diagnostics.
/// If the return is [`None`], an ad-hoc error is added to diagnostics, and the resource state is kept unchanged.
/// Return must be [`Some`] if the resource was updated, even if there was errors while updated the resource.
async fn update<'a>(
&self,
diags: &mut Diagnostics,
@@ -240,8 +240,8 @@ pub trait Resource: Send + Sync {
///
/// # Remarks
///
/// The return is ignored if there is an error in diagnostics.
/// If the return is [`None`], an ad-hoc error is added to diagnostics.
/// Return must be [`Some`] if the resource was imported, even if there was errors while importing the resource.
async fn import<'a>(
&self,
diags: &mut Diagnostics,
@@ -262,8 +262,11 @@ pub trait Resource: Send + Sync {
///
/// # Remarks
///
/// The return is ignored if there is an error in diagnostics.
/// If the return is [`None`], an ad-hoc error is added to diagnostics.
/// If the return is [`None`], an ad-hoc error is added to diagnostics, and the resource state is kept unchanged.
/// Return must be [`Some`] if the resource was upgraded, even if there was errors while upgraded the resource.
///
/// Because the schema of the resource might have changed,
/// the prior state must be deserialized explicitely.
async fn upgrade<'a>(
&self,
diags: &mut Diagnostics,
@@ -411,8 +414,8 @@ pub trait DynamicResource: Send + Sync {
///
/// # Remarks
///
/// The return is ignored if there is an error in diagnostics.
/// If the return is [`None`], an ad-hoc error is added to diagnostics.
/// Return must be [`Some`] if the resource was created, even if there was errors while creating the resource.
async fn create(
&self,
diags: &mut Diagnostics,
@@ -435,8 +438,8 @@ pub trait DynamicResource: Send + Sync {
///
/// # Remarks
///
/// The return is ignored if there is an error in diagnostics.
/// If the return is [`None`], an ad-hoc error is added to diagnostics.
/// If the return is [`None`], an ad-hoc error is added to diagnostics, and the resource state is kept unchanged.
/// Return must be [`Some`] if the resource was updated, even if there was errors while updated the resource.
async fn update(
&self,
diags: &mut Diagnostics,
@@ -477,8 +480,8 @@ pub trait DynamicResource: Send + Sync {
///
/// # Remarks
///
/// The return is ignored if there is an error in diagnostics.
/// If the return is [`None`], an ad-hoc error is added to diagnostics.
/// Return must be [`Some`] if the resource was imported, even if there was errors while importing the resource.
async fn import(&self, diags: &mut Diagnostics, id: String) -> Option<(RawValue, Vec<u8>)> {
_ = id;
diags.root_error_short("Import is not supported");
@@ -495,8 +498,8 @@ pub trait DynamicResource: Send + Sync {
///
/// # Remarks
///
/// The return is ignored if there is an error in diagnostics.
/// If the return is [`None`], an ad-hoc error is added to diagnostics.
/// If the return is [`None`], an ad-hoc error is added to diagnostics, and the resource state is kept unchanged.
/// Return must be [`Some`] if the resource was upgraded, even if there was errors while upgraded the resource.
async fn upgrade(
&self,
diags: &mut Diagnostics,

0 comments on commit 71b27e0

Please sign in to comment.