Skip to content

Inconsistent handling of YEAR substitution across generators #1371

@felix-kaestner

Description

@felix-kaestner

Background

#544 added a year option to generator commands (object, crd, rbac, and webhook), allowing callers to substitute a YEAR placeholder in boilerplate header files with a specific value.

Problem

The applyconfiguration generator is missing the year option and unconditionally replaces YEAR using time.Now().UTC().Year(), leading to inconsistent behaviour.

The full call chain is:

  1. controller-tools/pkg/applyconfiguration/gen.go#L215
  2. controller-tools/pkg/applyconfiguration/gen.go#L293
  3. code-generator/cmd/applyconfiguration-gen/generators/targets.go#L60
  4. gengo/v2/execute.go#L59

Proposed Solution

Add a optional year option to the applyconfiguration generator, which when set, will take precedence. This change would be backwards compatible, as if the option is not specified, the current logic stays as it currently is.

Additionally, the other generators could have same logic, of defaulting to the current year as a subsitution for the string "YEAR" if not overridden by the option.

Metadata

Metadata

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions