refactor: extract business logic to service package#144
Merged
arielsepton merged 7 commits intocrossplane-contrib:mainfrom Nov 17, 2025
Merged
Conversation
Signed-off-by: arielsepton <arielsepton1@gmail.com>
Resolved conflicts in disposablerequest controller by keeping refactored service layer implementation. All business logic has been moved to internal/service/disposablerequest package. Signed-off-by: arielsepton <arielsepton1@gmail.com>
76ff3e2 to
adaf4ff
Compare
…vices Signed-off-by: Ariel Septon <64063409+arielsepton@users.noreply.github.com>
…, headers, body, and error Signed-off-by: arielsepton <arielsepton1@gmail.com>
5ff806a to
127fd45
Compare
…idation Signed-off-by: arielsepton <arielsepton1@gmail.com>
127fd45 to
069403f
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the HTTP provider to extract business logic from controllers into a dedicated service layer. The refactoring introduces common interfaces to abstract differences between Request and DisposableRequest types, enabling code reuse and preparing the codebase for Crossplane v2 namespace-scoped resources support.
Key Changes:
- Introduced interface-based abstraction layer in
apis/interfaces/spec_accessors.gowith implementations across all API versions - Extracted business logic from controllers to new
internal/servicepackage with resource-specific subdirectories - Simplified controllers to delegate to service layer functions, reducing code duplication
Reviewed Changes
Copilot reviewed 43 out of 45 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
apis/interfaces/spec_accessors.go |
Defines common interfaces for HTTP request specs, responses, and status management |
apis/*/spec_accessors.go |
Implements interface methods for all API versions (v1alpha1, v1alpha2) |
apis/common/constants.go |
Centralizes action and response check type constants |
internal/service/request/*.go |
Request resource business logic (observe, deploy, status handling) |
internal/service/disposablerequest/*.go |
DisposableRequest resource business logic (observe, deploy, validation) |
internal/controller/*/*.go |
Simplified controllers delegating to service layer |
internal/utils/set_status.go |
Updated to use new interfaces instead of local types |
internal/data-patcher/patch.go |
Updated to work with interface types |
internal/clients/http/client.go |
Added HTTPResponse interface implementation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ricCap
approved these changes
Nov 15, 2025
Contributor
ricCap
left a comment
There was a problem hiding this comment.
LGTM, thanks for the changes
Signed-off-by: arielsepton <arielsepton1@gmail.com>
Signed-off-by: arielsepton <arielsepton1@gmail.com>
830a7a0 to
6add0b4
Compare
ricCap
approved these changes
Nov 15, 2025
barunavo
pushed a commit
to barunavo/provider-http
that referenced
this pull request
Nov 17, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR refactors the HTTP provider to extract business logic from controllers into a dedicated service layer. This architectural change prepares the codebase to support namespace-scoped resources in Crossplane v2 by making the core HTTP request/response logic reusable across both cluster-scoped and namespace-scoped resource controllers.
Related to #141
Changes
Core Refactoring
internal/controllertointernal/serviceapis/interfaces/spec_accessors.gowith interfaces (HTTPRequestSpec,SimpleHTTPRequestSpec,MappedHTTPRequestSpec) that abstract differences between Request and DisposableRequest typesService Package Structure
New
internal/servicepackage with resource-specific subdirectories:internal/service/request/- Request resource business logicdeployaction.go- Action deployment (create/update/delete)observe.go- Observation and up-to-date checkingobserve/,requestgen/,requestmapping/,statushandler/internal/service/disposablerequest/- DisposableRequest resource business logicdeployaction.go- Action deploymentobserve.go- Observation logicvalidation.go- Validation logicController Simplification
Controllers now delegate to service layer functions:
internal/controller/request/request.go- Reduced from ~750 to ~40 lines of business logicinternal/controller/disposablerequest/disposablerequest.go- Simplified significantlyobserve.go,responseconverter/from controllers (moved to service layer)Testing