pub async fn create_or_replace<T>(
client: &Client,
namespace: &str,
resource: &T,
) -> Result<()>where
T: Resource<DynamicType = (), Scope = NamespaceResourceScope> + ResourceExt + Clone + Debug + Serialize + for<'de> Deserialize<'de>,Expand description
Create or update a resource using replace strategy.
This function checks if the resource exists. If it does, it replaces the entire resource. Otherwise, it creates the resource.
The replace strategy is suitable for resources like Deployments where you want to completely replace the specification rather than merge changes.
§Arguments
client- Kubernetes API clientnamespace- Namespace where the resource should be created/updatedresource- The resource to create or update
§Returns
Returns Ok(()) if the operation succeeded.
§Errors
Returns an error if:
- The resource has no name in its metadata
- API operations fail
§Example
create_or_replace(client, namespace, &deploy).await.unwrap();