Skip to content

Commit

Permalink
Merge pull request #39 from AlexGacon/master
Browse files Browse the repository at this point in the history
FIX - Deletion of featuretype with Layer API
  • Loading branch information
AlexGacon authored Jun 17, 2024
2 parents 8b09a13 + f9890b5 commit 3c75d5d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions geoserver/resource_geoserver_featuretype.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,28 +314,27 @@ func resourceGeoserverFeatureTypeDelete(d *schema.ResourceData, meta interface{}

layer, errget := client.GetLayer(workspaceName, featureTypeName)
if layer != nil {
log.Printf("[INFO] Deleting Geoserver Layer for: %s", d.Id())

// If there is a matching layer into geoserver, delete it first
err1 := client.DeleteLayer(workspaceName, featureTypeName, true)
if err1 != nil {
return err1
}

err2 := client.DeleteFeatureType(workspaceName, datastoreName, featureTypeName, false)
if err2 != nil {
return err2
}
} else if errget.Error() == "not found" {
log.Printf("[INFO] No Layer found for: %s", d.Id())
// If not, delete only the feature type
err2 := client.DeleteFeatureType(workspaceName, datastoreName, featureTypeName, true)
if err2 != nil {
return err2
}
} else {
log.Printf("[INFO] Erreur détectée: %s", d.Id())
return errget
}

d.SetId("")

return nil
}

Expand Down

0 comments on commit 3c75d5d

Please sign in to comment.