Skip to content

Refactor new clients#537

Merged
Tinyblargon merged 3 commits intoTelmate:masterfrom
Tinyblargon:refactor-new-clients
Jan 18, 2026
Merged

Refactor new clients#537
Tinyblargon merged 3 commits intoTelmate:masterfrom
Tinyblargon:refactor-new-clients

Conversation

@Tinyblargon
Copy link
Collaborator

  • Remove the SelectX functions as they lead to inefficient code.
  • Renamed FormatArray and FormatMap to AsArray and AsMap.
  • Add iterators.

The `Select` functions are removed as they lead to less efficient code
@Tinyblargon Tinyblargon requested a review from Copilot January 18, 2026 20:17
@Tinyblargon Tinyblargon added type/enhancement An improvement of existing functionality type/refactoring Existing code has been cleaned up. There should be no new functionality modifies/go Pull requests that update Go code size/L Denotes a PR that changes 100-499 lines, ignoring generated files test/done This PR has been tested and the result was succesfull labels Jan 18, 2026
@Tinyblargon Tinyblargon merged commit 43689ce into Telmate:master Jan 18, 2026
9 checks passed
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 refactors the client interfaces for Users, Groups, and API Tokens to improve code efficiency and consistency. The changes remove inefficient selection methods in favor of standard map operations and add support for Go 1.23+ iterators.

Changes:

  • Removed SelectX functions (SelectUser, SelectName) which led to O(n) lookup performance for each call
  • Renamed FormatArray and FormatMap to more idiomatic AsArray and AsMap
  • Added Iter() methods that return iter.Seq[T] for efficient iteration over raw data structures

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
proxmox/config__user.go Updated RawUsersInfo interface: removed SelectUser, renamed formatting methods, added Iter()
proxmox/config__group.go Updated RawGroups interface: removed SelectName, renamed formatting methods, added Iter()
proxmox/config__apiToken.go Updated RawApiTokens interface: removed SelectName, renamed formatting methods, added Iter()
proxmox/config__user_test.go Refactored tests: renamed test functions, removed SelectUser tests, added comprehensive iterator tests
proxmox/config__group_test.go Refactored tests: renamed test functions, removed SelectName tests, added iterator tests, fixed test data (members array)
proxmox/config__apiToken_test.go Refactored tests: renamed test functions, removed SelectName tests, added comprehensive iterator tests
test/api/User/list_user_test.go Updated to use AsMap() instead of SelectUser() for efficient lookups
test/api/Group/list_group_test.go Updated to use AsMap()[key] instead of SelectName()
test/api/Group/create_group_test.go Updated to use AsMap()[key] instead of SelectName()
test/api/ApiToken/list_token_test.go Updated to use AsMap() instead of FormatMap()
main.go Updated to use AsArray() instead of FormatArray()
cli/command/list/list-users.go Updated to use AsArray() instead of FormatArray()
cli/command/list/list-tokens.go Updated to use AsArray() instead of FormatArray()
cli/command/list/list-groups.go Updated to use AsArray() instead of FormatArray()

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


func Test_RawGroups_FormatArray(t *testing.T) {
tests := []struct {
func test_RawGroups_Array_Data() []struct {
Copy link

Copilot AI Jan 18, 2026

Choose a reason for hiding this comment

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

The function name should be test_rawGroups_Array_Data (lowercase 'r') to maintain consistency with the naming convention used in similar helper functions in config__user_test.go (test_rawUsersInfo_Array_Data) and config__apiToken_test.go (test_rawApiTokens_Array_Data).

Suggested change
func test_RawGroups_Array_Data() []struct {
func test_rawGroups_Array_Data() []struct {

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

modifies/go Pull requests that update Go code size/L Denotes a PR that changes 100-499 lines, ignoring generated files test/done This PR has been tested and the result was succesfull type/enhancement An improvement of existing functionality type/refactoring Existing code has been cleaned up. There should be no new functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants