cfg
The cfg package is used to enable the options pattern in Connector.DefineConfig. This pattern is used in Go for expressing optional arguments. This package defines the various Options as well as their collector Config which is not used directly but rather applies and collects the list of Options behind the scenes.
For example:
con.DefineConfig("Database", cfg.Validation("url"), cfg.Secret())The following options are supported:
cfg.DefaultValuespecifies a default value for the property when one is not provided by the configuratorcfg.Validationuses a pattern to validate values before they are setstr- Plain text, no validationstr ^[a-zA-Z0-9]+$- Text with regexp validationbool- Must betrueorfalseint- An integer, no validationint [0,60]- An integer in rangefloat- A decimal number, no validationfloat [0.0,1.0)- A decimal number in rangedur- A duration such as7h3m45s500ms300us100nsdur (0s,24h]- A duration in rangeset Red|Green|Blue- A set of explicit options separated by|url- A URLemail- An email address, eitherJoe <joe@example.com>or justjoe@example.comjson- A valid JSON string
cfg.Secretindicates that the value of this property is a secret and should not be loggedcfg.Descriptionis intended to explain the purpose of the config property and how it will impact the microservice