Skip to content
This repository was archived by the owner on Sep 9, 2026. It is now read-only.

NO-ISSUE: Use new(expression) for remaining proto.Int32 calls - #617

Merged
openshift-merge-bot[bot] merged 1 commit into
osac-project:mainfrom
jhernand:use_new_expression_for_proto_int32
Jun 3, 2026
Merged

openshift-merge-bot[bot] merged 1 commit into
osac-project:mainfrom
jhernand:use_new_expression_for_proto_int32

Conversation

@jhernand

@jhernand jhernand commented May 31, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Continue the modernization started in #610 by replacing the remaining proto.Int32(value) calls
with the new(int32(value)) built-in syntax introduced in Go 1.26. This also removes the
now-unused "google.golang.org/protobuf/proto" imports from files where proto.Int32 was the last
usage of that package.

Test plan

  • Verify that the project compiles successfully.
  • Run unit tests with ginkgo run -r internal.

Summary by CodeRabbit

  • Refactor
    • Updated internal code across CLI commands, gRPC servers, and test suites to use native Go pointer allocation for integer fields.
    • Changes apply to pagination parameters (Limit, Offset), compute instance specifications (Cores, MemoryGib), and security rule configurations.
    • End-user functionality and public APIs remain completely unchanged.

Continue the modernization started in 76d1516 by replacing the remaining
`proto.Int32(value)` calls with the `new(int32(value))` built-in syntax
introduced in Go 1.26. This also removes the now-unused
`"google.golang.org/protobuf/proto"` imports from files where
`proto.Int32` was the last usage of that package.

Assisted-by: Cursor
Signed-off-by: Juan Hernandez <juan.hernandez@redhat.com>
@openshift-ci-robot

Copy link
Copy Markdown

@jhernand: This pull request explicitly references no jira issue.

Details

In response to this:

Summary

Continue the modernization started in #610 by replacing the remaining proto.Int32(value) calls
with the new(int32(value)) built-in syntax introduced in Go 1.26. This also removes the
now-unused "google.golang.org/protobuf/proto" imports from files where proto.Int32 was the last
usage of that package.

Test plan

  • Verify that the project compiles successfully.
  • Run unit tests with ginkgo run -r internal.

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 openshift-eng/jira-lifecycle-plugin repository.

@coderabbitai

coderabbitai Bot commented May 31, 2026 •

Copy link
Copy Markdown

Review Change Stack

Walkthrough

This PR removes a dependency on the google.golang.org/protobuf/proto package by systematically replacing proto.Int32(...) helper calls with Go's native new(int32(...)) pointer allocation across CLI commands, server tests, controllers, and utility files.

Changes

Proto Helper Removal and Native Pointer Allocation

Layer / File(s) Summary
CLI Commands List Request Limit Construction
internal/cmd/cli/console/connect/resolve.go, internal/cmd/cli/describe/cluster/describe_cluster.go, internal/cmd/cli/describe/computeinstance/describe_computeinstance_cmd.go, internal/cmd/cli/get/kubeconfig/get_kubeconfig_cmd.go, internal/cmd/cli/get/password/get_password_cmd.go, internal/cmd/cli/create/cluster/create_cluster_cmd.go, internal/cmd/cli/create/computeinstance/create_compute_instance_cmd.go
CLI commands that construct gRPC list requests now use new(int32(...)) for Limit and Offset fields instead of proto.Int32(...), and the google.golang.org/protobuf/proto import is removed.
CLI Test Files and Security Group Display
internal/cmd/cli/describe/securitygroup/describe_securitygroup_test.go
Test and display files update security rule port fields to use new(int32(...)) instead of proto.Int32(...) and remove the proto import.
Server Tests Pagination Fields
internal/servers/*_server_test.go (cluster catalog items, cluster templates, clusters, compute instance catalog items, compute instance templates, host types, network classes, private variants, public IP attachments, public IPs, subnets, virtual networks)
All server test files update list request pagination (Limit, Offset) to use new(int32(...)) instead of proto.Int32(...) and remove the proto import where present.
Server Tests Instance and Template Spec Defaults
internal/servers/compute_instances_server_test.go, internal/servers/private_compute_instances_server_test.go, internal/servers/security_groups_server_test.go
Server tests that construct instance specs and security rules now use new(int32(...)) for resource defaults and port fields instead of proto.Int32(...) and remove the proto import dependency.
Controller, Utility, and Integration Tests
internal/controllers/project/project_reconciler_function.go, internal/controllers/computeinstance/computeinstance_reconciler_function_test.go, internal/utils/spec_defaults_test.go, it/it_compute_subnet_test.go
Controller and utility code replace proto.Int32(...) with new(int32(...)) for instance spec fields, list request limits, and validation test fixtures, and the proto import is removed.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • osac-project/fulfillment-service#610: Both PRs update the same pattern—replacing google.golang.org/protobuf/proto helper pointer creation with Go's new(...) syntax, including in shared request-building paths.
  • osac-project/fulfillment-service#414: This PR's updates to internal/utils/spec_defaults_test.go directly touch the same file introduced by the template-spec-defaults feature work.

Suggested labels

approved, lgtm

Suggested reviewers

  • eranco74
  • trewest
  • adriengentil

🔧 Proto helpers traded for native pointers,
Through CLI, server, and test—no capers!
Go's new() now claims the stage,
Tidier imports mark this refactoring age. ✨

🚥 Pre-merge checks | ✅ 11
✅ Passed checks (11 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: replacing proto.Int32 calls with Go's new() expression syntax across the codebase.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
No-Hardcoded-Secrets ✅ Passed PR refactors numeric pointer allocations only (1,2,5,10,53,80,443). No API keys, tokens, passwords, credentials, or base64 secrets detected. Import removals are safe cleanup.
No-Weak-Crypto ✅ Passed PR contains no cryptographic code. Changes are purely protobuf syntax modernization, replacing proto.Int32() with new(int32()) and removing unused imports.
No-Injection-Vectors ✅ Passed PR contains only syntax refactoring: replacing proto.Int32() with new(int32()) and removing proto imports. No injection vectors detected.
Container-Privileges ✅ Passed PR contains only Go source code changes (proto.Int32 → new(int32) refactoring), no K8s manifests, Dockerfiles, or container privilege configurations modified. Container security check not applicable.
No-Sensitive-Data-In-Logs ✅ Passed PR replaces proto.Int32() with new(int32()) syntax. No logging statements output passwords, tokens, keys, or PII. Error messages reference file paths/query terms only, not sensitive data.
Ai-Attribution ✅ Passed AI tool (Cursor) used and properly attributed via Assisted-by trailer in commit 3ba90f1. No incorrect Co-Authored-By for AI. Signed by Red Hat employee.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci

openshift-ci Bot commented Jun 1, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: adriengentil, jhernand

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

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [adriengentil,jhernand]

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

@jhernand

jhernand commented Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

/retest

12 similar comments
@omer-vishlitzky

Copy link
Copy Markdown
Contributor

/retest

@omer-vishlitzky

Copy link
Copy Markdown
Contributor

/retest

@omer-vishlitzky

Copy link
Copy Markdown
Contributor

/retest

@omer-vishlitzky

Copy link
Copy Markdown
Contributor

/retest

@omer-vishlitzky

Copy link
Copy Markdown
Contributor

/retest

@omer-vishlitzky

Copy link
Copy Markdown
Contributor

/retest

@omer-vishlitzky

Copy link
Copy Markdown
Contributor

/retest

@omer-vishlitzky

Copy link
Copy Markdown
Contributor

/retest

@omer-vishlitzky

Copy link
Copy Markdown
Contributor

/retest

@omer-vishlitzky

Copy link
Copy Markdown
Contributor

/retest

@omer-vishlitzky

Copy link
Copy Markdown
Contributor

/retest

@jhernand

jhernand commented Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

/retest

@openshift-merge-bot
openshift-merge-bot Bot merged commit cc0688d into osac-project:main Jun 3, 2026
13 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants