Skip to content

feat: [#823] register service providers to bootstrap/providers.go - #115

Merged
hwbrzzl merged 1 commit into
masterfrom
bowen/#823
Dec 5, 2025
Merged

feat: [#823] register service providers to bootstrap/providers.go#115
hwbrzzl merged 1 commit into
masterfrom
bowen/#823

Conversation

@hwbrzzl

@hwbrzzl hwbrzzl commented Dec 5, 2025

Copy link
Copy Markdown
Contributor

📑 Description

Closes goravel/goravel#823

This pull request updates dependencies and refactors the setup logic for integrating MinIO with the Goravel framework. The most significant changes are dependency upgrades in go.mod and a more flexible, environment-aware setup process in setup/setup.go.

Dependency updates and additions:

  • Upgraded Go version to 1.24.0 and updated several direct and indirect dependencies, including github.com/goravel/framework, github.com/fsnotify/fsnotify, github.com/pelletier/go-toml/v2, github.com/pterm/pterm, github.com/sagikazarmark/locafero, github.com/sourcegraph/conc, github.com/spf13/afero, github.com/spf13/cast, github.com/spf13/pflag, github.com/spf13/viper, github.com/urfave/cli/v3, golang.org/x/crypto, golang.org/x/net, golang.org/x/text, and others. Several new indirect dependencies were also added, such as github.com/charmbracelet/bubbletea, github.com/samber/lo, and more. [1] [2] [3]

Setup process refactor:

  • Refactored setup/setup.go to use environment-aware logic for registering the MinIO service provider, supporting both bootstrap and non-bootstrap setups. This includes conditional registration and unregistration of the provider in either app.go or providers.go based on the environment, and improved handling of configuration and imports for the MinIO disk in filesystems.go. [1] [2]
image

✅ Checks

  • Added test cases for my code

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds support for registering service providers to bootstrap/providers.go while maintaining backward compatibility with the traditional app.go registration approach. The implementation uses environment-aware conditional logic to determine which registration method to use.

Key changes:

  • Refactored setup logic to support both bootstrap and non-bootstrap provider registration patterns
  • Upgraded dependencies including goravel/framework and numerous indirect dependencies
  • Improved code organization by moving package-level variables into function scope

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
setup/setup.go Refactored provider registration logic to conditionally register MinIO service provider in either app.go or bootstrap/providers.go based on environment setup detection
go.mod Updated Go version to 1.24.0 and upgraded goravel/framework plus numerous indirect dependencies for compatibility
go.sum Updated checksums corresponding to all dependency changes in go.mod

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

Comment thread setup/setup.go
Comment on lines +40 to +79
modify.When(func(_ map[string]any) bool {
return !env.IsBootstrapSetup()
}, modify.GoFile(appConfigPath).
Find(match.Imports()).Modify(modify.AddImport(modulePath)).
Find(match.Providers()).Modify(modify.Register(minioServiceProvider))),

// Add minio service provider to providers.go if using bootstrap setup
modify.When(func(_ map[string]any) bool {
return env.IsBootstrapSetup()
}, modify.AddProviderApply(modulePath, minioServiceProvider)),

// Add minio disk to filesystems.go
modify.GoFile(filesystemsConfigPath).Find(match.Imports()).Modify(
modify.AddImport(filesystemContract),
modify.AddImport(minioFacades, "miniofacades"),
).
Find(filesystemsDisksConfig).Modify(modify.AddConfig("minio", config)).
Find(filesystemsConfig).Modify(modify.AddConfig("default", `"minio"`)),
).
Uninstall(
modify.GoFile(path.Config("app.go")).
Find(match.Providers()).Modify(modify.Unregister("&minio.ServiceProvider{}")).
Find(match.Imports()).Modify(modify.RemoveImport(packages.GetModulePath())),
modify.GoFile(path.Config("filesystems.go")).
Find(match.Config("filesystems.disks")).Modify(modify.RemoveConfig("minio")).
Find(match.Imports()).Modify(modify.RemoveImport("github.com/goravel/framework/contracts/filesystem"), modify.RemoveImport("github.com/goravel/minio/facades", "miniofacades")).
Find(match.Config("filesystems")).Modify(modify.AddConfig("default", `"local"`)),
// Remove minio disk from filesystems.go
modify.GoFile(filesystemsConfigPath).
Find(filesystemsConfig).Modify(modify.AddConfig("default", `"local"`)).
Find(filesystemsDisksConfig).Modify(modify.RemoveConfig("minio")).
Find(match.Imports()).Modify(
modify.RemoveImport(filesystemContract),
modify.RemoveImport(minioFacades, "miniofacades"),
),

// Remove minio service provider from app.go if not using bootstrap setup
modify.When(func(_ map[string]any) bool {
return !env.IsBootstrapSetup()
}, modify.GoFile(appConfigPath).
Find(match.Providers()).Modify(modify.Unregister(minioServiceProvider)).
Find(match.Imports()).Modify(modify.RemoveImport(modulePath))),

// Remove minio service provider from providers.go if using bootstrap setup
modify.When(func(_ map[string]any) bool {
return env.IsBootstrapSetup()
}, modify.RemoveProviderApply(modulePath, minioServiceProvider)),

Copilot AI Dec 5, 2025

Copy link

Choose a reason for hiding this comment

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

[nitpick] The duplication of the conditional logic env.IsBootstrapSetup() in lines 41, 48, 71, and 78 could be reduced by extracting this check into a variable at the beginning of the function. This would make the code more maintainable and easier to test. For example:

isBootstrapSetup := env.IsBootstrapSetup()

Then use isBootstrapSetup and !isBootstrapSetup in the modify.When conditions.

Copilot uses AI. Check for mistakes.
@hwbrzzl
hwbrzzl merged commit fe184ec into master Dec 5, 2025
9 checks passed
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.

Sub-packages should register service providers to bootstrap/providers.go

2 participants