@@ -61,17 +61,13 @@ def get_git_info(self):
6161 repo_slug = "SumoLogic/sumologic-azure-function"
6262 try :
6363 branch_name = subprocess .check_output ("git branch --show-current" , stderr = subprocess .STDOUT , shell = True )
64- if not branch_name :
65- # in detached head state
66- branch_name = os .environ ["SOURCE_BRANCH" ]
67- else :
68- branch_name = self .branch_name .decode ("utf-8" ).strip ()
64+ branch_name = self .branch_name .decode ("utf-8" ).strip ()
6965
70- except Exception as e :
71- raise Exception ( f"Error getting branch name: { e } " )
72-
73- if not branch_name or branch_name == "undefined" or not repo_slug :
74- raise Exception ("No branch found " )
66+ except Exception :
67+ branch_name = os . environ [ "SOURCE_BRANCH" ]
68+
69+ if not branch_name or branch_name == "undefined" :
70+ raise Exception ("Error getting branch name " )
7571
7672 repo_name = f"https://github.com/{ repo_slug } "
7773
@@ -101,7 +97,7 @@ def create_collector(self, collector_name):
10197 try :
10298 resp = self .sumologic_cli .create_collector (collector , headers = None )
10399 collector_id = json .loads (resp .text )['collector' ]['id' ]
104- print (f "created collector { collector_id } " )
100+ print ("created collector" )
105101 except Exception as e :
106102 raise Exception (e )
107103
@@ -111,7 +107,7 @@ def delete_collector(self, collector_id):
111107 sources = self .sumologic_cli .sources (collector_id , limit = 10 )
112108 if len (sources ) == 0 :
113109 self .sumologic_cli .delete_collector ({"collector" : {"id" : collector_id }})
114- print (f "deleted collector { collector_id } " )
110+ print ("deleted collector" )
115111
116112 def create_source (self , collector_id , source_name ):
117113 print ("create_source start" )
@@ -129,11 +125,11 @@ def create_source(self, collector_id, source_name):
129125 data = resp .json ()['source' ]
130126 source_id = data ["id" ]
131127 endpoint = data ["url" ]
132- print (f "created source ' { source_id } ' endpoint ' { endpoint } ' " )
128+ print ("created source" )
133129 except Exception as e :
134130 raise Exception (e )
135131 return source_id , endpoint
136132
137133 def delete_source (self , collector_id , source_id ):
138134 self .sumologic_cli .delete_source (collector_id , {"source" : {"id" : source_id }})
139- print (f "deleted source { source_id } " )
135+ print ("deleted source" )
0 commit comments