tektoncd / tektoncd/operator

Use //go:fix inline and go fix to modernize codebase

Open
#3,280 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/cleanup
Dominant language
Go
Stars
608
Forks
263
Avg merge
1d 3h
Merged PRs (30d)
125

Description

Description

Go 1.26 introduced a rewritten go fix subcommand with a source-level inliner. The //go:fix inline directive allows annotating deprecated functions, type aliases, and variables so that go fix (or IDEs) automatically rewrite call sites to the modern replacement.

For tektoncd/operator this is relevant in two ways:

  1. As a consumer: Once tektoncd/pipeline adds //go:fix inline annotations to its deprecated APIs, operator can run go fix ./... to auto-migrate usage of deprecated pipeline types and functions.

  2. Own deprecated APIs: operator has deprecated fields and generated code that could be annotated.

Prerequisite

Bump go.mod to Go 1.26 (currently at 1.25.5).

Opportunities

Own Deprecated APIs

The generated informer factory has the common deprecated wrapper pattern:

// pkg/client/informers/externalversions/factory.go

// Deprecated: Please use NewSharedInformerFactoryWithOptions instead
//
//go:fix inline
func NewFilteredSharedInformerFactory(client versioned.Interface, defaultResync time.Duration, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerFactory {
	return NewSharedInformerFactoryWithOptions(client, defaultResync, WithNamespace(namespace), WithTweakListOptions(tweakListOptions))
}

Deprecated fields in the operator API types (pkg/apis/operator/v1alpha1/) could also benefit from annotation where applicable.

Consuming pipeline's annotations

Once tektoncd/pipeline annotates its deprecated APIs (tektoncd/pipeline#9560), running go fix ./... in operator will automatically migrate:

  • Deprecated type aliases (e.g. ArrayOrStringParamValue)
  • Deprecated wrapper functions
  • Deprecated resolution package imports
Go 1.26 built-in modernizers

Beyond //go:fix inline, Go 1.26's go fix ships with 24+ built-in modernizers that automatically apply improvements like using slices.Sort, min/max builtins, strings.Cut, and more. Running go fix ./... after bumping to Go 1.26 would apply all applicable modernizations.

References

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with go.mod and run go fix ./... after reviewing pkg/client/informers/externalversions/factory.go and deprecated API types under pkg/apis/operator/v1alpha1/. Check the resulting changes against the pipeline prerequisite in issue #9560, then run the repository's tests. Done means the Go 1.26 migration, applicable annotations, and modernizations are reviewed and validated.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
build-system, tooling
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.