Merge "Update cloud image Ubuntu18.04 mininet ovs"
[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     """Check if a prefix was checked into this repo."""
25     with open(filename, "r") as _file:
26         for num, line in enumerate(_file, 1):
27             if re.search(r"^\s+prefix:", line):
28                 if '""' not in line:
29                     print(
30                         "ERROR: A non-blank prefix is defined in "
31                         "jjb/defaults.yaml. The prefix MUST be set to blank "
32                         '"" in production!'
33                     )
34                     sys.exit(1)
35
36
37 if __name__ == "__main__":
38     check_prefix(os.path.join("jjb", "defaults.yaml"))