Skip to content

chore: migrate to TypeFor - #6107

Merged
remyleone merged 1 commit into
mainfrom
type_for
Sep 4, 2026
Merged

chore: migrate to TypeFor#6107
remyleone merged 1 commit into
mainfrom
type_for

Conversation

@remyleone

Copy link
Copy Markdown
Member

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Relates OR Closes #0000

Release note for CHANGELOG:


Copilot AI lite review requested due to automatic review settings September 2, 2026 11:46
@remyleone
remyleone requested review from a team as code owners September 2, 2026 11:46
@remyleone
remyleone requested review from elwinar and removed request for a team September 2, 2026 11:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Pull request overview

This PR migrates the codebase from reflect.TypeOf(...) patterns to the generic reflect.TypeFor[T]() API for acquiring reflect.Type values without allocating sentinel values.

Changes:

  • Replace reflect.TypeOf(x{}) / reflect.TypeOf((*T)(nil)).Elem() usages with reflect.TypeFor[T]() across commands, args, and human marshaling.
  • Update internal QA and multiple namespace command definitions to use TypeFor for ArgsType.
  • Update unit tests accordingly to match the new type acquisition strategy.

Reviewed changes

Copilot reviewed 103 out of 103 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
internal/qa/ignore.go Use reflect.TypeFor for ignored error type matching.
internal/qa/argspec.go Use reflect.TypeFor when checking for args.RawArgs arg types.
internal/namespaces/vpcgw/v2/custom_pat_rule.go Update command ArgsType initialization to reflect.TypeFor.
internal/namespaces/vpc/v2/custom_acl.go Update command ArgsType initialization to reflect.TypeFor.
internal/namespaces/test/v1/test_cli.go Update test namespace commands ArgsType to reflect.TypeFor.
internal/namespaces/test/custom/custom_cli.go Update custom test command ArgsType to reflect.TypeFor.
internal/namespaces/shell/shell.go Update shell command ArgsType to reflect.TypeFor.
internal/namespaces/secret/v1beta1/custom_secret_version.go Update builder-assigned ArgsType to reflect.TypeFor.
internal/namespaces/registry/v1/custom_tag.go Update builder-assigned ArgsType to reflect.TypeFor.
internal/namespaces/registry/v1/custom_logout.go Update command ArgsType to reflect.TypeFor.
internal/namespaces/registry/v1/custom_login.go Update command ArgsType to reflect.TypeFor.
internal/namespaces/registry/v1/custom_docker_helper.go Update multiple registry docker-helper command ArgsType values to reflect.TypeFor.
internal/namespaces/redis/v1/custom_version_settings.go Update command ArgsType to reflect.TypeFor.
internal/namespaces/redis/v1/custom_cluster.go Update builder/command ArgsType to reflect.TypeFor.
internal/namespaces/redis/v1/custom_acl.go Update command ArgsType to reflect.TypeFor.
internal/namespaces/rdb/v1/custom_user.go Update builder/command ArgsType to reflect.TypeFor.
internal/namespaces/rdb/v1/custom_url.go Update command ArgsType to reflect.TypeFor.
internal/namespaces/rdb/v1/custom_log.go Update command ArgsType to reflect.TypeFor.
internal/namespaces/rdb/v1/custom_instance.go Update multiple builder/command ArgsType to reflect.TypeFor.
internal/namespaces/rdb/v1/custom_engine_settings.go Update command ArgsType to reflect.TypeFor.
internal/namespaces/rdb/v1/custom_endpoint.go Update builder/command ArgsType to reflect.TypeFor.
internal/namespaces/rdb/v1/custom_backup.go Update builder/command ArgsType to reflect.TypeFor.
internal/namespaces/rdb/v1/custom_acl.go Update builder/command ArgsType to reflect.TypeFor.
internal/namespaces/object/v1/custom_config_install.go Update command ArgsType to reflect.TypeFor.
internal/namespaces/object/v1/custom_config_get.go Update command ArgsType to reflect.TypeFor.
internal/namespaces/object/v1/custom_bucket_policy.go Update bucket-policy commands ArgsType to reflect.TypeFor.
internal/namespaces/object/v1/custom_bucket_lifecycle.go Update lifecycle commands ArgsType to reflect.TypeFor.
internal/namespaces/object/v1/custom_bucket_cors.go Update bucket-cors commands ArgsType to reflect.TypeFor.
internal/namespaces/object/v1/custom_bucket.go Update bucket commands ArgsType to reflect.TypeFor.
internal/namespaces/mongodb/v1alpha1/custom_instance.go Update wait command ArgsType to reflect.TypeFor.
internal/namespaces/mnq/v1beta1/custom_nats.go Update nats command ArgsType to reflect.TypeFor.
internal/namespaces/mcp/server/mcp_tools_test.go Update MCP tool tests to use reflect.TypeFor for ArgsType.
internal/namespaces/mcp/server/list_tools.go Update list-tools command ArgsType to reflect.TypeFor.
internal/namespaces/mcp/server/commands.go Update MCP server commands ArgsType to reflect.TypeFor.
internal/namespaces/marketplace/v2/updated_commands.go Update builder-assigned ArgsType to reflect.TypeFor.
internal/namespaces/login/login.go Update login command ArgsType to reflect.TypeFor.
internal/namespaces/lb/v1/custom_lb.go Update LB commands/builders ArgsType to reflect.TypeFor.
internal/namespaces/lb/v1/custom_certificate.go Update builder-assigned ArgsType to reflect.TypeFor.
internal/namespaces/lb/v1/custom_backend.go Update backend builders ArgsType to reflect.TypeFor.
internal/namespaces/k8s/v1/custom_pool_taints.go Update k8s taint commands ArgsType to reflect.TypeFor.
internal/namespaces/k8s/v1/custom_pool_labels.go Update k8s label commands ArgsType to reflect.TypeFor.
internal/namespaces/k8s/v1/custom_pool.go Update k8s pool commands ArgsType to reflect.TypeFor.
internal/namespaces/k8s/v1/custom_node.go Update k8s node wait ArgsType to reflect.TypeFor.
internal/namespaces/k8s/v1/custom_kubeconfig_uninstall.go Update kubeconfig uninstall ArgsType to reflect.TypeFor.
internal/namespaces/k8s/v1/custom_kubeconfig_install.go Update kubeconfig install ArgsType to reflect.TypeFor.
internal/namespaces/k8s/v1/custom_kubeconfig_get.go Update kubeconfig get ArgsType to reflect.TypeFor.
internal/namespaces/k8s/v1/custom_cluster.go Update k8s cluster wait ArgsType to reflect.TypeFor.
internal/namespaces/jobs/v1alpha2/custom_job_run.go Update jobs wait ArgsType to reflect.TypeFor.
internal/namespaces/instance/v1/custom_volume.go Update instance volume builders/command ArgsType to reflect.TypeFor.
internal/namespaces/instance/v1/custom_ssh_key.go Update SSH key commands ArgsType to reflect.TypeFor.
internal/namespaces/instance/v1/custom_ssh_config.go Update ssh-config install ArgsType to reflect.TypeFor.
internal/namespaces/instance/v1/custom_snapshot.go Update snapshot builders/command ArgsType to reflect.TypeFor.
internal/namespaces/instance/v1/custom_server_ssh.go Update server ssh ArgsType to reflect.TypeFor.
internal/namespaces/instance/v1/custom_server_rdp.go Update get-rdp-password ArgsType to reflect.TypeFor.
internal/namespaces/instance/v1/custom_server_delete.go Update server delete ArgsType to reflect.TypeFor.
internal/namespaces/instance/v1/custom_server_create.go Update server create ArgsType to reflect.TypeFor.
internal/namespaces/instance/v1/custom_server_console.go Update server console ArgsType to reflect.TypeFor.
internal/namespaces/instance/v1/custom_server_action.go Update server action commands ArgsType to reflect.TypeFor.
internal/namespaces/instance/v1/custom_server.go Update server builders/commands ArgsType to reflect.TypeFor.
internal/namespaces/instance/v1/custom_security_group.go Update security-group builders/commands ArgsType to reflect.TypeFor.
internal/namespaces/instance/v1/custom_placement_group.go Update placement-group builders ArgsType to reflect.TypeFor.
internal/namespaces/instance/v1/custom_ip.go Update ip builders/commands ArgsType to reflect.TypeFor.
internal/namespaces/instance/v1/custom_image.go Update image builders/commands ArgsType to reflect.TypeFor.
internal/namespaces/init/init.go Update init command ArgsType to reflect.TypeFor.
internal/namespaces/info/custom.go Update info command ArgsType to reflect.TypeFor.
internal/namespaces/inference/v1/custom_deployment.go Update builder-assigned ArgsType to reflect.TypeFor.
internal/namespaces/iam/v1alpha1/custom_rule.go Update IAM rule commands ArgsType to reflect.TypeFor.
internal/namespaces/iam/v1alpha1/custom_iam.go Update custom builder argType to reflect.TypeFor.
internal/namespaces/iam/v1alpha1/custom.go Update init-with-ssh command ArgsType to reflect.TypeFor.
internal/namespaces/function/v1beta1/custom_deploy.go Update deploy command ArgsType to reflect.TypeFor.
internal/namespaces/edge_services/v1beta1/custom_route_rules.go Update edit command ArgsType to reflect.TypeFor.
internal/namespaces/domain/v2beta1/custom_record_set.go Update DNS record set ArgsType to reflect.TypeFor.
internal/namespaces/domain/v2beta1/custom_record_delete.go Update DNS record delete ArgsType to reflect.TypeFor.
internal/namespaces/domain/v2beta1/custom_record_add.go Update DNS record add ArgsType to reflect.TypeFor.
internal/namespaces/container/v1/custom_logs.go Update logs command ArgsType to reflect.TypeFor.
internal/namespaces/container/v1/custom_deploy.go Update deploy command ArgsType to reflect.TypeFor.
internal/namespaces/config/commands.go Update config commands ArgsType to reflect.TypeFor; update getProfileKeys to use TypeFor.
internal/namespaces/cockpit/v1/custom_config_get.go Update cockpit config get ArgsType to reflect.TypeFor.
internal/namespaces/block/v1alpha1/custom_volume.go Update block volume wait ArgsType to reflect.TypeFor.
internal/namespaces/block/v1alpha1/custom_snapshot.go Update block snapshot wait ArgsType to reflect.TypeFor.
internal/namespaces/billing/v2beta1/custom_invoice_export.go Update invoice-export builder ArgsType to reflect.TypeFor.
internal/namespaces/billing/v2beta1/custom_invoice_download.go Update invoice-download builder ArgsType to reflect.TypeFor.
internal/namespaces/baremetal/v1/custom_server_install.go Update install builder ArgsType to reflect.TypeFor.
internal/namespaces/baremetal/v1/custom_server_fip.go Update flexible IP command ArgsType to reflect.TypeFor.
internal/namespaces/baremetal/v1/custom_server_create.go Update server create builder ArgsType to reflect.TypeFor.
internal/namespaces/baremetal/v1/custom_server.go Update server wait ArgsType to reflect.TypeFor.
internal/namespaces/autocomplete/autocomplete.go Update autocomplete commands ArgsType to reflect.TypeFor.
internal/namespaces/applesilicon/v1alpha1/custom_server_ssh.go Update AppleSilicon ssh ArgsType to reflect.TypeFor.
internal/namespaces/applesilicon/v1alpha1/custom_server.go Update AppleSilicon wait ArgsType to reflect.TypeFor.
internal/namespaces/alias/alias.go Update alias commands ArgsType to reflect.TypeFor.
internal/gofields/gofields_test.go Update gofields tests to use reflect.TypeFor for expected types.
internal/editor/request_test.go Update editor request test to use reflect.TypeFor.
internal/args/unmarshal.go Update unmarshal function registry keys to use reflect.TypeFor.
internal/args/marshal.go Update marshal function registry keys to use reflect.TypeFor.
internal/args/args_test.go Update args tests to use reflect.TypeFor for arg types.
core/validate_test.go Update validation tests to use reflect.TypeFor for ArgsType.
core/human/marshal_func.go Update marshaler func type registry and interface checks to reflect.TypeFor.
core/human/marshal.go Update interface checks in Marshal/marshalStruct to reflect.TypeFor.
core/cobra_utils_test.go Update cobra utils tests to use reflect.TypeFor for ArgsType.
core/cobra_usage_builder_test.go Update usage builder test to use reflect.TypeFor.
core/checks_test.go Update checks test to use reflect.TypeFor.
core/build_info_test.go Update build info test to use reflect.TypeFor.
core/bootstrap_test.go Update bootstrap tests to use reflect.TypeFor.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread core/human/marshal.go
Comment thread core/human/marshal.go
Comment thread core/human/marshal.go
Comment thread core/human/marshal_func.go
@estellesoulard

Copy link
Copy Markdown
Contributor

Searching for reflect.TypeOf( in this branch I still see many occurrences are remaining, is this deliberate?

@github-actions github-actions Bot added registry Managed Container Registry issues, bugs and feature requests rdb Managed MySQL and PostgreSQL issues, bugs and feature requests load-balancer Load-balancer issues, bugs and feature requests instance Instance issues, bugs and feature requests k8s Kubernetes Kapsule issues, bugs and feature requests vpc Virtual Private Cloud (VPC) issues, bugs and feature requests domain Domains issues, bugs and feature requests container Container issues, bugs and feature requests function Serverless function issues, bugs and feature requests redis Managed Redis issues, bugs and feature requests apple-silicon Apple Silicon issues, bugs and feature requests iam IAM issues, bugs and feature requests mnq Messaging and queuing issues, bugs and feature requests billing Billing issues, bugs and feature requests secret Managed Secret Manager issues, bugs and feature requests baremetal vpcgw labels Sep 2, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.81726% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.80%. Comparing base (44c7174) to head (f7f8158).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
internal/namespaces/test/v1/test_cli.go 0.00% 8 Missing ⚠️
internal/namespaces/autocomplete/autocomplete.go 0.00% 3 Missing ⚠️
...espaces/billing/v2beta1/custom_invoice_download.go 0.00% 1 Missing ⚠️
...amespaces/billing/v2beta1/custom_invoice_export.go 0.00% 1 Missing ⚠️
...nternal/namespaces/cockpit/v1/custom_config_get.go 0.00% 1 Missing ⚠️
...nal/namespaces/domain/v2beta1/custom_record_add.go 0.00% 1 Missing ⚠️
.../namespaces/domain/v2beta1/custom_record_delete.go 0.00% 1 Missing ⚠️
...nal/namespaces/domain/v2beta1/custom_record_set.go 0.00% 1 Missing ⚠️
...spaces/edge_services/v1beta1/custom_route_rules.go 0.00% 1 Missing ⚠️
...nternal/namespaces/jobs/v1alpha2/custom_job_run.go 0.00% 1 Missing ⚠️
... and 5 more
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6107   +/-   ##
=======================================
  Coverage   50.80%   50.80%           
=======================================
  Files         359      359           
  Lines       82260    82260           
=======================================
  Hits        41790    41790           
  Misses      40470    40470           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@remyleone
remyleone added this pull request to the merge queue Sep 3, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Sep 3, 2026
@remyleone
remyleone added this pull request to the merge queue Sep 3, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Sep 3, 2026
@remyleone
remyleone added this pull request to the merge queue Sep 4, 2026
Merged via the queue into main with commit 8f2d145 Sep 4, 2026
129 checks passed
@remyleone
remyleone deleted the type_for branch September 4, 2026 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

apple-silicon Apple Silicon issues, bugs and feature requests baremetal billing Billing issues, bugs and feature requests container Container issues, bugs and feature requests domain Domains issues, bugs and feature requests function Serverless function issues, bugs and feature requests iam IAM issues, bugs and feature requests instance Instance issues, bugs and feature requests k8s Kubernetes Kapsule issues, bugs and feature requests load-balancer Load-balancer issues, bugs and feature requests mnq Messaging and queuing issues, bugs and feature requests rdb Managed MySQL and PostgreSQL issues, bugs and feature requests redis Managed Redis issues, bugs and feature requests registry Managed Container Registry issues, bugs and feature requests secret Managed Secret Manager issues, bugs and feature requests vpc Virtual Private Cloud (VPC) issues, bugs and feature requests vpcgw

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants