Skip to content

Add an option for indicating a direct replacement of a deprecated variable. #53

@jmalloc

Description

@jmalloc
old := ferrite.
    Duration("OLD", "example duration variable").
    Deprecated(
        WithDirectReplacement(new),
    )

new := ferrite.
    Duration("NEW", "example duration variable").
    Deprecated()

The goal here is twofold:

  1. Allow documentation to point to the replacement environment variable
  2. Surface the value of the new variable via the old.DeprecatedValue() method

Resolution logic for old.DeprecatedValue() pseudo code

if OLD is defined {
  if OLD matches schema of OLD {
    return OLD
  }
  return error
}

if NEW is defined {
  if NEW matches schema of OLD {
    return NEW
  }

  // we _could_ optionally return nil here indicating no value is available,
  // but I think that would be less useful
  return error 
}

return nil

The behavior of NEW is unaffected, it is unaware that it is the replacement for OLD.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions