Skip to content

Commit

Permalink
refactor, remove dirty migration, npm update
Browse files Browse the repository at this point in the history
  • Loading branch information
vx3r committed Apr 19, 2020
1 parent 9e4b22d commit a765dea
Show file tree
Hide file tree
Showing 12 changed files with 866 additions and 963 deletions.
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ build-back:
stage: build artifacts
image: golang:latest
script:
- GOOS=linux GOARCH=amd64 go build -ldflags="-X 'gitlab.127-0-0-1.fr/vx3r/wg-gen-web/util.Version=${CI_COMMIT_SHA}'" -o ${CI_PROJECT_NAME}-linux-amd64
- GOOS=linux GOARCH=amd64 go build -ldflags="-X 'gitlab.127-0-0-1.fr/vx3r/wg-gen-web/version.Version=${CI_COMMIT_SHA}'" gitlab.127-0-0-1.fr/vx3r/wg-gen-web/cmd/wg-gen-web -o ${CI_PROJECT_NAME}-linux-amd64
artifacts:
paths:
- ${CI_PROJECT_NAME}-linux-amd64
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ FROM golang:alpine AS build-back
WORKDIR /app
ARG COMMIT
COPY . .
RUN go build -ldflags="-X 'gitlab.127-0-0-1.fr/vx3r/wg-gen-web/util.Version=${COMMIT}'" -o wg-gen-web-linux
RUN go build -ldflags="-X 'gitlab.127-0-0-1.fr/vx3r/wg-gen-web/version.Version=${COMMIT}'" gitlab.127-0-0-1.fr/vx3r/wg-gen-web/cmd/wg-gen-web -o wg-gen-web-linux

FROM node:10-alpine AS build-front
WORKDIR /app
Expand Down
8 changes: 4 additions & 4 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"gitlab.127-0-0-1.fr/vx3r/wg-gen-web/core"
"gitlab.127-0-0-1.fr/vx3r/wg-gen-web/model"
"gitlab.127-0-0-1.fr/vx3r/wg-gen-web/template"
"gitlab.127-0-0-1.fr/vx3r/wg-gen-web/util"
"gitlab.127-0-0-1.fr/vx3r/wg-gen-web/version"
"net/http"
)

Expand All @@ -30,7 +30,7 @@ func ApplyRoutes(r *gin.Engine) {
server.GET("", readServer)
server.PATCH("", updateServer)
server.GET("/config", configServer)
server.GET("/version", version)
server.GET("/version", versionStr)
}
}

Expand Down Expand Up @@ -238,8 +238,8 @@ func configServer(c *gin.Context) {
c.Data(http.StatusOK, "application/config", configData)
}

func version(c *gin.Context) {
func versionStr(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"version": util.Version,
"version": version.Version,
})
}
17 changes: 2 additions & 15 deletions main.go → cmd/wg-gen-web/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"gitlab.127-0-0-1.fr/vx3r/wg-gen-web/api"
"gitlab.127-0-0-1.fr/vx3r/wg-gen-web/core"
"gitlab.127-0-0-1.fr/vx3r/wg-gen-web/util"
"gitlab.127-0-0-1.fr/vx3r/wg-gen-web/version"
"os"
"path/filepath"
)
Expand All @@ -22,7 +23,7 @@ func init() {
}

func main() {
log.Infof("Starting Wg Gen Web version: %s", util.Version)
log.Infof("Starting Wg Gen Web version: %s", version.Version)

// load .env environment variables
err := godotenv.Load()
Expand Down Expand Up @@ -65,20 +66,6 @@ func main() {
log.SetLevel(log.InfoLevel)
}

// migrate
err = core.MigrateInitialStructChange()
if err != nil {
log.WithFields(log.Fields{
"err": err,
}).Fatal("failed to migrate initial struct changes")
}
err = core.MigratePresharedKey()
if err != nil {
log.WithFields(log.Fields{
"err": err,
}).Fatal("failed to migrate preshared key struct changes")
}

// dump wg config file
err = core.UpdateServerConfigWg()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion core/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func ReadClientConfig(id string) ([]byte, error) {
return configDataWg, nil
}

// SendEmail to client
// EmailClient send email to client
func EmailClient(id string) error {
client, err := ReadClient(id)
if err != nil {
Expand Down
Loading

0 comments on commit a765dea

Please sign in to comment.