Skip to content

Commit

Permalink
Improve management of errors for cilium_config_resource.go
Browse files Browse the repository at this point in the history
  • Loading branch information
littlejo committed Dec 11, 2023
1 parent 279a455 commit 98a63eb
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions internal/provider/cilium_config_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (r *CiliumConfigResource) Create(ctx context.Context, req resource.CreateRe

check := config.NewK8sConfig(k8sClient, params)
if err := check.Set(context.Background(), key, value, params); err != nil {
fmt.Printf("Unable to set config: %s", err)
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to set config: %s", err))
return
}

Expand Down Expand Up @@ -186,7 +186,7 @@ func (r *CiliumConfigResource) Read(ctx context.Context, req resource.ReadReques
check := config.NewK8sConfig(k8sClient, params)
out, err := check.View(context.Background())
if err != nil {
fmt.Printf("Unable to view config: %s", err)
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to view config: %s", err))
return
}

Expand Down Expand Up @@ -228,7 +228,7 @@ func (r *CiliumConfigResource) Update(ctx context.Context, req resource.UpdateRe

check := config.NewK8sConfig(k8sClient, params)
if err := check.Set(context.Background(), key, value, params); err != nil {
fmt.Printf("Unable to set config: %s", err)
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to set config: %s", err))
return
}

Expand Down Expand Up @@ -257,7 +257,8 @@ func (r *CiliumConfigResource) Delete(ctx context.Context, req resource.DeleteRe

check := config.NewK8sConfig(k8sClient, params)
if err := check.Delete(context.Background(), key, params); err != nil {
fmt.Printf("Unable to delete config: %s", err)
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to delete config: %s", err))
return
}
}

Expand Down

0 comments on commit 98a63eb

Please sign in to comment.