Skip to content

Commit 5cf791d

Browse files
committed
add mapstructure to environment variables
1 parent 07a388c commit 5cf791d

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

utils/environment.go

+16-16
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ var (
1616

1717
// EnvString represents either a literal string or an environment reference
1818
type EnvString struct {
19-
Value *string `json:"value,omitempty" yaml:"value,omitempty" jsonschema:"anyof_required=value"`
20-
Variable *string `json:"env,omitempty" yaml:"env,omitempty" jsonschema:"anyof_required=env"`
19+
Value *string `json:"value,omitempty" yaml:"value,omitempty" mapstructure:"value" jsonschema:"anyof_required=value"`
20+
Variable *string `json:"env,omitempty" yaml:"env,omitempty" mapstructure:"env" jsonschema:"anyof_required=env"`
2121
}
2222

2323
// NewEnvString creates an EnvString instance
@@ -101,8 +101,8 @@ func (ev EnvString) GetOrDefault(defaultValue string) (string, error) {
101101

102102
// EnvInt represents either a literal integer or an environment reference
103103
type EnvInt struct {
104-
Value *int64 `json:"value,omitempty" yaml:"value,omitempty" jsonschema:"anyof_required=value"`
105-
Variable *string `json:"env,omitempty" yaml:"env,omitempty" jsonschema:"anyof_required=env"`
104+
Value *int64 `json:"value,omitempty" yaml:"value,omitempty" mapstructure:"value" jsonschema:"anyof_required=value"`
105+
Variable *string `json:"env,omitempty" yaml:"env,omitempty" mapstructure:"env" jsonschema:"anyof_required=env"`
106106
}
107107

108108
// NewEnvInt creates an EnvInt instance.
@@ -175,8 +175,8 @@ func (ev EnvInt) GetOrDefault(defaultValue int64) (int64, error) {
175175

176176
// EnvBool represents either a literal boolean or an environment reference
177177
type EnvBool struct {
178-
Value *bool `json:"value,omitempty" yaml:"value,omitempty" jsonschema:"anyof_required=value"`
179-
Variable *string `json:"env,omitempty" yaml:"env,omitempty" jsonschema:"anyof_required=env"`
178+
Value *bool `json:"value,omitempty" yaml:"value,omitempty" mapstructure:"value" jsonschema:"anyof_required=value"`
179+
Variable *string `json:"env,omitempty" yaml:"env,omitempty" mapstructure:"env" jsonschema:"anyof_required=env"`
180180
}
181181

182182
// NewEnvBool creates an EnvBool instance.
@@ -249,8 +249,8 @@ func (ev EnvBool) GetOrDefault(defaultValue bool) (bool, error) {
249249

250250
// EnvFloat represents either a literal floating point number or an environment reference
251251
type EnvFloat struct {
252-
Value *float64 `json:"value,omitempty" yaml:"value,omitempty" jsonschema:"anyof_required=value"`
253-
Variable *string `json:"env,omitempty" yaml:"env,omitempty" jsonschema:"anyof_required=env"`
252+
Value *float64 `json:"value,omitempty" yaml:"value,omitempty" mapstructure:"value" jsonschema:"anyof_required=value"`
253+
Variable *string `json:"env,omitempty" yaml:"env,omitempty" mapstructure:"env" jsonschema:"anyof_required=env"`
254254
}
255255

256256
// NewEnvFloat creates an EnvFloat instance.
@@ -342,8 +342,8 @@ func validateEnvironmentMapValue(variable *string) error {
342342

343343
// EnvMapString represents either a literal string map or an environment reference
344344
type EnvMapString struct {
345-
Value map[string]string `json:"value,omitempty" yaml:"value,omitempty" jsonschema:"anyof_required=value"`
346-
Variable *string `json:"env,omitempty" yaml:"env,omitempty" jsonschema:"anyof_required=env"`
345+
Value map[string]string `json:"value,omitempty" yaml:"value,omitempty" mapstructure:"value" jsonschema:"anyof_required=value"`
346+
Variable *string `json:"env,omitempty" yaml:"env,omitempty" mapstructure:"env" jsonschema:"anyof_required=env"`
347347
}
348348

349349
// NewEnvMapString creates an EnvMapString instance.
@@ -399,8 +399,8 @@ func (ev EnvMapString) Get() (map[string]string, error) {
399399

400400
// EnvMapInt represents either a literal int map or an environment reference
401401
type EnvMapInt struct {
402-
Value map[string]int64 `json:"value,omitempty" yaml:"value,omitempty" jsonschema:"anyof_required=value"`
403-
Variable *string `json:"env,omitempty" yaml:"env,omitempty" jsonschema:"anyof_required=env"`
402+
Value map[string]int64 `json:"value,omitempty" yaml:"value,omitempty" mapstructure:"value" jsonschema:"anyof_required=value"`
403+
Variable *string `json:"env,omitempty" yaml:"env,omitempty" mapstructure:"env" jsonschema:"anyof_required=env"`
404404
}
405405

406406
// NewEnvMapInt creates an EnvMapInt instance.
@@ -456,8 +456,8 @@ func (ev EnvMapInt) Get() (map[string]int64, error) {
456456

457457
// EnvMapFloat represents either a literal float map or an environment reference
458458
type EnvMapFloat struct {
459-
Value map[string]float64 `json:"value,omitempty" yaml:"value,omitempty" jsonschema:"anyof_required=value"`
460-
Variable *string `json:"env,omitempty" yaml:"env,omitempty" jsonschema:"anyof_required=env"`
459+
Value map[string]float64 `json:"value,omitempty" yaml:"value,omitempty" mapstructure:"value" jsonschema:"anyof_required=value"`
460+
Variable *string `json:"env,omitempty" yaml:"env,omitempty" mapstructure:"env" jsonschema:"anyof_required=env"`
461461
}
462462

463463
// NewEnvMapFloat creates an EnvMapFloat instance.
@@ -513,8 +513,8 @@ func (ev EnvMapFloat) Get() (map[string]float64, error) {
513513

514514
// EnvMapBool represents either a literal bool map or an environment reference
515515
type EnvMapBool struct {
516-
Value map[string]bool `json:"value,omitempty" yaml:"value,omitempty" jsonschema:"anyof_required=value"`
517-
Variable *string `json:"env,omitempty" yaml:"env,omitempty" jsonschema:"anyof_required=env"`
516+
Value map[string]bool `json:"value,omitempty" yaml:"value,omitempty" mapstructure:"value" jsonschema:"anyof_required=value"`
517+
Variable *string `json:"env,omitempty" yaml:"env,omitempty" mapstructure:"env" jsonschema:"anyof_required=env"`
518518
}
519519

520520
// NewEnvMapBool creates an EnvMapBool instance.

0 commit comments

Comments
 (0)