fix(agent/file): NewIFileService should return IFileService, not FileService#12648
fix(agent/file): NewIFileService should return IFileService, not FileService#12648eddieran wants to merge 1 commit into1Panel-dev:dev-v2from
Conversation
`NewIFileService` returns the bare struct type `FileService`, but its
body returns a pointer (`&FileService{}`), and the function name suggests
it should return the interface (`IFileService`). The current signature
breaks `go build ./...` on the `agent` module:
app/service/file.go:95:9: cannot use &FileService{} (value of type
*FileService) as FileService value in return statement
app/service/website_proxy.go:276:36: cannot call pointer method
GetFileList on FileService
Both errors resolve when the constructor returns the interface, since
`*FileService` implements every method on `IFileService` (verified with
`go vet ./...`).
After this change, `go build ./...` and `go vet ./...` are clean on the
`agent` module.
|
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. DetailsInstructions 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 kubernetes-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Summary
agent/app/service/file.go:94declares the constructor with a bare struct return type:But the body returns a pointer (
&FileService{}), and the function name (NewIFileService) suggests the caller should receive the interface (IFileService).Repro
`go build ./...` on the `agent` module currently fails:
The second error is a downstream consequence:
website_proxy.go:276callsNewIFileService().GetFileList(...), which fails becauseGetFileListhas a pointer receiver butNewIFileServiceis declared to return a value.Fix
One-line change: declare the return type as the interface.
*FileServiceimplements every method onIFileService(verified withgo vet ./...).Verification
go build ./...— cleango vet ./...— cleanNotes
This regression appears to have been introduced in commit `e57dc12` (#12529 area). No other call sites of `NewIFileService` reference the concrete type; switching to the interface is fully source-compatible with existing consumers.