Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

note field on service_dependency correctly takes empty string #537

Merged
merged 2 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changes/unreleased/Bugfix-20241121-081407.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kind: Bugfix
body: '"note" field on service_dependency correctly takes empty string'
time: 2024-11-21T08:14:07.471282-06:00
11 changes: 7 additions & 4 deletions opslevel/resource_opslevel_service_dependency.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,16 @@ func (r *ServiceDependencyResource) Create(ctx context.Context, req resource.Cre
return
}

serviceDependency, err := r.client.CreateServiceDependency(opslevel.ServiceDependencyCreateInput{
serviceDependencyCreateInput := opslevel.ServiceDependencyCreateInput{
DependencyKey: opslevel.ServiceDependencyKey{
DestinationIdentifier: opslevel.NewIdentifier(planModel.DependsUpon.ValueString()),
SourceIdentifier: opslevel.NewIdentifier(planModel.Service.ValueString()),
},
Notes: planModel.Note.ValueStringPointer(),
})
}
if !planModel.Note.IsNull() && !planModel.Note.IsUnknown() {
serviceDependencyCreateInput.Notes = planModel.Note.ValueStringPointer()
}
serviceDependency, err := r.client.CreateServiceDependency(serviceDependencyCreateInput)
if err != nil || serviceDependency == nil {
resp.Diagnostics.AddError("opslevel client error", fmt.Sprintf("Unable to create serviceDependency, got error: %s", err))
return
Expand Down Expand Up @@ -200,7 +203,7 @@ func extractServiceDependency(id string, serviceDependencies opslevel.ServiceDep

func (r *ServiceDependencyResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
resp.Diagnostics.AddError("terraform plugin error",
"property assignments should never be updated, only replaced.\nplease file a bug report including your .tf file at: github.com/OpsLevel/terraform-provider-opslevel")
"service dependencies should never be updated, only replaced.\nplease file a bug report including your .tf file at: github.com/OpsLevel/terraform-provider-opslevel")
}

func (r *ServiceDependencyResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {
Expand Down
Loading