weldr: Add support for the v1 API to /projects/source/delete

This changes store.DeleteSource to DeleteSourceByName for v0 use and
DeleteSourceByID for v1 usage.

It includes a new client function DeleteSourceV1, adds a new test, and
converts the tests for the previous Source V1 API commits to use
DeleteSourceV1.
This commit is contained in:
Brian C. Lane 2020-04-30 15:45:54 -07:00 committed by Tom Gundersen
parent 982d292a96
commit 37258803b4
4 changed files with 61 additions and 12 deletions

View file

@ -416,8 +416,22 @@ func (s *Store) PushSource(key string, source SourceConfig) {
})
}
// DeleteSource removes a SourceConfig from store.Sources
func (s *Store) DeleteSource(key string) {
// DeleteSourceByName removes a SourceConfig from store.Sources using the .Name field
func (s *Store) DeleteSourceByName(name string) {
// FIXME: handle or comment this possible error
_ = s.change(func() error {
for key := range s.sources {
if s.sources[key].Name == name {
delete(s.sources, key)
return nil
}
}
return nil
})
}
// DeleteSourceByID removes a SourceConfig from store.Sources using the ID
func (s *Store) DeleteSourceByID(key string) {
// FIXME: handle or comment this possible error
_ = s.change(func() error {
delete(s.sources, key)