From 2f106889868d00f09fb243eff97cabadc1ebb199 Mon Sep 17 00:00:00 2001 From: Vincent Boutour Date: Sat, 20 Feb 2021 17:43:11 +0100 Subject: [PATCH] chore(deps): Bumping httputils to v4 Signed-off-by: Vincent Boutour --- README.md | 44 ++++++++++++++++++++++++------------ cmd/deploy/deploy.go | 33 +++++++++++++++++++-------- go.mod | 2 +- go.sum | 12 ++++------ pkg/annotation/annotation.go | 4 ++-- pkg/api/api.go | 8 +++---- 6 files changed, 63 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index b1a6198..d306628 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ If something goes wrong during the deploy process, the uploaded `docker-compose. ```bash Usage of deploy: -address string - [http] Listen address {DEPLOY_ADDRESS} + [server] Listen address {DEPLOY_ADDRESS} -annotationPass string [annotation] Pass {DEPLOY_ANNOTATION_PASS} -annotationURL string @@ -53,7 +53,7 @@ Usage of deploy: -apiTempFolder string [api] Temp folder for uploading files {DEPLOY_API_TEMP_FOLDER} (default "/tmp") -cert string - [http] Certificate file {DEPLOY_CERT} + [server] Certificate file {DEPLOY_CERT} -csp string [owasp] Content-Security-Policy {DEPLOY_CSP} (default "default-src 'self'; base-uri 'self'") -frameOptions string @@ -63,9 +63,9 @@ Usage of deploy: -hsts [owasp] Indicate Strict Transport Security {DEPLOY_HSTS} (default true) -idleTimeout string - [http] Idle Timeout {DEPLOY_IDLE_TIMEOUT} (default "2m") + [server] Idle Timeout {DEPLOY_IDLE_TIMEOUT} (default "2m") -key string - [http] Key file {DEPLOY_KEY} + [server] Key file {DEPLOY_KEY} -loggerJson [logger] Log format as JSON {DEPLOY_LOGGER_JSON} -loggerLevel string @@ -76,30 +76,44 @@ Usage of deploy: [logger] Key for message in JSON {DEPLOY_LOGGER_MESSAGE_KEY} (default "message") -loggerTimeKey string [logger] Key for timestamp in JSON {DEPLOY_LOGGER_TIME_KEY} (default "time") - -mailerPass string - [mailer] Pass {DEPLOY_MAILER_PASS} + -mailerName string + [mailer] HTTP Username or AMQP Exchange name {DEPLOY_MAILER_NAME} (default "mailer") + -mailerPassword string + [mailer] HTTP Pass {DEPLOY_MAILER_PASSWORD} -mailerURL string - [mailer] URL (an instance of github.com/ViBiOh/mailer) {DEPLOY_MAILER_URL} - -mailerUser string - [mailer] User {DEPLOY_MAILER_USER} + [mailer] URL (https?:// or amqps?://) {DEPLOY_MAILER_URL} -okStatus int [http] Healthy HTTP Status code {DEPLOY_OK_STATUS} (default 204) -port uint - [http] Listen port {DEPLOY_PORT} (default 1080) + [server] Listen port {DEPLOY_PORT} (default 1080) + -prometheusAddress string + [prometheus] Listen address {DEPLOY_PROMETHEUS_ADDRESS} + -prometheusCert string + [prometheus] Certificate file {DEPLOY_PROMETHEUS_CERT} + -prometheusIdleTimeout string + [prometheus] Idle Timeout {DEPLOY_PROMETHEUS_IDLE_TIMEOUT} (default "10s") -prometheusIgnore string [prometheus] Ignored path prefixes for metrics, comma separated {DEPLOY_PROMETHEUS_IGNORE} - -prometheusPath string - [prometheus] Path for exposing metrics {DEPLOY_PROMETHEUS_PATH} (default "/metrics") + -prometheusKey string + [prometheus] Key file {DEPLOY_PROMETHEUS_KEY} + -prometheusPort uint + [prometheus] Listen port {DEPLOY_PROMETHEUS_PORT} (default 9090) + -prometheusReadTimeout string + [prometheus] Read Timeout {DEPLOY_PROMETHEUS_READ_TIMEOUT} (default "5s") + -prometheusShutdownTimeout string + [prometheus] Shutdown Timeout {DEPLOY_PROMETHEUS_SHUTDOWN_TIMEOUT} (default "5s") + -prometheusWriteTimeout string + [prometheus] Write Timeout {DEPLOY_PROMETHEUS_WRITE_TIMEOUT} (default "10s") -readTimeout string - [http] Read Timeout {DEPLOY_READ_TIMEOUT} (default "5s") + [server] Read Timeout {DEPLOY_READ_TIMEOUT} (default "5s") -shutdownTimeout string - [http] Shutdown Timeout {DEPLOY_SHUTDOWN_TIMEOUT} (default "10s") + [server] Shutdown Timeout {DEPLOY_SHUTDOWN_TIMEOUT} (default "10s") -url string [alcotest] URL to check {DEPLOY_URL} -userAgent string [alcotest] User-Agent for check {DEPLOY_USER_AGENT} (default "Alcotest") -writeTimeout string - [http] Write Timeout {DEPLOY_WRITE_TIMEOUT} (default "2m") + [server] Write Timeout {DEPLOY_WRITE_TIMEOUT} (default "2m") ``` ## License diff --git a/cmd/deploy/deploy.go b/cmd/deploy/deploy.go index 2a59cc5..e28f882 100644 --- a/cmd/deploy/deploy.go +++ b/cmd/deploy/deploy.go @@ -6,12 +6,14 @@ import ( "github.com/ViBiOh/deploy/pkg/annotation" "github.com/ViBiOh/deploy/pkg/api" - "github.com/ViBiOh/httputils/v3/pkg/alcotest" - "github.com/ViBiOh/httputils/v3/pkg/flags" - "github.com/ViBiOh/httputils/v3/pkg/httputils" - "github.com/ViBiOh/httputils/v3/pkg/logger" - "github.com/ViBiOh/httputils/v3/pkg/owasp" - "github.com/ViBiOh/httputils/v3/pkg/prometheus" + "github.com/ViBiOh/httputils/v4/pkg/alcotest" + "github.com/ViBiOh/httputils/v4/pkg/flags" + "github.com/ViBiOh/httputils/v4/pkg/health" + "github.com/ViBiOh/httputils/v4/pkg/httputils" + "github.com/ViBiOh/httputils/v4/pkg/logger" + "github.com/ViBiOh/httputils/v4/pkg/owasp" + "github.com/ViBiOh/httputils/v4/pkg/prometheus" + "github.com/ViBiOh/httputils/v4/pkg/server" "github.com/ViBiOh/mailer/pkg/client" mailer "github.com/ViBiOh/mailer/pkg/client" ) @@ -19,7 +21,10 @@ import ( func main() { fs := flag.NewFlagSet("deploy", flag.ExitOnError) - serverConfig := httputils.Flags(fs, "", flags.NewOverride("WriteTimeout", "2m")) + appServerConfig := server.Flags(fs, "", flags.NewOverride("WriteTimeout", "2m")) + promServerConfig := server.Flags(fs, "prometheus", flags.NewOverride("Port", 9090), flags.NewOverride("IdleTimeout", "10s"), flags.NewOverride("ShutdownTimeout", "5s")) + healthConfig := health.Flags(fs, "") + alcotestConfig := alcotest.Flags(fs, "") loggerConfig := logger.Flags(fs, "logger") prometheusConfig := prometheus.Flags(fs, "prometheus") @@ -35,6 +40,11 @@ func main() { logger.Global(logger.New(loggerConfig)) defer logger.Close() + appServer := server.New(appServerConfig) + promServer := server.New(promServerConfig) + prometheusApp := prometheus.New(prometheusConfig) + healthApp := health.New(healthConfig) + mailerApp, err := mailer.New(mailerConfig) logger.Fatal(err) defer mailerApp.Close() @@ -42,8 +52,11 @@ func main() { annotationApp := annotation.New(annotationConfig) apiApp := api.New(apiConfig, mailerApp, annotationApp) - server := httputils.New(serverConfig) - go apiApp.Start(server.GetDone()) + go apiApp.Start(healthApp.Done()) + + go promServer.Start("prometheus", healthApp.End(), prometheusApp.Handler()) + go appServer.Start("http", healthApp.End(), httputils.Handler(apiApp.Handler(), healthApp, prometheusApp.Middleware, owasp.New(owaspConfig).Middleware)) - server.ListenAndServe(apiApp.Handler(), nil, prometheus.New(prometheusConfig).Middleware, owasp.New(owaspConfig).Middleware) + healthApp.WaitForTermination(appServer.Done()) + server.GracefulWait(appServer.Done(), promServer.Done()) } diff --git a/go.mod b/go.mod index 0efafb9..92500c8 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,6 @@ module github.com/ViBiOh/deploy go 1.16 require ( - github.com/ViBiOh/httputils/v3 v3.37.2 + github.com/ViBiOh/httputils/v4 v4.0.0 github.com/ViBiOh/mailer v1.14.0 ) diff --git a/go.sum b/go.sum index 4ca0b43..ac910f5 100644 --- a/go.sum +++ b/go.sum @@ -7,6 +7,8 @@ github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWX github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/ViBiOh/httputils/v3 v3.37.2 h1:b3Hm7+PbyBAIitdT0vEvATjZj8lIZ2+0tC8Ecfgd+MI= github.com/ViBiOh/httputils/v3 v3.37.2/go.mod h1:PocQEM67sTVg51k0kYtoSA3JrwZmEVo5aIBqto/JKek= +github.com/ViBiOh/httputils/v4 v4.0.0 h1:FW7YanNVCcDaKCQ7UAramPv2ovuW2OZndYs8ftHEFb8= +github.com/ViBiOh/httputils/v4 v4.0.0/go.mod h1:+mwW3YVDPI9y1Fx1ZXbehJPqWDFtlDLsNL5otGeBSBw= github.com/ViBiOh/mailer v1.14.0 h1:PwlsCzypGEfNzH0f6/TocHDKlYkNGbFa7BWG0X3XSlg= github.com/ViBiOh/mailer v1.14.0/go.mod h1:meIw1djU80vo0LVhuc/MJOo4YmX2swiW6D9w7hLCRxk= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= @@ -88,7 +90,6 @@ github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrU github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= -github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= @@ -217,7 +218,6 @@ github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXP github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= -github.com/prometheus/client_golang v1.7.1 h1:NTGy1Ja9pByO+xAeH/qiWnLrKtr3hJPNjaVUwnjpdpA= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= github.com/prometheus/client_golang v1.9.0 h1:Rrch9mh17XcxvEu9D9DEpb4isxjGBtcevQjKvxPRQIU= github.com/prometheus/client_golang v1.9.0/go.mod h1:FqZLKOZnGdFAhOK4nqGHa7D66IdsO+O441Eve7ptJDU= @@ -231,7 +231,6 @@ github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6T github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA= -github.com/prometheus/common v0.10.0 h1:RyRA7RzGXQZiW+tGMr7sxa85G1z0yOpM1qq5c8lNawc= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.15.0 h1:4fgOnadei3EZvgRwxJ7RMpG1k1pOZth5Pc13tyspaKM= github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= @@ -239,7 +238,6 @@ github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= -github.com/prometheus/procfs v0.1.3 h1:F0+tqvhOksq22sc6iCHF5WGlWjdwj92p0udFh1VFBS8= github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.2.0 h1:wH4vA7pcjKuZzjF7lM8awk4fnuJO6idemZXoKnULUx4= github.com/prometheus/procfs v0.2.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= @@ -271,7 +269,9 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/tdewolff/minify/v2 v2.9.12/go.mod h1:yuntVVAFuGyi9VmiRoUqAYEQnFCGO929ytj2ITMZuB8= +github.com/tdewolff/minify/v2 v2.9.13/go.mod h1:faNOp+awAoo+fhFHD+NAkBOaXBAvJI2X2SDERGKnARo= github.com/tdewolff/parse/v2 v2.5.9/go.mod h1:WzaJpRSbwq++EIQHYIRTpbYKNA3gn9it1Ik++q4zyho= +github.com/tdewolff/parse/v2 v2.5.10/go.mod h1:WzaJpRSbwq++EIQHYIRTpbYKNA3gn9it1Ik++q4zyho= github.com/tdewolff/test v1.0.6/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= @@ -300,9 +300,7 @@ golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3 h1:XQyxROzUlZH+WIQwySDgnISgOivlhjIEwaQaJEJrrN0= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= @@ -351,9 +349,7 @@ golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200724161237-0e2f3a69832c h1:UIcGWL6/wpCfyGuJnRFJRurA+yj8RrW7Q6x2YMCXt6c= golang.org/x/sys v0.0.0-20200724161237-0e2f3a69832c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201214210602-f9fddec55a1e h1:AyodaIpKjppX+cBfTASF2E1US3H2JFBj920Ot3rtDjs= golang.org/x/sys v0.0.0-20201214210602-f9fddec55a1e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4 h1:myAQVi0cGEoqQVR5POX+8RR2mrocKqNN1hmeMqhX27k= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/pkg/annotation/annotation.go b/pkg/annotation/annotation.go index dc39dcf..a18fcb2 100644 --- a/pkg/annotation/annotation.go +++ b/pkg/annotation/annotation.go @@ -5,8 +5,8 @@ import ( "flag" "strings" - "github.com/ViBiOh/httputils/v3/pkg/flags" - "github.com/ViBiOh/httputils/v3/pkg/request" + "github.com/ViBiOh/httputils/v4/pkg/flags" + "github.com/ViBiOh/httputils/v4/pkg/request" ) // App of package diff --git a/pkg/api/api.go b/pkg/api/api.go index 5cf4931..808a456 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -15,10 +15,10 @@ import ( "time" "github.com/ViBiOh/deploy/pkg/annotation" - "github.com/ViBiOh/httputils/v3/pkg/cron" - "github.com/ViBiOh/httputils/v3/pkg/flags" - "github.com/ViBiOh/httputils/v3/pkg/httperror" - "github.com/ViBiOh/httputils/v3/pkg/logger" + "github.com/ViBiOh/httputils/v4/pkg/cron" + "github.com/ViBiOh/httputils/v4/pkg/flags" + "github.com/ViBiOh/httputils/v4/pkg/httperror" + "github.com/ViBiOh/httputils/v4/pkg/logger" "github.com/ViBiOh/mailer/pkg/client" )