Merge "Add gre type driver for dc-gw and tdd cases"
[releng/builder.git] / check_prefix.py
1 # SPDX-License-Identifier: EPL-1.0
2 ##############################################################################
3 # Copyright (c) 2018 The Linux Foundation and others.
4 #
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Eclipse Public License v1.0
7 # which accompanies this distribution, and is available at
8 # http://www.eclipse.org/legal/epl-v10.html
9 ##############################################################################
10 """Ensures that the prefix MUST be set to blank.
11
12 The production prefix MUST always be a blank string.
13 """
14
15 __author__ = 'Thanh Ha'
16
17
18 import os
19 import re
20 import sys
21
22
23 def check_prefix(filename):
24     with open(filename, 'r') as _file:
25         for num, line in enumerate(_file, 1):
26             if re.search('prefix:', line):
27                 if "''" not in line:
28                     print(
29                         'ERROR: A non-blank prefix is defined in '
30                         'jjb/defaults.yaml. The prefix MUST be set to blank '
31                         '\'\' in production!'
32                     )
33                     sys.exit(1)
34
35
36 if __name__ == "__main__":
37     check_prefix(os.path.join('jjb', 'defaults.yaml'))