mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 00:57:27 +00:00
check flag format in file known-flags.txt
All flags in file hack/verify-flags/known-flags.txt should contain character -, this change check this to prevent adding useless flags to known-flags.txt
This commit is contained in:
parent
f0e5a999e9
commit
3aa71aa193
@ -120,6 +120,26 @@ def line_has_bad_flag(line, flagre):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def check_known_flags(rootdir):
|
||||||
|
pathname = os.path.join(rootdir, "hack/verify-flags/known-flags.txt")
|
||||||
|
f = open(pathname, 'r')
|
||||||
|
flags = set(f.read().splitlines())
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
illegal_known_flags = set()
|
||||||
|
for flag in flags:
|
||||||
|
if len(flag) > 0:
|
||||||
|
if not "-" in flag:
|
||||||
|
illegal_known_flags.add(flag)
|
||||||
|
|
||||||
|
if len(illegal_known_flags) != 0:
|
||||||
|
print("All flags in hack/verify-flags/known-flags.txt should contain character -, found these flags without -")
|
||||||
|
l = list(illegal_known_flags)
|
||||||
|
l.sort()
|
||||||
|
print("%s" % "\n".join(l))
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
# The list of files might not be the whole repo. If someone only changed a
|
# The list of files might not be the whole repo. If someone only changed a
|
||||||
# couple of files we don't want to run all of the golang files looking for
|
# couple of files we don't want to run all of the golang files looking for
|
||||||
# flags. Instead load the list of flags from hack/verify-flags/known-flags.txt
|
# flags. Instead load the list of flags from hack/verify-flags/known-flags.txt
|
||||||
@ -174,7 +194,7 @@ def get_flags(rootdir, files):
|
|||||||
print("%s" % "\n".join(l))
|
print("%s" % "\n".join(l))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
if len(new_flags) != 0:
|
if len(new_flags) != 0:
|
||||||
print("Found flags in golang files not in the list of known flags. Please add these to hack/verify-flags/known-flags.txt")
|
print("Found flags with character - in golang files not in the list of known flags. Please add these to hack/verify-flags/known-flags.txt")
|
||||||
l = list(new_flags)
|
l = list(new_flags)
|
||||||
l.sort()
|
l.sort()
|
||||||
print("%s" % "\n".join(l))
|
print("%s" % "\n".join(l))
|
||||||
@ -223,6 +243,8 @@ def main():
|
|||||||
files = get_all_files(rootdir)
|
files = get_all_files(rootdir)
|
||||||
files = normalize_files(rootdir, files)
|
files = normalize_files(rootdir, files)
|
||||||
|
|
||||||
|
check_known_flags(rootdir)
|
||||||
|
|
||||||
flags = get_flags(rootdir, files)
|
flags = get_flags(rootdir, files)
|
||||||
flagRE = flags_to_re(flags)
|
flagRE = flags_to_re(flags)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user