MCPcopy Create free account
hub / github.com/airbnb/binaryalert / save

Method save

cli/config.py:284–306  ·  view source on GitHub ↗

Save the current configuration to the terraform.tfvars config file.

(self)

Source from the content-addressed store, hash-verified

282 self.encrypted_carbon_black_api_token = self.encrypted_carbon_black_api_token
283
284 def save(self) -> None:
285 """Save the current configuration to the terraform.tfvars config file."""
286 # In order to preserve comments, we overwrite each individual variable instead of re-writing
287 # the entire configuration file.
288 with open(CONFIG_FILE) as config_file:
289 raw_config = config_file.read()
290
291 for variable_name, value in self._config.items():
292 if isinstance(value, str):
293 formatted_value = '"{}"'.format(value)
294 elif isinstance(value, bool):
295 formatted_value = str(value).lower()
296 else:
297 formatted_value = value
298
299 raw_config = re.sub(
300 r'{}\s*=\s*\S+'.format(variable_name),
301 '{} = {}'.format(variable_name, formatted_value),
302 raw_config
303 )
304
305 with open(CONFIG_FILE, 'w') as config_file:
306 config_file.write(raw_config)

Callers 5

configureMethod · 0.95
test_saveMethod · 0.95
compile_rulesFunction · 0.80
save_test_yara_rulesFunction · 0.80

Calls

no outgoing calls

Tested by 1

test_saveMethod · 0.76