Skip to content

Commit

Permalink
ci: Add option to manually dispatch upgrade job (#58)
Browse files Browse the repository at this point in the history
Co-authored-by: Ross Nanopoulos <2287187+zythosec@users.noreply.github.com>
  • Loading branch information
jsbroks and zythosec authored Mar 3, 2023
1 parent 1423a8d commit f3a8f50
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @jsbroks @venky-wandb @zythosec @vanpelt
* @wandb/delivery-team @wandb/security-team
8 changes: 5 additions & 3 deletions scripts/set_variable_default.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import re
import sys


def set_variable_default(variable: str, value: str, content: str) -> str:
"""
This script uses regex to replace the text. It makes an assumption that the
default value must be declared before an conditions are applied.
"""
pat = '(variable\s+\"' + variable + '\"\s*{[^\}]+\s+default\s*=\s\").*(\"\n)'
pat = '(variable\s+\"' + variable + '\"\s*{[^}]+\s+default\s*=\s\").*(\"\n)'

rep = lambda m: f'{m.group(1)}{value}{m.group(2)}'
return re.sub(
pat,
r'\1' + value + r'\2',
rep,
content
)

Expand All @@ -19,7 +22,6 @@ def set_variable_default(variable: str, value: str, content: str) -> str:
file_path = ''.join(var_file) or 'variables.tf'

print(f"Setting \"{var}\" to \"{val}\" in \"{file_path}\"")

with open(file_path, 'r+', encoding="utf8") as f:
txt = f.read()
result = set_variable_default(var, val, txt)
Expand Down

0 comments on commit f3a8f50

Please sign in to comment.