diff --git a/hack/boilerplate/boilerplate.Dockerfile.txt b/hack/boilerplate/boilerplate.Dockerfile.txt index 384f325abf3..069e282bc85 100644 --- a/hack/boilerplate/boilerplate.Dockerfile.txt +++ b/hack/boilerplate/boilerplate.Dockerfile.txt @@ -1,4 +1,4 @@ -# Copyright YEAR The Kubernetes Authors. +# Copyright The Kubernetes Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/hack/boilerplate/boilerplate.Makefile.txt b/hack/boilerplate/boilerplate.Makefile.txt index 384f325abf3..069e282bc85 100644 --- a/hack/boilerplate/boilerplate.Makefile.txt +++ b/hack/boilerplate/boilerplate.Makefile.txt @@ -1,4 +1,4 @@ -# Copyright YEAR The Kubernetes Authors. +# Copyright The Kubernetes Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/hack/boilerplate/boilerplate.go.txt b/hack/boilerplate/boilerplate.go.txt index 59e740c1ee4..b7c650da470 100644 --- a/hack/boilerplate/boilerplate.go.txt +++ b/hack/boilerplate/boilerplate.go.txt @@ -1,5 +1,5 @@ /* -Copyright YEAR The Kubernetes Authors. +Copyright The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/hack/boilerplate/boilerplate.py b/hack/boilerplate/boilerplate.py index 65eb08b00ec..2e82e1e1710 100755 --- a/hack/boilerplate/boilerplate.py +++ b/hack/boilerplate/boilerplate.py @@ -103,26 +103,11 @@ def file_passes(filename, refs, regexs): # trim our file to the same number of lines as the reference file data = data[: len(ref)] - pattern = regexs["year"] - for line in data: - if pattern.search(line): - if generated: - print( - f"File {filename} has the YEAR field, but it should not be in generated file", - file=verbose_out, - ) - else: - print( - "File {filename} has the YEAR field, but missing the year of date", - file=verbose_out, - ) - return False - if not generated: - # Replace all occurrences of the regex "2014|2015|2016|2017|2018" with "YEAR" + # Remove all occurrences of the year (regex "Copyright (2014|2015|2016|2017|2018) ") pattern = regexs["date"] for i, line in enumerate(data): - data[i], found = pattern.subn("YEAR", line) + data[i], found = pattern.subn("Copyright ", line) if found != 0: break @@ -203,18 +188,18 @@ def get_files(extensions): def get_dates(): - years = datetime.datetime.now().year - return "(%s)" % "|".join(str(year) for year in range(2014, years + 1)) + # After 2025, we no longer allow new files to include the year in the copyright header. + final_year = 2025 + return " (%s) " % "|".join(str(year) for year in range(2014, final_year + 1)) def get_regexs(): regexs = {} # Search for "YEAR" which exists in the boilerplate, but shouldn't in the real thing regexs["year"] = re.compile("YEAR") - # get_dates return 2014, 2015, 2016, 2017, or 2018 until the current year - # as a regex like: "(2014|2015|2016|2017|2018)"; - # company holder names can be anything - regexs["date"] = re.compile(get_dates()) + # get_dates return 2014, 2015, 2016, 2017, ..., 2025 + # as a regex like: "(2014|2015|2016|2017|2018|...|2025)"; + regexs["date"] = re.compile("Copyright" + get_dates()) # strip the following build constraints/tags: # //go:build # // +build \n\n diff --git a/hack/boilerplate/boilerplate.py.txt b/hack/boilerplate/boilerplate.py.txt index 384f325abf3..069e282bc85 100644 --- a/hack/boilerplate/boilerplate.py.txt +++ b/hack/boilerplate/boilerplate.py.txt @@ -1,4 +1,4 @@ -# Copyright YEAR The Kubernetes Authors. +# Copyright The Kubernetes Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/hack/boilerplate/boilerplate.sh.txt b/hack/boilerplate/boilerplate.sh.txt index 384f325abf3..069e282bc85 100644 --- a/hack/boilerplate/boilerplate.sh.txt +++ b/hack/boilerplate/boilerplate.sh.txt @@ -1,4 +1,4 @@ -# Copyright YEAR The Kubernetes Authors. +# Copyright The Kubernetes Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/hack/boilerplate/boilerplate_test.py b/hack/boilerplate/boilerplate_test.py index 8fc7e4cbcb1..cd8f532fd67 100644 --- a/hack/boilerplate/boilerplate_test.py +++ b/hack/boilerplate/boilerplate_test.py @@ -50,4 +50,4 @@ class TestBoilerplate(unittest.TestCase): sys.stdout = old_stdout - self.assertEqual(output, ["././fail.go", "././fail.py"]) + self.assertEqual(output, ["././fail.go", "././fail.py", "././fail_2026.go"]) diff --git a/hack/boilerplate/test/fail_2026.go b/hack/boilerplate/test/fail_2026.go new file mode 100644 index 00000000000..1f9623be5b7 --- /dev/null +++ b/hack/boilerplate/test/fail_2026.go @@ -0,0 +1,17 @@ +/* +Copyright 2026 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package test diff --git a/hack/boilerplate/test/pass_no_year.go b/hack/boilerplate/test/pass_no_year.go new file mode 100644 index 00000000000..d4a36a26617 --- /dev/null +++ b/hack/boilerplate/test/pass_no_year.go @@ -0,0 +1,17 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package test