Linting and dockerization.
This commit is contained in:
parent
cd6e739dc2
commit
355dac8ea3
15
.drone.yml
Normal file
15
.drone.yml
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: build
|
||||
|
||||
steps:
|
||||
- name: docker
|
||||
image: plugins/docker
|
||||
settings:
|
||||
username:
|
||||
from_secret: dockerhub_user
|
||||
password:
|
||||
from_secret: dockerhub_password
|
||||
repo: pztrn/giredore
|
||||
auto_tag: true
|
18
.golangci.yml
Normal file
18
.golangci.yml
Normal file
@ -0,0 +1,18 @@
|
||||
run:
|
||||
deadline: 5m
|
||||
linters:
|
||||
enable-all: true
|
||||
disable:
|
||||
# Because globals might exist, but according to our codestyle they
|
||||
# should be lowercased and considered as unexported.
|
||||
- gochecknoglobals
|
||||
# While it might be useful it'll create more problems that will solve.
|
||||
- gocritic
|
||||
# Complains about main() lengths, which isn't an issue.
|
||||
- funlen
|
||||
linters-settings:
|
||||
lll:
|
||||
line-length: 420
|
||||
gocyclo:
|
||||
min-complexity: 40
|
||||
|
17
Dockerfile
Normal file
17
Dockerfile
Normal file
@ -0,0 +1,17 @@
|
||||
FROM golang:1.13.1-alpine AS build
|
||||
|
||||
WORKDIR /go/src/sources.dev.pztrn.name/pztrn/giredore
|
||||
COPY . .
|
||||
|
||||
WORKDIR /go/src/gitlab.com/pztrn/fastpastebin/cmd/fastpastebin
|
||||
|
||||
RUN cd /go/src/sources.dev.pztrn.name/pztrn/giredore/cmd/giredored && go build && cd ../giredorectl && go build
|
||||
|
||||
FROM alpine:latest
|
||||
LABEL maintainer "Stanislav N. <pztrn@pztrn.name>"
|
||||
|
||||
COPY --from=build /go/src/sources.dev.pztrn.name/pztrn/giredore/cmd/giredored/giredored /usr/local/bin/giredored
|
||||
COPY --from=build /go/src/sources.dev.pztrn.name/pztrn/giredore/cmd/giredorectl/giredorectl /usr/local/bin/giredorectl
|
||||
|
||||
EXPOSE 62222
|
||||
ENTRYPOINT [ "/usr/local/bin/giredored" ]
|
@ -5,7 +5,7 @@ import (
|
||||
"os"
|
||||
|
||||
// local
|
||||
"sources.dev.pztrn.name/pztrn/giredore/domains/client/v1"
|
||||
clientv1 "sources.dev.pztrn.name/pztrn/giredore/domains/client/v1"
|
||||
"sources.dev.pztrn.name/pztrn/giredore/internal/logger"
|
||||
|
||||
// other
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
"syscall"
|
||||
|
||||
// local
|
||||
"sources.dev.pztrn.name/pztrn/giredore/domains/server/v1"
|
||||
serverv1 "sources.dev.pztrn.name/pztrn/giredore/domains/server/v1"
|
||||
"sources.dev.pztrn.name/pztrn/giredore/internal/configuration"
|
||||
"sources.dev.pztrn.name/pztrn/giredore/internal/httpserver"
|
||||
"sources.dev.pztrn.name/pztrn/giredore/internal/logger"
|
||||
|
@ -31,7 +31,7 @@ func packagesGET(ec echo.Context) error {
|
||||
pkgs, errors = configuration.Cfg.GetPackagesInfo(req.PackageNames)
|
||||
}
|
||||
|
||||
if errors != nil && len(errors) > 0 {
|
||||
if len(errors) > 0 {
|
||||
return ec.JSON(http.StatusBadRequest, &structs.Reply{Status: structs.StatusFailure, Errors: errors, Data: pkgs})
|
||||
}
|
||||
|
||||
|
@ -9,8 +9,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
log zerolog.Logger
|
||||
loggerInitialized bool
|
||||
log zerolog.Logger
|
||||
|
||||
envCfg *envConfig
|
||||
Cfg *fileConfig
|
||||
@ -18,7 +17,6 @@ var (
|
||||
|
||||
func Initialize() {
|
||||
log = logger.Logger.With().Str("type", "internal").Str("package", "configuration").Logger()
|
||||
loggerInitialized = true
|
||||
log.Info().Msg("Initializing...")
|
||||
|
||||
envCfg = &envConfig{}
|
||||
|
@ -49,7 +49,6 @@ func Shutdown() {
|
||||
log.Fatal().Err(err).Msg("Failed to stop HTTP server")
|
||||
}
|
||||
log.Info().Msg("HTTP server shutted down")
|
||||
|
||||
}
|
||||
|
||||
// Start starts HTTP server and checks that server is ready to process
|
||||
@ -60,7 +59,7 @@ func Start() {
|
||||
go func() {
|
||||
err := Srv.Start(configuration.Cfg.HTTP.Listen)
|
||||
if !strings.Contains(err.Error(), "Server closed") {
|
||||
log.Fatal().Err(err).Msg("HTTP server critial error occured")
|
||||
log.Fatal().Err(err).Msg("HTTP server critial error occurred")
|
||||
}
|
||||
}()
|
||||
|
||||
@ -75,7 +74,7 @@ func Start() {
|
||||
time.Sleep(time.Second * 1)
|
||||
resp, err := httpc.Get("http://" + configuration.Cfg.HTTP.Listen + "/_internal/waitForOnline")
|
||||
if err != nil {
|
||||
log.Debug().Err(err).Msg("HTTP error occured, HTTP server isn't ready, waiting...")
|
||||
log.Debug().Err(err).Msg("HTTP error occurred, HTTP server isn't ready, waiting...")
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -14,8 +14,6 @@ import (
|
||||
var (
|
||||
Logger zerolog.Logger
|
||||
SuperVerbosive bool
|
||||
|
||||
loggerInitialized bool
|
||||
)
|
||||
|
||||
// Initialize initializes zerolog with proper formatting and log level.
|
||||
@ -72,5 +70,4 @@ func Initialize() {
|
||||
}
|
||||
|
||||
Logger = zerolog.New(output).With().Timestamp().Logger()
|
||||
loggerInitialized = true
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user