MCPcopy
hub / github.com/vektra/mockery / migrateConfig

Function migrateConfig

internal/cmd/migrate.go:286–415  ·  view source on GitHub ↗
(
	ctx context.Context,
	tbl *tableWriter,
	v2Config *V2Config,
	v3Config **config.Config,
)

Source from the content-addressed store, hash-verified

284}
285
286func migrateConfig(
287 ctx context.Context,
288 tbl *tableWriter,
289 v2Config *V2Config,
290 v3Config **config.Config,
291) {
292 if v2Config == nil {
293 return
294 }
295 checkDeprecatedTemplateVariables(ctx, v2Config, tbl)
296
297 // We do this so we can lazily create a new `config` section if necessary.
298 // It's kind of gross, but the double pointer is necessary to update the struct
299 // that contains the *config.Config pointer.
300 if *v3Config == nil {
301 *v3Config = &config.Config{}
302 }
303 v3 := *v3Config
304 v3.All = v2Config.All
305 v3.Anchors = v2Config.Anchors
306 if v2Config.BoilerplateFile != nil {
307 if v3.TemplateData == nil {
308 v3.TemplateData = map[string]any{}
309 }
310 v3.TemplateData["boilerplate-file"] = v2Config.BoilerplateFile
311 }
312
313 if v2Config.BuildTags != nil {
314 tbl.Append("deprecated-parameter", "`tags` is no longer supported, parameter not migrated. Use `template-data.mock-build-tags` instead.")
315 }
316 if v2Config.Case != nil {
317 tbl.Append("deprecated-parameter", "`case` is no longer supported. Use `structname` to specify the name and exported-ness of the output mocks.")
318 }
319 v3.ConfigFile = v2Config.Config
320 if v2Config.Cpuprofile != nil {
321 tbl.Append("deprecated-parameter", "`cpuprofile` is not supported in v3, however we welcome PRs to implement the feature: https://github.com/vektra/mockery/issues/956")
322 }
323 v3.Dir = v2Config.Dir
324 if v2Config.DisableConfigSearch != nil {
325 tbl.Append("deprecated-parameter", "`disable-config-search` is permanently disabled in v3.")
326 }
327 // disable-deprecation-warnings: no deprecations in v3
328 // disabled-deprecation-warnings: no deprecations in v3
329 if v2Config.DisableFuncMocks == nil || !*v2Config.DisableFuncMocks {
330 tbl.Append("deprecated-parameter", "`disable-func-mocks` permanently enabled in v3.")
331 }
332 if v2Config.DisableVersionString == nil || !*v2Config.DisableVersionString {
333 tbl.Append("deprecated-parameter", "`disable-version-string` is permanently set to True in v3.")
334 }
335 if v2Config.DryRun != nil && *v2Config.DryRun {
336 tbl.Append("deprecated-parameter", "`dry-run` not supported in v3.")
337 }
338 v3.ExcludeSubpkgRegex = v2Config.Exclude
339 v3.ExcludeInterfaceRegex = v2Config.ExcludeRegex
340 if v2Config.Exported != nil {
341 tbl.Append("deprecated-parameter", "`exported` is no longer supported. Use `structname` instead.")
342 }
343 if v2Config.FailOnMissing == nil || (v2Config.FailOnMissing != nil && *v2Config.FailOnMissing == false) {

Callers 1

runFunction · 0.85

Calls 2

AppendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…