Skip to content

Conversation

@polatengin
Copy link
Contributor

  • Consolidated array helper functions into the helpers package and standardize names (ArrayDiff, ArrayContains, ArrayExcept, ArrayFind, etc.).
  • Remove redundant slice helper and update usages in API and services.
  • Harden request handling for unexpected nil responses.

@polatengin polatengin self-assigned this Jan 21, 2026
@polatengin polatengin requested a review from a team as a code owner January 21, 2026 01:08
Copilot AI review requested due to automatic review settings January 21, 2026 01:08
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR consolidates array helper functions from a separate internal/helpers/array package and the standalone contains.go file into a unified internal/helpers/array.go file within the main helpers package. The refactoring standardizes function naming with an "Array" prefix and updates all usages across the codebase. Additionally, it includes a safety improvement for handling unexpected nil responses in API request processing.

Changes:

  • Consolidated array utility functions (ArrayDiff, ArrayContains, ArrayExcept, ArrayFind) into the helpers package with standardized naming
  • Removed the separate internal/helpers/array package and contains.go file
  • Updated all function calls across API clients and service resources to use the new naming convention
  • Improved nil response handling in internal/api/request.go by checking for nil before creating Response struct

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
internal/helpers/array.go Moved from package array to package helpers and renamed all functions with "Array" prefix for consistency
internal/helpers/contains.go Deleted - functionality merged into array.go as ArrayContains with generic implementation
internal/api/client.go Updated to use helpers.ArrayContains instead of array.Contains and removed array package import
internal/api/request.go Moved nil response check before Response struct creation for improved safety
internal/services/authorization/api_user.go Updated to use helpers.ArrayFind and removed array package import
internal/services/authorization/resource_user.go Updated to use helpers.ArrayDiff and helpers.ArrayExcept, removed array package import
internal/services/managed_environment/resource_managed_environment.go Updated to use helpers.ArrayContains instead of helpers.Contains
Comments suppressed due to low confidence (1)

internal/helpers/array.go:70

  • The array helper functions lack unit test coverage. Following the project's testing pattern (where other helper files like config.go, hash.go, contexts.go, and string_to_set.go have corresponding test files), you should create an array_test.go file with unit tests for ArrayDiff, ArrayContains, ArrayExcept, and ArrayFind functions. This is especially important since these are core utility functions that are now used across multiple services in the codebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants