Skip to content

Commit d6d00a1

Browse files
authored
chore: deprecate environment modules, move to github.com/hasura/goenvconf (#208)
1 parent 12bb41e commit d6d00a1

2 files changed

Lines changed: 92 additions & 0 deletions

File tree

utils/environment.go

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@ var (
1515
)
1616

1717
// EnvString represents either a literal string or an environment reference.
18+
//
19+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
1820
type EnvString struct {
1921
Value *string `json:"value,omitempty" jsonschema:"anyof_required=value" mapstructure:"value" yaml:"value,omitempty"`
2022
Variable *string `json:"env,omitempty" jsonschema:"anyof_required=env" mapstructure:"env" yaml:"env,omitempty"`
2123
}
2224

2325
// NewEnvString creates an EnvString instance.
26+
//
27+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
2428
func NewEnvString(env string, value string) EnvString {
2529
return EnvString{
2630
Variable: &env,
@@ -29,13 +33,17 @@ func NewEnvString(env string, value string) EnvString {
2933
}
3034

3135
// NewEnvStringValue creates an EnvString with a literal value.
36+
//
37+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
3238
func NewEnvStringValue(value string) EnvString {
3339
return EnvString{
3440
Value: &value,
3541
}
3642
}
3743

3844
// NewEnvStringVariable creates an EnvString with a variable name.
45+
//
46+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
3947
func NewEnvStringVariable(name string) EnvString {
4048
return EnvString{
4149
Variable: &name,
@@ -61,6 +69,8 @@ func (ev *EnvString) UnmarshalJSON(b []byte) error {
6169
}
6270

6371
// Get gets literal value or from system environment.
72+
//
73+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
6474
func (ev EnvString) Get() (string, error) {
6575
if err := validateEnvironmentValue(ev.Value, ev.Variable); err != nil {
6676
return "", err
@@ -88,6 +98,8 @@ func (ev EnvString) Get() (string, error) {
8898
}
8999

90100
// GetOrDefault returns the default value if the environment value is empty.
101+
//
102+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
91103
func (ev EnvString) GetOrDefault(defaultValue string) (string, error) {
92104
result, err := ev.Get()
93105
if err != nil {
@@ -104,12 +116,16 @@ func (ev EnvString) GetOrDefault(defaultValue string) (string, error) {
104116
}
105117

106118
// EnvInt represents either a literal integer or an environment reference.
119+
//
120+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
107121
type EnvInt struct {
108122
Value *int64 `json:"value,omitempty" jsonschema:"anyof_required=value" mapstructure:"value" yaml:"value,omitempty"`
109123
Variable *string `json:"env,omitempty" jsonschema:"anyof_required=env" mapstructure:"env" yaml:"env,omitempty"`
110124
}
111125

112126
// NewEnvInt creates an EnvInt instance.
127+
//
128+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
113129
func NewEnvInt(env string, value int64) EnvInt {
114130
return EnvInt{
115131
Variable: &env,
@@ -118,13 +134,17 @@ func NewEnvInt(env string, value int64) EnvInt {
118134
}
119135

120136
// NewEnvIntValue creates an EnvInt with a literal value.
137+
//
138+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
121139
func NewEnvIntValue(value int64) EnvInt {
122140
return EnvInt{
123141
Value: &value,
124142
}
125143
}
126144

127145
// NewEnvIntVariable creates an EnvInt with a variable name.
146+
//
147+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
128148
func NewEnvIntVariable(name string) EnvInt {
129149
return EnvInt{
130150
Variable: &name,
@@ -150,6 +170,8 @@ func (ev *EnvInt) UnmarshalJSON(b []byte) error {
150170
}
151171

152172
// Get gets literal value or from system environment.
173+
//
174+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
153175
func (ev EnvInt) Get() (int64, error) {
154176
if err := validateEnvironmentValue(ev.Value, ev.Variable); err != nil {
155177
return 0, err
@@ -170,6 +192,8 @@ func (ev EnvInt) Get() (int64, error) {
170192
}
171193

172194
// GetOrDefault returns the default value if the environment value is empty.
195+
//
196+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
173197
func (ev EnvInt) GetOrDefault(defaultValue int64) (int64, error) {
174198
result, err := ev.Get()
175199
if err != nil {
@@ -184,12 +208,16 @@ func (ev EnvInt) GetOrDefault(defaultValue int64) (int64, error) {
184208
}
185209

186210
// EnvBool represents either a literal boolean or an environment reference.
211+
//
212+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
187213
type EnvBool struct {
188214
Value *bool `json:"value,omitempty" jsonschema:"anyof_required=value" mapstructure:"value" yaml:"value,omitempty"`
189215
Variable *string `json:"env,omitempty" jsonschema:"anyof_required=env" mapstructure:"env" yaml:"env,omitempty"`
190216
}
191217

192218
// NewEnvBool creates an EnvBool instance.
219+
//
220+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
193221
func NewEnvBool(env string, value bool) EnvBool {
194222
return EnvBool{
195223
Variable: &env,
@@ -198,13 +226,17 @@ func NewEnvBool(env string, value bool) EnvBool {
198226
}
199227

200228
// NewEnvBoolValue creates an EnvBool with a literal value.
229+
//
230+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
201231
func NewEnvBoolValue(value bool) EnvBool {
202232
return EnvBool{
203233
Value: &value,
204234
}
205235
}
206236

207237
// NewEnvBoolVariable creates an EnvBool with a variable name.
238+
//
239+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
208240
func NewEnvBoolVariable(name string) EnvBool {
209241
return EnvBool{
210242
Variable: &name,
@@ -230,6 +262,8 @@ func (ev *EnvBool) UnmarshalJSON(b []byte) error {
230262
}
231263

232264
// Get gets literal value or from system environment.
265+
//
266+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
233267
func (ev EnvBool) Get() (bool, error) {
234268
if err := validateEnvironmentValue(ev.Value, ev.Variable); err != nil {
235269
return false, err
@@ -250,6 +284,8 @@ func (ev EnvBool) Get() (bool, error) {
250284
}
251285

252286
// GetOrDefault returns the default value if the environment value is empty.
287+
//
288+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
253289
func (ev EnvBool) GetOrDefault(defaultValue bool) (bool, error) {
254290
result, err := ev.Get()
255291
if err != nil {
@@ -264,12 +300,16 @@ func (ev EnvBool) GetOrDefault(defaultValue bool) (bool, error) {
264300
}
265301

266302
// EnvFloat represents either a literal floating point number or an environment reference.
303+
//
304+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
267305
type EnvFloat struct {
268306
Value *float64 `json:"value,omitempty" jsonschema:"anyof_required=value" mapstructure:"value" yaml:"value,omitempty"`
269307
Variable *string `json:"env,omitempty" jsonschema:"anyof_required=env" mapstructure:"env" yaml:"env,omitempty"`
270308
}
271309

272310
// NewEnvFloat creates an EnvFloat instance.
311+
//
312+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
273313
func NewEnvFloat(env string, value float64) EnvFloat {
274314
return EnvFloat{
275315
Variable: &env,
@@ -278,13 +318,17 @@ func NewEnvFloat(env string, value float64) EnvFloat {
278318
}
279319

280320
// NewEnvFloatValue creates an EnvFloat with a literal value.
321+
//
322+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
281323
func NewEnvFloatValue(value float64) EnvFloat {
282324
return EnvFloat{
283325
Value: &value,
284326
}
285327
}
286328

287329
// NewEnvFloatVariable creates an EnvFloat with a variable name.
330+
//
331+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
288332
func NewEnvFloatVariable(name string) EnvFloat {
289333
return EnvFloat{
290334
Variable: &name,
@@ -310,6 +354,8 @@ func (ev *EnvFloat) UnmarshalJSON(b []byte) error {
310354
}
311355

312356
// Get gets literal value or from system environment.
357+
//
358+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
313359
func (ev EnvFloat) Get() (float64, error) {
314360
if err := validateEnvironmentValue(ev.Value, ev.Variable); err != nil {
315361
return 0, err
@@ -330,6 +376,8 @@ func (ev EnvFloat) Get() (float64, error) {
330376
}
331377

332378
// GetOrDefault returns the default value if the environment value is empty.
379+
//
380+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
333381
func (ev EnvFloat) GetOrDefault(defaultValue float64) (float64, error) {
334382
result, err := ev.Get()
335383
if err != nil {
@@ -364,12 +412,16 @@ func validateEnvironmentMapValue(variable *string) error {
364412
}
365413

366414
// EnvMapString represents either a literal string map or an environment reference.
415+
//
416+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
367417
type EnvMapString struct {
368418
Value map[string]string `json:"value,omitempty" jsonschema:"anyof_required=value" mapstructure:"value" yaml:"value,omitempty"`
369419
Variable *string `json:"env,omitempty" jsonschema:"anyof_required=env" mapstructure:"env" yaml:"env,omitempty"`
370420
}
371421

372422
// NewEnvMapString creates an EnvMapString instance.
423+
//
424+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
373425
func NewEnvMapString(env string, value map[string]string) EnvMapString {
374426
return EnvMapString{
375427
Variable: &env,
@@ -378,13 +430,17 @@ func NewEnvMapString(env string, value map[string]string) EnvMapString {
378430
}
379431

380432
// NewEnvMapStringValue creates an EnvMapString with a literal value.
433+
//
434+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
381435
func NewEnvMapStringValue(value map[string]string) EnvMapString {
382436
return EnvMapString{
383437
Value: value,
384438
}
385439
}
386440

387441
// NewEnvMapStringVariable creates an EnvMapString with a variable name.
442+
//
443+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
388444
func NewEnvMapStringVariable(name string) EnvMapString {
389445
return EnvMapString{
390446
Variable: &name,
@@ -410,6 +466,8 @@ func (ev *EnvMapString) UnmarshalJSON(b []byte) error {
410466
}
411467

412468
// Get gets literal value or from system environment.
469+
//
470+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
413471
func (ev EnvMapString) Get() (map[string]string, error) {
414472
if err := validateEnvironmentMapValue(ev.Variable); err != nil {
415473
return nil, err
@@ -426,12 +484,16 @@ func (ev EnvMapString) Get() (map[string]string, error) {
426484
}
427485

428486
// EnvMapInt represents either a literal int map or an environment reference.
487+
//
488+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
429489
type EnvMapInt struct {
430490
Value map[string]int64 `json:"value,omitempty" jsonschema:"anyof_required=value" mapstructure:"value" yaml:"value,omitempty"`
431491
Variable *string `json:"env,omitempty" jsonschema:"anyof_required=env" mapstructure:"env" yaml:"env,omitempty"`
432492
}
433493

434494
// NewEnvMapInt creates an EnvMapInt instance.
495+
//
496+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
435497
func NewEnvMapInt(env string, value map[string]int64) EnvMapInt {
436498
return EnvMapInt{
437499
Variable: &env,
@@ -440,13 +502,17 @@ func NewEnvMapInt(env string, value map[string]int64) EnvMapInt {
440502
}
441503

442504
// NewEnvMapIntValue creates an EnvMapInt with a literal value.
505+
//
506+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
443507
func NewEnvMapIntValue(value map[string]int64) EnvMapInt {
444508
return EnvMapInt{
445509
Value: value,
446510
}
447511
}
448512

449513
// NewEnvMapIntVariable creates an EnvMapInt with a variable name.
514+
//
515+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
450516
func NewEnvMapIntVariable(name string) EnvMapInt {
451517
return EnvMapInt{
452518
Variable: &name,
@@ -472,6 +538,8 @@ func (ev *EnvMapInt) UnmarshalJSON(b []byte) error {
472538
}
473539

474540
// Get gets literal value or from system environment.
541+
//
542+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
475543
func (ev EnvMapInt) Get() (map[string]int64, error) {
476544
if err := validateEnvironmentMapValue(ev.Variable); err != nil {
477545
return nil, err
@@ -488,12 +556,16 @@ func (ev EnvMapInt) Get() (map[string]int64, error) {
488556
}
489557

490558
// EnvMapFloat represents either a literal float map or an environment reference.
559+
//
560+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
491561
type EnvMapFloat struct {
492562
Value map[string]float64 `json:"value,omitempty" jsonschema:"anyof_required=value" mapstructure:"value" yaml:"value,omitempty"`
493563
Variable *string `json:"env,omitempty" jsonschema:"anyof_required=env" mapstructure:"env" yaml:"env,omitempty"`
494564
}
495565

496566
// NewEnvMapFloat creates an EnvMapFloat instance.
567+
//
568+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
497569
func NewEnvMapFloat(env string, value map[string]float64) EnvMapFloat {
498570
return EnvMapFloat{
499571
Variable: &env,
@@ -502,13 +574,17 @@ func NewEnvMapFloat(env string, value map[string]float64) EnvMapFloat {
502574
}
503575

504576
// NewEnvMapFloatValue creates an EnvMapFloat with a literal value.
577+
//
578+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
505579
func NewEnvMapFloatValue(value map[string]float64) EnvMapFloat {
506580
return EnvMapFloat{
507581
Value: value,
508582
}
509583
}
510584

511585
// NewEnvMapFloatVariable creates an EnvMapFloat with a variable name.
586+
//
587+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
512588
func NewEnvMapFloatVariable(name string) EnvMapFloat {
513589
return EnvMapFloat{
514590
Variable: &name,
@@ -534,6 +610,8 @@ func (ev *EnvMapFloat) UnmarshalJSON(b []byte) error {
534610
}
535611

536612
// Get gets literal value or from system environment.
613+
//
614+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
537615
func (ev EnvMapFloat) Get() (map[string]float64, error) {
538616
if err := validateEnvironmentMapValue(ev.Variable); err != nil {
539617
return nil, err
@@ -550,12 +628,16 @@ func (ev EnvMapFloat) Get() (map[string]float64, error) {
550628
}
551629

552630
// EnvMapBool represents either a literal bool map or an environment reference.
631+
//
632+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
553633
type EnvMapBool struct {
554634
Value map[string]bool `json:"value,omitempty" jsonschema:"anyof_required=value" mapstructure:"value" yaml:"value,omitempty"`
555635
Variable *string `json:"env,omitempty" jsonschema:"anyof_required=env" mapstructure:"env" yaml:"env,omitempty"`
556636
}
557637

558638
// NewEnvMapBool creates an EnvMapBool instance.
639+
//
640+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
559641
func NewEnvMapBool(env string, value map[string]bool) EnvMapBool {
560642
return EnvMapBool{
561643
Variable: &env,
@@ -564,13 +646,17 @@ func NewEnvMapBool(env string, value map[string]bool) EnvMapBool {
564646
}
565647

566648
// NewEnvMapBoolValue creates an EnvMapBool with a literal value.
649+
//
650+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
567651
func NewEnvMapBoolValue(value map[string]bool) EnvMapBool {
568652
return EnvMapBool{
569653
Value: value,
570654
}
571655
}
572656

573657
// NewEnvMapBoolVariable creates an EnvMapBool with a variable name.
658+
//
659+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
574660
func NewEnvMapBoolVariable(name string) EnvMapBool {
575661
return EnvMapBool{
576662
Variable: &name,
@@ -596,6 +682,8 @@ func (ev *EnvMapBool) UnmarshalJSON(b []byte) error {
596682
}
597683

598684
// Get gets literal value or from system environment.
685+
//
686+
// Deprecated: this module was moved to github.com/hasura/goenvconf.
599687
func (ev EnvMapBool) Get() (map[string]bool, error) {
600688
if err := validateEnvironmentMapValue(ev.Variable); err != nil {
601689
return nil, err

0 commit comments

Comments
 (0)