gosettings

Go package providing helper functions for working with settings

MIT License

Stars
1
gosettings - v0.4.4-rc1 Latest Release

Published by qdm12 2 months ago

Fixes

  • validate: linux only: handle permission denied on ip_unprivileged_port_start and return start port 1024 in that case
gosettings - v0.4.3

Published by qdm12 2 months ago

Fixes

  • reader: default force lowercase option to true to match documentation
gosettings - v0.4.2

Published by qdm12 4 months ago

Fixes

  • internal/parse: ignore empty set values if accept empty setting is false - this caused an issue such as this one

Maintenance

  • internal/parse: add get unit tests with mock of Source
gosettings - v0.4.1

Published by qdm12 7 months ago

Fixes

  • do not reuse key to try transformed for previous source
gosettings - v0.4.0

Published by qdm12 7 months ago

Breaking changes

  • reader and internal/parse packages which replace previous sources/env and sources/merge packages
    • Reader reads from multiple sources in order for each call
    • By default, the reader uses the flags source then the environment variable source
    • internal/parse contains only pure functions to make full use of Go 1.18+ generics
    • Update all code comments, merge example and readme document
  • Merge functions in merge.go removed (now unneeded due to reader package handling the merging)
  • Override: OverrideWithComparable function, replacing OverrideWithNumber, OverrideWithString, OverrideWithPointerRaw, OverrideWithInterface and OverrideWithSliceRaw
  • Defaults: DefaultComparable function, replacing DefaultNumber, DefaultString, DefaultPointerRaw, DefaultInterface and DefaultSliceRaw
  • Number constraint and constraints.go file removed (no longer needed)

Features

  • reader/sources/env environment variable reader-compatible source
  • reader/sources/flags CLI flags reader-compatible source
  • reader package (previously sources/env):
    • add DefaultOptions setting to apply to each read
    • add FirstKeySet method
    • add CSVNetipAddresses method
    • add NetipPrefix method
    • add NetipAddrPort method
    • add CSVNetipAddrPorts method
    • add builtin types methods: Int8, Int16, Int32, Int64, Int8Ptr, Int16Ptr, Int32Ptr, Int64Ptr, Float32, Float32Ptr and Float64Ptr

Fixes

  • validate: allow empty listening addresses
  • validate: listening port validation
    • Check non root users against unprivileged start port found from Kernel file on Linux
    • Check if the running program has the net_bind_service capability if trying to listen on a privileged port without root or windows
  • internal/parse (previously within sources/env/parse.go):
    • try parsing the empty string if AllowEmpty(true) option is specified
  • reader and internal/parse (previously sources/env):
    • BoolPtr returns nil when the empty string is found

Documentation

  • Update readme and examples with the new usage to merge settings from different sources
  • Review code comments
    • fix godoc comments bullet list formatting
    • fix godoc comments new lines formatting
    • mention default settings for CSV methods
    • mention nil slices conditions for CSV methods
    • change function comment the error context to its message
    • fix CSVNetipPrefixes method comment
    • review AcceptEmpty option comment

Maintenance

  • Upgrade Go from 1.20 to 1.21
  • Upgrade dependency golang.org/x/exp
  • Upgrade CI Docker image Alpine from 3.16 to 3.18
  • Upgrade actions/checkout from 3 to 4 (#12)
  • Bump github/codeql-action from 2 to 3 by @dependabot in https://github.com/qdm12/gosettings/pull/16
gosettings - v0.4.0-rc9

Published by qdm12 9 months ago

Hotfixes

gosettings - v0.4.0-rc7

Published by qdm12 9 months ago

Fixes

  • validate: listening port validation
    • Check non root users against unprivileged start port found from Kernel file on Linux
    • Check if the running program has the net_bind_service capability if trying to listen on a privileged port without root or windows

Maintenance

gosettings - v0.4.0-rc6

Published by qdm12 10 months ago

Features

  • reader/sources/env: key prefix option, use settings struct to create source

Maintenance

  • Tidy Go modules dependencies
gosettings - v0.4.0-rc5

Published by qdm12 11 months ago

Hotfixes

  • reader: Uint returns a uint not an int

Features

  • reader: add NetipPrefix, NetipAddrPort and CSVNetipAddrPorts methods
gosettings - v0.4.0-rc4

Published by qdm12 11 months ago

Breaking changes

  • Move reader/parse to internal/parse

Maintenance

  • Upgrade dependency golang.org/x/exp
  • Upgrade CI Docker image Alpine from 3.16 to 3.18
  • Upgrade Go from 1.20 to 1.21
  • Upgrade actions/checkout from 3 to 4 (#12)

Features

  • reader:
    • add builtin methods: Int8, Int16, Int32, Int64, Int8Ptr, Int16Ptr, Int32Ptr, Int64Ptr, Float32, Float32Ptr and Float64Ptr
    • default reader sources are flags then env isntead of only env

Documentation

  • Simplify README.md reader Go code example
  • Update reader example code to use flag and env instead of both sources as env
gosettings - v0.4.0-rc3

Published by qdm12 11 months ago

Breaking changes

  • Move environment variables source env.go to its own reader/sources/env package

Features

  • Add flags source package reader/sources/flag
gosettings - v0.4.0-rc2

Published by qdm12 11 months ago

Breaking changes

  • reader package which replaces all sources packages
    • Merge functions in merge.go removed (now unneeded)
    • Settings reader now reads from multiple sources in order
    • sources/merger removed
    • sources/env removed (replaced by reader package)
    • Define Env reader-compatible Source
    • parse package generic functions accept source interfaces instead of keyValues map
    • Update all code comments, example and readme
  • reader package: New takes a Settings struct as its unique argument
  • Number constraint and constraints.go file removed
  • Override: OverrideWithComparable function, replacing OverrideWithNumber, OverrideWithString, OverrideWithPointerRaw, OverrideWithInterface and OverrideWithSliceRaw
  • Defaults: DefaultComparable function, replacing DefaultNumber, DefaultString, DefaultPointerRaw, DefaultInterface and DefaultSliceRaw
  • parse package: try parsing the empty string if AllowEmpty(true) option is used

Features

  • reader package: add DefaultOptions field to the Settings struct
  • reader package: add FirstKeySet function

Fixes

  • reader/parse package:
    • settings default properly set handleDeprecatedKey function
    • parseBool returns a bool pointer

Documentation

  • Review code comments
    • fix godoc comments bullet list formatting
    • fix godoc comments new lines formatting
    • mention default settings for CSV methods
    • change the error context to its message
    • mention nil slices conditions for CSV methods
    • review AcceptEmpty option comment
gosettings - v0.4.0-rc1

Published by qdm12 over 1 year ago

Features

  • sources/env: add CSVNetipAddresses method

Fixes

  • validate: ListeningAddress accepts empty listening addresses

Documentation

  • sources/env: fix CSVNetipPrefixes method comment
gosettings - v0.3.0

Published by qdm12 over 1 year ago

Features

  • Add ObfuscateKey function
  • Add BoolToYesNo function
  • Add DefaultPointerRaw function
  • sources/env:
    • add ForceLowercase option
    • add AcceptEmpty option
    • add String function as a shorthand to return the empty string if the environment variable is not set or is the empty string.
    • add Uint32Ptr method
    • add Duration method
    • BoolPtr accepts true and false as string values
    • add CSV functions for signed, unsigned and netip prefixes
    • add RetroKeys option
      • Breaking change: New takes handleDeprecatedKey functional argument, which can be left to nil
  • sources/merger package with sources merger generic code
  • validate:
    • add AreAllOneOfCaseInsensitive function
    • add FileExists function
    • add DirectoryExists function
    • add ListeningAddress function
  • Breaking changes:
    • Change MergeWith to be a value receiver and return a merged result
    • sources/env:
      • all functions changed to methods on Env which is created with env.New(os.Environ())
      • Get trims quotes by default
      • add environment variable key in the error context
      • Get returns a string pointer, which is always nil if the variable is not set, and can be nil if empty values are not accepted (default). Most functions still return nil if they get an empty string (i.e. Uint8Ptr)

Fixes

  • sources/env: trim both spaces and new lines if both are specified
  • validate: fix orStrings function
  • MergeWithSlice with nil arguments

Documentation

  • Readme: update features section
  • Readme: fully revised
  • Readme: add gluetun, dns and tinier as concrete examples
  • Add comments to all exported members
  • Add examples/merger/main.go
  • Add Names string slice field to example settings in example/settings/settings.go
  • sources/env:
    • document Get default behavior
    • add Test_New test

Maintenance

  • Drop dependency on github.com/qdm12/govalid:
    • sources/env: add unsigned and signed local parse functions
    • sources/env: package local parseBool
  • sources/env:
    • split Get body into postProcessValue function
    • Get has a more flexible value trimming logic
  • Enforce exported comments with linter, except for sentinel errors
gosettings - v0.3.0-rc14

Published by qdm12 over 1 year ago

Documentation

  • sources/env: comment on order of retro keys

Features

  • sources/env: add Duration method
gosettings - v0.3.0-rc13

Published by qdm12 over 1 year ago

Features

  • sources/env: add Uint32Ptr
  • sources/env: BoolPtr accepts true and false as string values
  • sources/env: add CSV functions for signed, unsigned and netip prefixes
  • sources/env: add RetroKeys option
    • Breaking change: New takes handleDeprecatedKey functional argument, which can be left to nil

Maintenance

  • Drop dependency on qdm12/govalid:
    • sources/env: add unsigned and signed local parse functions
    • sources/env: package local parseBool
gosettings - v0.3.0-rc12

Published by qdm12 over 1 year ago

  • Fix: MergeWithSlice with nil arguments
  • Maintenance: sources/env: add Test_New test
gosettings - v0.3.0-rc11

Published by qdm12 over 1 year ago

gosettings - v0.3.0-rc10

Published by qdm12 over 1 year ago

gosettings - v0.3.0-rc9

Published by qdm12 over 1 year ago