Skip to content

Commit

Permalink
delete source even if config is deprecated (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
dariakharlan authored Jan 31, 2020
1 parent 0ee100c commit ed6cd3b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
14 changes: 9 additions & 5 deletions agent/src/agent/source/abstract_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,19 @@ def create(self):

self.save()

def delete(self):
if not self.exists(self.name):
raise SourceNotExists(f"Source config {self.name} doesn't exist")
@classmethod
def delete_source(cls, source_name):
if not cls.exists(source_name):
raise SourceNotExists(f"Source config {source_name} doesn't exist")

pipelines = pipeline.get_pipelines(source_name=self.name)
pipelines = pipeline.get_pipelines(source_name=source_name)
if pipelines:
raise SourceException(f"Can't delete. Source is used by {', '.join([p.id for p in pipelines])} pipelines")

os.remove(self.file_path)
os.remove(cls.get_file_path(source_name))

def delete(self):
self.delete_source(self.name)

@abstractmethod
def prompt(self, default_config, advanced=False):
Expand Down
3 changes: 1 addition & 2 deletions agent/src/agent/source/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,7 @@ def delete(name):
"""
Delete source
"""
source_instance = source.load_object(name)
source_instance.delete()
source.Source.delete_source(name)


source_group.add_command(create)
Expand Down

0 comments on commit ed6cd3b

Please sign in to comment.