Skip to content

Conversation

@chlins
Copy link
Member

@chlins chlins commented May 8, 2025

This pull request replaces all instances of the interface{} type with the any type across the codebase for improved readability and alignment with Go 1.18+ conventions. The changes span multiple files and functions, including core utilities, APIs, and test files.

Type Replacement: interface{} to any

Core API and Utility Functions:

  • Updated function parameters and return types in src/common/api/base.go to use any instead of interface{} for methods like DecodeJSONReq, Validate, and DecodeJSONReqAndValidate. [1] [2] [3]
  • Modified utility functions in src/common/utils/utils.go such as ConvertMapToStruct, SafeCastString, and SafeCastInt to replace interface{} with any. [1] [2] [3]

Data Structures and Models:

  • Replaced interface{} with any in type definitions like Parameters and Message in src/common/job/models/models.go. [1] [2]
  • Adjusted map types in configuration files (e.g., defaultConfig) to use map[string]any instead of map[string]interface{}. [1] [2]

HTTP Client and Logging:

  • Updated variadic parameters in HTTP client methods (Get, Post, Put) in src/common/http/client.go to use any. [1] [2] [3]
  • Changed logging function parameters in src/common/dao/base.go to use any.

Test Files:

  • Refactored test cases and mock data to replace interface{} with any in files like src/common/utils/utils_test.go and src/controller/artifact/annotation/v1alpha1_test.go. [1] [2]

These updates enhance code clarity and leverage Go's modern type system, making the codebase more idiomatic and easier to maintain.Thank you for contributing to Harbor!

Comprehensive Summary of your change

Issue being fixed

Fixes #(issue)

Please indicate you've done the following:

  • Well Written Title and Summary of the PR
  • Label the PR as needed. "release-note/ignore-for-release, release-note/new-feature, release-note/update, release-note/enhancement, release-note/community, release-note/breaking-change, release-note/docs, release-note/infra, release-note/deprecation"
  • Accepted the DCO. Commits without the DCO will delay acceptance.
  • Made sure tests are passing and test coverage is added if needed.
  • Considered the docs impact and opened a new docs issue or PR with docs changes if needed in website repository.

@chlins chlins requested a review from a team as a code owner May 8, 2025 03:06
@chlins chlins added the release-note/update Update or Fix label May 8, 2025
@codecov
Copy link

codecov bot commented May 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 46.46%. Comparing base (c8c11b4) to head (7eee411).
Report is 472 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #21973      +/-   ##
==========================================
+ Coverage   45.36%   46.46%   +1.09%     
==========================================
  Files         244      253       +9     
  Lines       13333    14236     +903     
  Branches     2719     2924     +205     
==========================================
+ Hits         6049     6615     +566     
- Misses       6983     7272     +289     
- Partials      301      349      +48     
Flag Coverage Δ
unittests 46.46% <ø> (+1.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

see 178 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@wy65701436 wy65701436 left a comment

Choose a reason for hiding this comment

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

lgtm

@chlins chlins force-pushed the refactor/any branch 2 times, most recently from 9a79529 to 7029fef Compare May 8, 2025 07:12
@chlins chlins enabled auto-merge (squash) May 8, 2025 07:13
@chlins chlins force-pushed the refactor/any branch 5 times, most recently from 1328afd to 0f36bf7 Compare May 8, 2025 10:26
@chlins chlins merged commit 9e18bbc into goharbor:main May 8, 2025
18 checks passed
wy65701436 pushed a commit to wy65701436/harbor that referenced this pull request May 16, 2025
OrlinVasilev pushed a commit to OrlinVasilev/harbor that referenced this pull request Oct 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note/update Update or Fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants