diff --git a/cmd/purge.go b/cmd/purge.go index d825753..cd34096 100644 --- a/cmd/purge.go +++ b/cmd/purge.go @@ -38,6 +38,11 @@ var errPurgeNoConfirmation = exit.Error{ ExitCode: exit.ExitGeneric, } +var errPurgeGeneric = exit.Error{ + Message: "Unable to purge instance %s: %s", + ExitCode: exit.ExitGeneric, +} + func (p purge) Run(context wisski_distillery.Context) error { dis := context.Environment slug := p.Positionals.Slug @@ -88,7 +93,7 @@ func (p purge) Run(context wisski_distillery.Context) error { return nil }, context.IOStream, "Purging instance-specific resources"); err != nil { - return errProvisionGeneric.WithMessageF(slug, err) + return errPurgeGeneric.WithMessageF(slug, err) } // remove from bookkeeping @@ -98,7 +103,7 @@ func (p purge) Run(context wisski_distillery.Context) error { } // remove the filesystem - logging.LogMessage(context.IOStream, "Remove lock data", instance.FilesystemBase) + logging.LogMessage(context.IOStream, "Remove lock data") if instance.Locker().TryUnlock() { context.EPrintln("instance was not locked") } diff --git a/internal/dis/component/triplestore/database.go b/internal/dis/component/triplestore/database.go index 9423ba1..33b19cd 100644 --- a/internal/dis/component/triplestore/database.go +++ b/internal/dis/component/triplestore/database.go @@ -99,25 +99,27 @@ func (ts Triplestore) Wait() error { }, ts.PollContext, ts.PollInterval) } -// TriplestorePurgeUser deletes the specified user from the triplestore +// PurgeUser deletes the specified user from the triplestore. +// When the user does not exist, returns no error. func (ts Triplestore) PurgeUser(user string) error { res, err := ts.OpenRaw("DELETE", "/rest/security/users/"+user, nil, "", "") if err != nil { return err } - if res.StatusCode != http.StatusNoContent { + if res.StatusCode != http.StatusNoContent && res.StatusCode != http.StatusNotFound { return errors.Errorf("Delete returned code %d", res.StatusCode) } return nil } -// TriplestorePurgeRepo deletes the specified repo from the triplestore +// PurgeRepo deletes the specified repo from the triplestore. +// When the repo does not exist, returns no error. func (ts Triplestore) PurgeRepo(repo string) error { res, err := ts.OpenRaw("DELETE", "/rest/repositories/"+repo, nil, "", "") if err != nil { return err } - if res.StatusCode != http.StatusOK { + if res.StatusCode != http.StatusOK && res.StatusCode != http.StatusNotFound { return errors.Errorf("Delete returned code %d", res.StatusCode) } return nil