Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
LandonTClipp committed Aug 4, 2023
1 parent f624c4b commit d7818e4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
10 changes: 2 additions & 8 deletions cmd/mockery.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,8 @@ func (r *RootApp) Run() error {
return fmt.Errorf("failed to determine configured packages: %w", err)
}
if len(configuredPackages) != 0 {
// Check for unsupported config options
if unsupported := r.Config.CheckUnsupportedPackagesConfig(ctx); len(unsupported) != 0 {
l := log.With().
Dict("unsupported-fields", zerolog.Dict().Fields(unsupported)).
Str("url", logging.DocsURL("/configuration/#parameter-descriptions")).
Logger()
l.Error().Msg("use of unsupported options detected. mockery behavior is undefined.")
}
r.Config.LogUnsupportedPackagesConfig(ctx)

configuredPackages, err := r.Config.GetPackages(ctx)
if err != nil {
return fmt.Errorf("failed to get package from config: %w", err)
Expand Down
16 changes: 13 additions & 3 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -713,10 +713,11 @@ func (c *Config) TagName(name string) string {
return string(field.Tag.Get("mapstructure"))

Check warning on line 713 in pkg/config/config.go

View check run for this annotation

Codecov / codecov/patch

pkg/config/config.go#L713

Added line #L713 was not covered by tests
}

// CheckUnsupportedPackagesConfig is a method that will help aid migrations to the
// LogUnsupportedPackagesConfig is a method that will help aid migrations to the
// packages config feature. This is intended to be a temporary measure until v3
// when we can remove all legacy config options.
func (c *Config) CheckUnsupportedPackagesConfig(ctx context.Context) map[string]any {
func (c *Config) LogUnsupportedPackagesConfig(ctx context.Context) {
log := zerolog.Ctx(ctx)
unsupportedOptions := make(map[string]any)
for _, name := range []string{"Name", "KeepTree", "Case", "Output", "TestOnly"} {
value := reflect.ValueOf(c).Elem().FieldByName(name)
Expand All @@ -732,5 +733,14 @@ func (c *Config) CheckUnsupportedPackagesConfig(ctx context.Context) map[string]
unsupportedOptions[c.TagName(name)] = valueAsString
}

Check warning on line 734 in pkg/config/config.go

View check run for this annotation

Codecov / codecov/patch

pkg/config/config.go#L732-L734

Added lines #L732 - L734 were not covered by tests
}
return unsupportedOptions
if len(unsupportedOptions) == 0 {
return
}

Check warning on line 738 in pkg/config/config.go

View check run for this annotation

Codecov / codecov/patch

pkg/config/config.go#L736-L738

Added lines #L736 - L738 were not covered by tests

l := log.With().
Dict("unsupported-fields", zerolog.Dict().Fields(unsupportedOptions)).
Str("url", logging.DocsURL("/configuration/#parameter-descriptions")).
Logger()
l.Error().Msg("use of unsupported options detected. mockery behavior is undefined.")

Check warning on line 744 in pkg/config/config.go

View check run for this annotation

Codecov / codecov/patch

pkg/config/config.go#L740-L744

Added lines #L740 - L744 were not covered by tests

}
2 changes: 2 additions & 0 deletions pkg/outputter.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ func (m *Outputter) Generate(ctx context.Context, iface *Interface) error {
}

for _, interfaceConfig := range interfaceConfigs {
interfaceConfig.LogUnsupportedPackagesConfig(ctx)

log.Debug().Msg("getting mock generator")

if err := parseConfigTemplates(ctx, interfaceConfig, iface); err != nil {
Expand Down

0 comments on commit d7818e4

Please sign in to comment.