Skip to content

Commit 1065922

Browse files
authored
Merge pull request #130 from splunk/ba_release_notes
BA release notes
2 parents 04b1783 + f581fea commit 1065922

File tree

1 file changed

+46
-14
lines changed

1 file changed

+46
-14
lines changed

contentctl/actions/release_notes.py

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,9 @@ def create_notes(self,repo_path, file_paths):
3030
if 'name' in data and 'stories/' in file_path:
3131
story_link = "https://research.splunk.com/stories/" + data['name']
3232
story_link=story_link.replace(" ","_")
33-
story_link=story_link.replace("- ","_")
3433
story_link = story_link.lower()
3534
print("- "+"["+f"{data['name']}"+"]"+"("+story_link+")")
36-
# Check and create detection link
37-
if 'name' in data and 'id' in data and 'detections/' in file_path:
38-
temp_link = "https://research.splunk.com" + file_path.replace(repo_path,"")
39-
pattern = r'(?<=/)[^/]*$'
40-
detection_link = re.sub(pattern, data['id'], temp_link)
41-
detection_link = detection_link.replace("detections","" )
42-
detection_link = detection_link.replace(".com//",".com/" )
43-
print("- "+"["+f"{data['name']}"+"]"+"("+detection_link+")")
35+
4436
if 'name' in data and'playbooks/' in file_path:
4537
playbook_link = "https://research.splunk.com" + file_path.replace(repo_path,"")
4638
playbook_link=playbook_link.replace(".yml","/").lower()
@@ -52,6 +44,28 @@ def create_notes(self,repo_path, file_paths):
5244
if 'name' in data and'lookups/' in file_path:
5345
print("- " + f"{data['name']}")
5446

47+
# Create only SSA link when its production
48+
if 'name' in data and 'id' in data and 'ssa_detections/' in file_path:
49+
if data['status'] == "production":
50+
temp_link = "https://research.splunk.com" + file_path.replace(repo_path,"")
51+
pattern = r'(?<=/)[^/]*$'
52+
detection_link = re.sub(pattern, data['id'], temp_link)
53+
detection_link = detection_link.replace("detections","" )
54+
detection_link = detection_link.replace("ssa_/","" )
55+
print("- "+"["+f"{data['name']}"+"]"+"("+detection_link+")")
56+
57+
if data['status'] == "validation":
58+
print("- "+f"{data['name']}"+" (Validation Mode)")
59+
60+
# Check and create detection link
61+
if 'name' in data and 'id' in data and 'detections/' in file_path and not 'ssa_detections/' in file_path:
62+
temp_link = "https://research.splunk.com" + file_path.replace(repo_path,"")
63+
pattern = r'(?<=/)[^/]*$'
64+
detection_link = re.sub(pattern, data['id'], temp_link)
65+
detection_link = detection_link.replace("detections","" )
66+
detection_link = detection_link.replace(".com//",".com/" )
67+
print("- "+"["+f"{data['name']}"+"]"+"("+detection_link+")")
68+
5569
except yaml.YAMLError as exc:
5670
print(f"Error parsing YAML file {file_path}: {exc}")
5771
else:
@@ -60,7 +74,7 @@ def create_notes(self,repo_path, file_paths):
6074
def release_notes(self, input_dto: DirectorInputDto, old_tag:Union[str,None], new_tag:str, latest_branch:str) -> None:
6175

6276
### Remove hard coded path
63-
directories = ['detections/','stories/','macros/','lookups/','playbooks']
77+
directories = ['detections/','stories/','macros/','lookups/','playbooks/','ssa_detections/']
6478
repo_path = os.path.abspath(input_dto.director_input_dto.input_path)
6579
repo = Repo(repo_path)
6680
# Ensure the new tag is in the tags if tags are supplied
@@ -104,25 +118,28 @@ def release_notes(self, input_dto: DirectorInputDto, old_tag:Union[str,None], ne
104118
# Check if a file is Modified
105119
if diff.change_type == 'M':
106120
modified_files.append(file_path)
121+
122+
107123
# Check if a file is Added
108124
elif diff.change_type == 'A':
109125
added_files.append(file_path)
110126
# print(added_files)
111-
112127
detections_added = []
128+
ba_detections_added = []
113129
stories_added = []
114130
macros_added = []
115131
lookups_added = []
116132
playbooks_added = []
117133
detections_modified = []
134+
ba_detections_modified = []
118135
stories_modified = []
119136
macros_modified = []
120137
lookups_modified = []
121138
playbooks_modified = []
122139

123140
for file in modified_files:
124141
file=repo_path +"/"+file
125-
if 'detections/' in file:
142+
if 'detections/' in file and 'ssa_detections/' not in file:
126143
detections_modified.append(file)
127144
if 'stories/' in file:
128145
stories_modified.append(file)
@@ -132,10 +149,12 @@ def release_notes(self, input_dto: DirectorInputDto, old_tag:Union[str,None], ne
132149
lookups_modified.append(file)
133150
if 'playbooks/' in file:
134151
playbooks_modified.append(file)
152+
if 'ssa_detections/' in file:
153+
ba_detections_modified.append(file)
135154

136155
for file in added_files:
137156
file=repo_path +"/"+file
138-
if 'detections/' in file:
157+
if 'detections/' in file and 'ssa_detections/' not in file:
139158
detections_added.append(file)
140159
if 'stories/' in file:
141160
stories_added.append(file)
@@ -145,6 +164,9 @@ def release_notes(self, input_dto: DirectorInputDto, old_tag:Union[str,None], ne
145164
lookups_added.append(file)
146165
if 'playbooks/' in file:
147166
playbooks_added.append(file)
167+
if 'ssa_detections/' in file:
168+
ba_detections_added.append(file)
169+
148170
if new_tag:
149171

150172
print(f"Generating release notes - \033[92m{latest_tag}\033[0m")
@@ -177,6 +199,16 @@ def release_notes(self, input_dto: DirectorInputDto, old_tag:Union[str,None], ne
177199
print("\n### Playbooks Updated")
178200
self.create_notes(repo_path,playbooks_modified)
179201

180-
print("\n### Other Updates\n-\n")
202+
print("\n### Other Updates\n-\n")
203+
204+
print("\n## BA Release Notes")
205+
206+
print("\n### New BA Analytics")
207+
self.create_notes(repo_path,ba_detections_added)
208+
209+
print("\n### Updated BA Analytics")
210+
self.create_notes(repo_path,ba_detections_modified)
211+
212+
181213

182214
print(f"Release notes completed succesfully")

0 commit comments

Comments
 (0)