Skip to content

2.0.0: New Prefix Support

Choose a tag to compare

@chadweimer chadweimer released this 05 Sep 23:55
· 4 commits to main since this release
449b075

馃挜 BREAKING CHANGES 馃挜

This release includes breaking changes to the way prefixes are supported, as well as slight adjustments to several method names.

  1. Removed *Env suffix from some names
    • WithLookupEnv is now named WithLookup
    • MapLookupEnv is now named MapLookup
    • CompositeLookupEnv is now named CompositeLookup
  2. Removed WithPrefix, WithPrefixHandling, SetPrefix, and NewWithPrefix.
    // OLD
    vary.New(vary.WithPrefix("MYAPP"))
    // or
    vary.New(vary.WithPrefix("MYAPP"), vary.WithPrefixHandling(vary.PrefixHandlingPrimary))
    
    // NEW
    vary.New(vary.WithLookup(
      vary.CompositeLookup(vary.PrefixedLookup("MYAPP_", os.LookupEnv), os.LookupEnv)))
    // OLD
    vary.New(vary.WithPrefix("MYAPP"), vary.WithPrefixHandling(vary.PrefixHandlingSecondary))
    
    // NEW
    vary.New(vary.WithLookup(
      vary.CompositeLookup(os.LookupEnv, vary.PrefixedLookup("MYAPP_", os.LookupEnv))))
    // OLD
    vary.New(vary.WithPrefix("MYAPP"), vary.WithPrefixHandling(vary.PrefixHandlingAlways))
    
    // NEW
    vary.New(vary.WithLookup(vary.PrefixedLookup("MYAPP_", os.LookupEnv)))
    • Notice the explicit inclusion of the trailing underscore (_) in the new code, as the underscore is no longer automatically inserted when using PrefixedLookup in order to provide more flexibility.

What's Changed

  • Eliminate some code redundancies by @chadweimer in #10
  • Added CompositeLookupEnv to allow adding multiple lookups by @chadweimer in #11
  • BREAKING: Changed prefix support to leverage LookupEnvFunc by @chadweimer in #12

Full Changelog: v1.3.1...v2.0.0