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

Fix: nil pointer on pi_key #3133

Merged
merged 1 commit into from
Nov 9, 2021
Merged
Changes from all commits
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
7 changes: 5 additions & 2 deletions ibm/resource_ibm_pi_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,16 @@ func resourceIBMPIKeyExists(d *schema.ResourceData, meta interface{}) (bool, err
client := st.NewIBMPIKeyClient(sess, powerinstanceid)

key, err := client.Get(parts[1], powerinstanceid)
if err != nil {
if err != nil || key == nil {
if apiErr, ok := err.(bmxerror.RequestFailure); ok {
if apiErr.StatusCode() == 404 {
return false, nil
}
}
return false, fmt.Errorf("Error communicating with the API: %s", err)
}
return *key.Name == name, nil
if key.Name != nil {
return *key.Name == name, nil
}
return false, nil
}