Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve localizer readability #4860

Conversation

annasong20
Copy link
Contributor

This PR aims to improve the readability of code under api/internal/localizer. Specifically, it addresses readability-related code review feedback from #4797.

@k8s-ci-robot
Copy link
Contributor

@annasong20: This PR has multiple commits, and the default merge method is: merge.
You can request commits to be squashed using the label: tide/merge-method-squash

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/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 9, 2022
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 9, 2022
@annasong20
Copy link
Contributor Author

/label tide/merge-method-squash

@k8s-ci-robot k8s-ci-robot added tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Nov 9, 2022
@annasong20 annasong20 force-pushed the improve-localize-ldr-readability branch from 4b33348 to ad6348f Compare November 11, 2022 19:12
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 11, 2022
@yuwenma
Copy link
Contributor

yuwenma commented Nov 14, 2022

I think we want to find a better name to replace Args and raw...

  • args is normally used on string slice variables which is used as CLI argument.
    e.g. kustomize build <ARGS> see code
  • raw should be either 1. more specific 2. more concise (e.g. rawScope -> scope), defer to whether the variables are used in the main logic (meaning matters) or in a helper methods (concise wins). Shall we change establishScope to something like GetEffectiveScope or EffectiveScope like [effectiveNamespace](https://github.com/kubernetes-sigs/kustomize/blob/fcfd30ca18bf5d533e1c1b6e94bb47ffd2c24f18/kyaml/resid/resid.go#L149)
    So the code will be
// Before
scope, err := establishScope(rawScope, rawTarget, ldr, fSys)
// After
effectiveScope, err := GetEffectiveScope(scope, target, ldr, fSys)

@annasong20
Copy link
Contributor Author

I think we want to find a better name to replace Args and raw...

  • args is normally used on string slice variables which is used as CLI argument.
    e.g. kustomize build <ARGS> see code
  • raw should be either 1. more specific 2. more concise (e.g. rawScope -> scope), defer to whether the variables are used in the main logic (meaning matters) or in a helper methods (concise wins). Shall we change establishScope to something like GetEffectiveScope or EffectiveScope like [effectiveNamespace](https://github.com/kubernetes-sigs/kustomize/blob/fcfd30ca18bf5d533e1c1b6e94bb47ffd2c24f18/kyaml/resid/resid.go#L149)
    So the code will be
// Before
scope, err := establishScope(rawScope, rawTarget, ldr, fSys)
// After
effectiveScope, err := GetEffectiveScope(scope, target, ldr, fSys)
  1. Sure! I can change raw as you've dictated here.
  2. Yeah, I wanted Args to represent the cleaned, validated CLI arguments for localize. Unfortunately, it's not a []string. I've been thinking about alternatives. How do you like Spec or Constants?

@yuwenma
Copy link
Contributor

yuwenma commented Nov 15, 2022

I think we want to find a better name to replace Args and raw...

  • args is normally used on string slice variables which is used as CLI argument.
    e.g. kustomize build <ARGS> see code
  • raw should be either 1. more specific 2. more concise (e.g. rawScope -> scope), defer to whether the variables are used in the main logic (meaning matters) or in a helper methods (concise wins). Shall we change establishScope to something like GetEffectiveScope or EffectiveScope like [effectiveNamespace](https://github.com/kubernetes-sigs/kustomize/blob/fcfd30ca18bf5d533e1c1b6e94bb47ffd2c24f18/kyaml/resid/resid.go#L149)
    So the code will be
// Before
scope, err := establishScope(rawScope, rawTarget, ldr, fSys)
// After
effectiveScope, err := GetEffectiveScope(scope, target, ldr, fSys)
  1. Sure! I can change raw as you've dictated here.
  2. Yeah, I wanted Args to represent the cleaned, validated CLI arguments for localize. Unfortunately, it's not a []string. I've been thinking about alternatives. How do you like Spec or Constants?

ah, I see. Args makes sense.

@yuwenma
Copy link
Contributor

yuwenma commented Nov 15, 2022

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 15, 2022
@natasha41575
Copy link
Contributor

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: annasong20, natasha41575

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:

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 added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 16, 2022
@k8s-ci-robot k8s-ci-robot merged commit f79e16b into kubernetes-sigs:master Nov 16, 2022
@annasong20 annasong20 deleted the improve-localize-ldr-readability branch November 16, 2022 18:17
elisshafer pushed a commit to elisshafer/kustomize that referenced this pull request Dec 8, 2022
* Replace '%s' with %q

* Change ambiguous cli-"Arg" suffix in func arg names

* Remove repetitive "loc" in names

* Apply readability changes to localizer

* Fix comment
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. size/L Denotes a PR that changes 100-499 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.

None yet

4 participants