Skip to content

Commit

Permalink
feat: use env parse
Browse files Browse the repository at this point in the history
  • Loading branch information
davidebianchi committed Mar 12, 2024
1 parent 76e4eb6 commit 8c288db
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 666 deletions.
42 changes: 6 additions & 36 deletions env.go → config/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,44 +14,14 @@
* limitations under the License.
*/

package main

import (
"github.com/mia-platform/configlib"
)
package config

// EnvironmentVariables struct with the mapping of desired
// environment variables.
type EnvironmentVariables struct {
LogLevel string
HTTPPort string
ServicePrefix string
ServiceVersion string
DelayShutdownSeconds int
}

var envVariablesConfig = []configlib.EnvConfig{
{
Key: "LOG_LEVEL",
Variable: "LogLevel",
DefaultValue: "info",
},
{
Key: "HTTP_PORT",
Variable: "HTTPPort",
DefaultValue: "8080",
},
{
Key: "SERVICE_PREFIX",
Variable: "ServicePrefix",
},
{
Key: "SERVICE_VERSION",
Variable: "ServiceVersion",
},
{
Key: "DELAY_SHUTDOWN_SECONDS",
Variable: "DelayShutdownSeconds",
DefaultValue: "10",
},
LogLevel string `env:"LOG_LEVEL" envDefault:"info"`
HTTPPort string `env:"HTTP_PORT" envDefault:"8080"`
ServicePrefix string `env:"SERVICE_PREFIX"`
ServiceVersion string `env:"SERVICE_VERSION"`
DelayShutdownSeconds int `env:"DELAY_SHUTDOWN_SECONDS" envDefault:"10"`
}
24 changes: 3 additions & 21 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ module mia_template_service_name_placeholder
go 1.20

require (
github.com/caarlos0/env/v10 v10.0.0
github.com/davidebianchi/gswagger v0.8.0
github.com/getkin/kin-openapi v0.112.0
github.com/gofiber/fiber/v2 v2.42.0
github.com/mia-platform/configlib v1.0.0
github.com/mia-platform/glogger/v3 v3.0.0
github.com/sirupsen/logrus v1.9.0
github.com/stretchr/testify v1.8.1
Expand All @@ -15,51 +15,33 @@ require (
require (
github.com/andybalholm/brotli v1.0.4 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/swag v0.21.1 // indirect
github.com/google/go-cmp v0.5.8 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/iancoleman/orderedmap v0.2.0 // indirect
github.com/invopop/yaml v0.2.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/klauspost/compress v1.15.9 // indirect
github.com/knadh/koanf v1.4.1 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/mia-platform/jsonschema v0.1.0 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.1 // indirect
github.com/philhofer/fwd v1.1.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/savsgio/dictpool v0.0.0-20221023140959-7bf2e61cea94 // indirect
github.com/savsgio/gotils v0.0.0-20220530130905-52f3993e8d6d // indirect
github.com/spf13/afero v1.8.2 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.12.0 // indirect
github.com/subosito/gotenv v1.4.0 // indirect
github.com/tinylib/msgp v1.1.6 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.44.0 // indirect
github.com/valyala/tcplisten v1.0.0 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab // indirect
golang.org/x/text v0.3.7 // indirect
gopkg.in/ini.v1 v1.66.4 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 8c288db

Please sign in to comment.