Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix config issue with type conversion and deprecation warnings #897

Merged
merged 2 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions cmd/mockery.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,11 @@ func (r *RootApp) Run() error {
boilerplate = string(data)
}

if r.Config.Packages == nil {
configuredPackages, err := r.Config.GetPackages(ctx)
if err != nil && !errors.Is(err, os.ErrNotExist) {
return fmt.Errorf("failed to determine configured packages: %w", err)
}
if len(configuredPackages) == 0 {
logging.WarnDeprecated(
"packages",
"use of the packages config will be the only way to generate mocks in v3. Please migrate your config to use the packages feature.",
Expand All @@ -241,13 +245,7 @@ func (r *RootApp) Run() error {
"migration": logging.DocsURL("/migrating_to_packages/"),
},
)
}

configuredPackages, err := r.Config.GetPackages(ctx)
if err != nil && !errors.Is(err, os.ErrNotExist) {
return fmt.Errorf("failed to determine configured packages: %w", err)
}
if len(configuredPackages) != 0 {
} else {
r.Config.LogUnsupportedPackagesConfig(ctx)

configuredPackages, err := r.Config.GetPackages(ctx)
Expand Down
2 changes: 1 addition & 1 deletion mockery-tools.env
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION=v2.51.0
VERSION=v2.51.1
10 changes: 8 additions & 2 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -502,8 +502,14 @@ func (c *Config) addSubPkgConfig(ctx context.Context, subPkgPath string, parentP
log.Trace().Msgf("parent-package config: %v", parentPkgConfig)

// Merge the parent config with the sub-package config.
parentConfigSection := parentPkgConfig["config"].(map[string]any)
subPkgConfigSection := subPkgConfig["config"].(map[string]any)
parentConfigSection, ok := parentPkgConfig["config"].(map[string]any)
if !ok {
parentConfigSection = map[string]any{}
}
subPkgConfigSection, ok := subPkgConfig["config"].(map[string]any)
if !ok {
subPkgConfigSection = map[string]any{}
}
for key, val := range parentConfigSection {
if _, keyInSubPkg := subPkgConfigSection[key]; !keyInSubPkg {
subPkgConfigSection[key] = val
Expand Down
Loading