Skip to content

Commit 9dd341e

Browse files
committed
fix referencing potentially nil http response
1 parent e0145f6 commit 9dd341e

11 files changed

+11
-11
lines changed

bitbucket/resource_deploy_key.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func resourceDeployKeysRead(ctx context.Context, d *schema.ResourceData, m inter
107107

108108
deployKey, res, err := deployApi.RepositoriesWorkspaceRepoSlugDeployKeysKeyIdGet(c.AuthContext, keyId, repo, workspace)
109109

110-
if res.StatusCode == http.StatusNotFound {
110+
if res != nil && res.StatusCode == http.StatusNotFound {
111111
log.Printf("[WARN] Deploy Key (%s) not found, removing from state", d.Id())
112112
d.SetId("")
113113
return nil

bitbucket/resource_deployment_variable.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func resourceDeploymentVariableRead(ctx context.Context, d *schema.ResourceData,
107107

108108
rvRes, res, err := pipeApi.GetDeploymentVariables(c.AuthContext, workspace, repoSlug, deployment, nil)
109109

110-
if res.StatusCode == http.StatusNotFound {
110+
if res != nil && res.StatusCode == http.StatusNotFound {
111111
log.Printf("[WARN] Deployment Variable (%s) not found, removing from state", d.Id())
112112
d.SetId("")
113113
return nil

bitbucket/resource_forked_repository.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ func resourceForkedRepositoryRead(ctx context.Context, d *schema.ResourceData, m
267267

268268
repoRes, res, err := repoApi.RepositoriesWorkspaceRepoSlugGet(c.AuthContext, repoSlug, workspace)
269269

270-
if res.StatusCode == http.StatusNotFound {
270+
if res != nil && res.StatusCode == http.StatusNotFound {
271271
log.Printf("[WARN] Repository (%s) not found, removing from state", d.Id())
272272
d.SetId("")
273273
return nil

bitbucket/resource_pipeline_schedule.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ func resourcePipelineScheduleRead(ctx context.Context, d *schema.ResourceData, m
150150

151151
schedule, res, err := pipeApi.GetRepositoryPipelineSchedule(c.AuthContext, workspace, repo, uuid)
152152

153-
if res.StatusCode == http.StatusNotFound {
153+
if res != nil && res.StatusCode == http.StatusNotFound {
154154
log.Printf("[WARN] Pipeline Schedule (%s) not found, removing from state", d.Id())
155155
d.SetId("")
156156
return nil

bitbucket/resource_pipeline_ssh_key.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func resourcePipelineSshKeysRead(ctx context.Context, d *schema.ResourceData, m
7575

7676
key, res, err := pipeApi.GetRepositoryPipelineSshKeyPair(c.AuthContext, workspace, repo)
7777

78-
if res.StatusCode == http.StatusNotFound {
78+
if res != nil && res.StatusCode == http.StatusNotFound {
7979
log.Printf("[WARN] Pipeline Ssh Key (%s) not found, removing from state", d.Id())
8080
d.SetId("")
8181
return nil

bitbucket/resource_pipeline_ssh_known_host.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func resourcePipelineSshKnownHostsRead(ctx context.Context, d *schema.ResourceDa
121121

122122
host, res, err := pipeApi.GetRepositoryPipelineKnownHost(c.AuthContext, workspace, repo, uuid)
123123

124-
if res.StatusCode == http.StatusNotFound {
124+
if res != nil && res.StatusCode == http.StatusNotFound {
125125
log.Printf("[WARN] Pipeline Ssh known host (%s) not found, removing from state", d.Id())
126126
d.SetId("")
127127
return nil

bitbucket/resource_project.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ func resourceProjectRead(ctx context.Context, d *schema.ResourceData, m interfac
198198

199199
projRes, res, err := projectApi.WorkspacesWorkspaceProjectsProjectKeyGet(c.AuthContext, projectKey, d.Get("owner").(string))
200200

201-
if res.StatusCode == http.StatusNotFound {
201+
if res != nil && res.StatusCode == http.StatusNotFound {
202202
log.Printf("[WARN] Project (%s) not found, removing from state", d.Id())
203203
d.SetId("")
204204
return nil

bitbucket/resource_repository.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ func resourceRepositoryRead(ctx context.Context, d *schema.ResourceData, m inter
345345

346346
repoRes, res, err := repoApi.RepositoriesWorkspaceRepoSlugGet(c.AuthContext, repoSlug, workspace)
347347

348-
if res.StatusCode == http.StatusNotFound {
348+
if res != nil && res.StatusCode == http.StatusNotFound {
349349
log.Printf("[WARN] Repository (%s) not found, removing from state", d.Id())
350350
d.SetId("")
351351
return nil

bitbucket/resource_repository_variable.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func resourceRepositoryVariableRead(ctx context.Context, d *schema.ResourceData,
105105

106106
rvRes, res, err := pipeApi.GetRepositoryPipelineVariable(c.AuthContext, workspace, repoSlug, d.Get("uuid").(string))
107107

108-
if res.StatusCode == http.StatusNotFound {
108+
if res != nil && res.StatusCode == http.StatusNotFound {
109109
log.Printf("[WARN] Repository Variable (%s) not found, removing from state", d.Id())
110110
d.SetId("")
111111
return nil

bitbucket/resource_ssh_key.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func resourceSshKeysRead(ctx context.Context, d *schema.ResourceData, m interfac
9191

9292
sshKeyReq, res, err := sshApi.UsersSelectedUserSshKeysKeyIdGet(c.AuthContext, keyId, user)
9393

94-
if res.StatusCode == http.StatusNotFound {
94+
if res != nil && res.StatusCode == http.StatusNotFound {
9595
log.Printf("[WARN] SSH Key (%s) not found, removing from state", d.Id())
9696
d.SetId("")
9797
return nil

0 commit comments

Comments
 (0)