in ec/ecresource/deploymentresource/elasticsearch/v2/elasticsearch_snapshot.go [81:129]
func elasticsearchSnapshotPayload(ctx context.Context, srcObj attr.Value, model *models.ElasticsearchClusterSettings, state *ElasticsearchTF) (*models.ElasticsearchClusterSettings, diag.Diagnostics) {
var snapshot ElasticsearchSnapshotTF
if srcObj.IsNull() || srcObj.IsUnknown() {
return model, nil
}
// Only put snapshot updates into the payload, if the plan is making changes to the snapshot settings
// (To avoid overwriting changes made outside, i.e. with the elasticstack provider)
if state != nil && state.Snapshot.Equal(srcObj) {
return model, nil
}
if diags := tfsdk.ValueAs(ctx, srcObj, &snapshot); diags.HasError() {
return model, diags
}
if model == nil {
model = &models.ElasticsearchClusterSettings{}
}
model.Snapshot = &models.ClusterSnapshotSettings{
Enabled: &snapshot.Enabled,
}
if snapshot.Repository.IsNull() || snapshot.Repository.IsUnknown() {
return model, nil
}
var repo ElasticsearchSnapshotRepositoryInfoTF
if diags := tfsdk.ValueAs(ctx, snapshot.Repository, &repo); diags.HasError() {
return model, diags
}
if repo.Reference.IsNull() || repo.Reference.IsUnknown() {
return model, nil
}
var reference ElasticsearchSnapshotRepositoryReferenceTF
if diags := tfsdk.ValueAs(ctx, repo.Reference, &reference); diags.HasError() {
return model, diags
}
model.Snapshot.Repository = &models.ClusterSnapshotRepositoryInfo{
Reference: &models.ClusterSnapshotRepositoryReference{
RepositoryName: reference.RepositoryName.ValueString(),
},
}
return model, nil
}