diff --git a/geoserver/resource_geoserver_datastore.go b/geoserver/resource_geoserver_datastore.go index fe8c277..3217cb8 100644 --- a/geoserver/resource_geoserver_datastore.go +++ b/geoserver/resource_geoserver_datastore.go @@ -98,10 +98,15 @@ func resourceGeoserverDatastoreRead(d *schema.ResourceData, meta interface{}) er client := meta.(*Config).Client() datastore, err := client.GetDatastore(workspaceName, datastoreName) - if err != nil { + if err != nil && err.Error() != "Not Found" { return err } + if datastore == nil { + d.SetId("") + return nil + } + d.Set("workspace_name", datastore.Workspace.Name) d.Set("name", datastore.Name) d.Set("description", datastore.Description) diff --git a/geoserver/resource_geoserver_featuretype.go b/geoserver/resource_geoserver_featuretype.go index 97c3251..6b73609 100644 --- a/geoserver/resource_geoserver_featuretype.go +++ b/geoserver/resource_geoserver_featuretype.go @@ -226,10 +226,14 @@ func resourceGeoserverFeatureTypeRead(d *schema.ResourceData, meta interface{}) client := meta.(*Config).Client() featureType, err := client.GetFeatureType(workspaceName, datastoreName, featureTypeName) - if err != nil { + if err != nil && err.Error() != "Not Found" { return err } + if featureType == nil { + d.SetId("") + return nil + } d.Set("workspace_name", workspaceName) d.Set("datastore_name", datastoreName) d.Set("name", featureType.Name) diff --git a/geoserver/resource_geoserver_workspace.go b/geoserver/resource_geoserver_workspace.go index cd840fe..e611060 100644 --- a/geoserver/resource_geoserver_workspace.go +++ b/geoserver/resource_geoserver_workspace.go @@ -65,10 +65,15 @@ func resourceGeoserverWorkspaceRead(d *schema.ResourceData, meta interface{}) er client := meta.(*Config).Client() workspace, err := client.GetWorkspace(d.Id()) - if err != nil { + if err != nil && err.Error() != "Not Found" { return err } + if workspace == nil { + d.SetId("") + return nil + } + d.Set("name", workspace.Name) d.Set("isolated", workspace.Isolated)