Skip to content

Conversation

@aerfio
Copy link
Contributor

@aerfio aerfio commented Nov 19, 2025

Introduce FieldOwner field to client.Options, to allow users to set it once, without doing it like that:

cl, err := client.New(restCfg, client.Options{})
if err != nil {
  panic(err)
}
cl = client.WithFieldOwner(cl, "field-owner")

The main reason however is the ability to set it in manager creation, so that the client we get from it using mgr.GetClient() is already correctly configured. Otherwise I have to plumb the client manually or use following code:

mgr, err := ctrl.NewManager(restCfg, ctrl.Options{
        ...
		NewClient: func(config *rest.Config, options client.Options) (client.Client, error) {
			cli, err := client.New(config, options)
			if err != nil {
				return nil, err
			}
			return client.WithFieldOwner(cli, "test-owner"), nil
		},
        ...

But the documentation of NewClient states that it's a low level primitive and should not be used unless you know what you're doing, so I'd rather not overwrite default client creation fn

@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 19, 2025
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 19, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @aerfio. Thanks for your PR.

I'm waiting for a github.com member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 19, 2025
@aerfio aerfio marked this pull request as ready for review November 19, 2025 23:29
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 19, 2025
@troy0820
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 19, 2025
Copy link
Member

@alvaroaleman alvaroaleman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems okay to me. @sbueringer WDYT? Odds are we will end up adding most/all of the wrappers in here.

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 20, 2025
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 20, 2025
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 439b4f17408bf1e5554a84542279b4d791b14840

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 20, 2025
@aerfio
Copy link
Contributor Author

aerfio commented Nov 20, 2025

@alvaroaleman My plan is to actually create the same PR but for the FieldValidation. I can also prepare other ones for any other field you've got in mind, but right now I can only see 2 With.* functions in client package

@sbueringer
Copy link
Member

seems okay to me. @sbueringer WDYT? Odds are we will end up adding most/all of the wrappers in here.

/hold

All good from my side, just a minor point on the godoc: #3389 (comment)

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 21, 2025
@sbueringer sbueringer added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Nov 21, 2025
@sbueringer
Copy link
Member

Thank you very much!

/lgtm
/approve
/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 21, 2025
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 21, 2025
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 2007aae2b26d584377139437f6e8769c40a0a2f2

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aerfio, alvaroaleman, sbueringer

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [alvaroaleman,sbueringer]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit 3893e04 into kubernetes-sigs:main Nov 21, 2025
10 checks passed
@aerfio aerfio deleted the aerfio/client-field-owner branch November 21, 2025 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants