🐛 (applyconfiguration): applyconfiguration: add a year option to pin the copyright year in generated file headers, matching the object generator and avoiding annual diffs on regeneration. - #1379
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: camilamacedo86 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
c4c3d7f to
ca8c426
Compare
|
@JoelSpeed I think this one is your baby :-) |
|
Unknown CLA label state. Rechecking for CLA labels. Send feedback to sig-contributor-experience at kubernetes/community. /check-cla |
alvaroaleman
left a comment
There was a problem hiding this comment.
/hold
For the discussion in #1371
|
Thank you for looking on this one. Consistent behaviour is a key and expected.
|
|
I see this has a |
@alvaroaleman blocked it for discussion: #1379 (review) As I described in #1379 (comment) IMO it is a bug and must be done or we should not support the YEAR at all. |
| tmpFile.Close() | ||
| os.Remove(tmpFile.Name()) |
| { | ||
| name: "YEAR without space not replaced", | ||
| headerContent: "CopyrightYEAR YEAR", | ||
| year: "2024", | ||
| expectedOutput: "CopyrightYEAR 2024", | ||
| }, |
There was a problem hiding this comment.
Does this match what DeepCopy generator would do in the upstream code-generator repo?
There was a problem hiding this comment.
Yes, that is the intention.
I changed the tests for use gingo.
But we are covering here the scenarios to ensure that it works like object.
Both should work at the same way.
ca8c426 to
1eb5542
Compare
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: camilamacedo86 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
1eb5542 to
92c99ad
Compare
92c99ad to
7c6fd5d
Compare
|
Hi @alvaroaleman @JoelSpeed @sbueringer @felix-kaestner @liggitt, I've updated the PR description to better explain why the
Supporting If we decide to remove the |
|
@camilamacedo86 I'm not following how the code enables the files to retain their previous year. As far as I can see the generator has a static year which it dumps into the header file, and then the generator runs and substitutes that one file for all assets it generates What am I missing? |
year option to pin the copyright year in generated file headers, matching the object generator and avoiding annual diffs on regeneration.
|
Hi @JoelSpeed Thank you for taking the time to look into this and all your support !! I've updated both the PR title and desc to make the intent clearer. Hopefully they're easier to follow now. AI also helped me here to wording better. So "retain the previous year" was the wrong wording. What this PR actually does is pin a single configured year so regeneration no longer rewrites it to the current calendar year. It does not read existing generated files and preserve each file's copyright year. It make the behaviour consistent accross the project (object and apply works at the same way) and solve the Jan 1 issue. Today, the applyconfiguration generator passes the boilerplate header directly to the For example: Without the The
For example, with
This pins a single year for the entire generation run, matching the behavior of the The goal is simply to achieve parity with the object generator and produce deterministic output. |
What
Add a
year=<value>option to theapplyconfigurationgenerator, matching the existingobjectgenerator.Why
Today, the applyconfiguration generator passes the boilerplate header directly to the
applyconfiguration-gen, which replacesYEARwith the current calendar year at generation time.For example:
Without a
year=option:make generate→Copyright 2024make generateagain (even with no API changes) →Copyright 2025This results in a large, unnecessary diff every January.
The
objectgenerator already supportsyear=, producing deterministic output without annual copyright churn. This change brings the applyconfiguration generator to the same behavior.Example:
Copyright 2024. The working tree is clean.make generate. Nothing in the API has changed, but the generator now stampsCopyright 2025into every generated applyconfiguration file.How
Before invoking the upstream generator, this change:
YEARwith the configuredyear=value.Because
YEARhas already been replaced, the upstream generator has nothing leftto substitute with the current calendar year, so the configured year remains
unchanged.
For example, with
year=2024:make generate→Copyright 2024- Jan 2025:
make generate→ stillCopyright 2024This pins a single year for the entire generation run, matching the behavior of the
objectgenerator. It does not preserve the existing copyright year of individual generated files.References
yearoption to pin the copyright year in generated file headers, matching the object generator and avoiding annual diffs on regeneration. #1379year=support forobject: ✨ Add header and year options for yaml generator #544gengoperforms theYEARsubstitution: https://github.com/kubernetes/gengo/blob/5ee0d033ba5bcb073f0e69c32057520b82d75ccb/v2/execute.go#L59YEARplaceholder inhack/boilerplate.go.txtkubebuilder#5553Fixes: #1371