Compare commits

..

8 Commits

Author SHA1 Message Date
Pasha
811783e1c4 fix lint
All checks were successful
Lint / Lint (push) Successful in 1m49s
2024-11-26 22:15:01 +03:00
Pasha
7af3f682b8 applied renamer
All checks were successful
Lint / Lint (push) Successful in 1m52s
2024-11-26 18:31:12 +00:00
ffc3d246f6 remove .git from taskfile
All checks were successful
Lint / Lint (push) Successful in 1m46s
2024-11-26 17:14:58 +03:00
ab89c0677d replace all themakers/hlog to penaside/hlog because themakers deleted one
Some checks failed
Lint / Lint (push) Failing after 1m11s
2024-11-26 02:11:24 +03:00
f8a2561b46 Merge remote-tracking branch 'origin/dev' into staging
Some checks failed
Deploy / CreateImage (push) Successful in 1m22s
Deploy / DeployService (push) Successful in 46s
Lint / Lint (push) Failing after 1m5s
2024-11-17 01:27:06 +03:00
990bee2c5f enable service discovery artefacts creation 2024-09-07 15:42:23 +03:00
c79db15dd5 timeweb storage 2024-05-28 16:31:16 +03:00
52affcccd8 ci: remove from external interface 2024-04-21 21:14:55 +03:00
24 changed files with 122 additions and 98 deletions

@ -19,8 +19,9 @@ jobs:
DeployService:
runs-on: [hubstaging]
needs: CreateImage
uses: http://gitea.pena/PenaDevops/actions.git/.gitea/workflows/deploy.yml@v1.0.1
uses: http://gitea.pena/PenaDevops/actions.git/.gitea/workflows/deploy.yml@v1.0.3
with:
runner: hubstaging
actionid: ${{ gitea.run_id }}

@ -9,6 +9,6 @@ on:
jobs:
Lint:
runs-on: [hubstaging]
uses: http://gitea.pena/PenaDevops/actions.git/.gitea/workflows/lint.yml@v1.1.0
uses: http://gitea.pena/PenaDevops/actions.git/.gitea/workflows/lint.yml@v1.1.2
with:
runner: hubstaging

40
.gitlab-ci.yml Normal file

@ -0,0 +1,40 @@
include:
- project: "devops/pena-continuous-integration"
file: "/templates/docker/build-template.gitlab-ci.yml"
- project: "devops/pena-continuous-integration"
file: "/templates/docker/deploy-template.gitlab-ci.yml"
- project: "devops/pena-continuous-integration"
file: "/templates/docker/golint.gitlab-ci.yml"
- project: "devops/pena-continuous-integration"
file: "/templates/docker/service-discovery.gitlab-ci.yml"
stages:
- lint
- build
- deploy
- service-discovery
lint:
extends: .golint_template
build-app:
tags:
- gobuild
extends: .build_template
deploy-to-staging:
rules:
- if: "$CI_COMMIT_BRANCH == $STAGING_BRANCH"
extends: .deploy_template
tags:
- staging
extends: .deploy_template
deploy-to-prod:
rules:
- if: "$CI_COMMIT_BRANCH == $PRODUCTION_BRANCH"
tags:
- prod
extends: .deploy_template
service-discovery:
extends: .sd_artefacts_template

@ -1,9 +1,11 @@
FROM gitea.pena/penadevops/container-images/golang:main as builder
WORKDIR /app
COPY go.mod ./
COPY go.sum ./
RUN go mod download
RUN apk add git
COPY . .
ENV GOPRIVATE=gitea.pena/PenaSide/linters-golang
ENV GOINSECURE=gitea.pena/PenaSide/linters-golang
RUN go env
RUN go mod download -x
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o heruvym
FROM gitea.pena/penadevops/container-images/alpine:main

@ -3,8 +3,8 @@ version: "3"
tasks:
update-linter:
cmds:
- go get -u gitea.pena/PenaSide/linters-golang.git
- go get -u gitea.pena/PenaSide/linters-golang
lint:
cmds:
- task: update-linter
- cmd: golangci-lint run -v -c $(go list -f '{{"{{"}}.Dir{{"}}"}}' -m gitea.pena/PenaSide/linters-golang.git)/.golangci.yml
- cmd: golangci-lint run -v -c $(go list -f '{{"{{"}}.Dir{{"}}"}}' -m gitea.pena/PenaSide/linters-golang)/.golangci.yml

@ -4,20 +4,20 @@ import (
"context"
"errors"
"fmt"
"gitea.pena/PenaSide/heruvym/dal/minio"
"gitea.pena/PenaSide/heruvym/dal/mongo"
"gitea.pena/PenaSide/heruvym/middleware"
"gitea.pena/PenaSide/heruvym/router"
"gitea.pena/PenaSide/heruvym/service"
"gitea.pena/PenaSide/heruvym/tools"
"github.com/go-redis/redis/v8"
"heruvym/dal/minio"
"heruvym/dal/mongo"
"heruvym/middleware"
"heruvym/router"
"heruvym/service"
"heruvym/tools"
"net/http"
"time"
"github.com/skeris/appInit"
tb "gopkg.in/tucnak/telebot.v2"
"github.com/themakers/hlog"
"gitea.pena/PenaSide/hlog"
"go.uber.org/zap"
)
@ -47,7 +47,7 @@ type Options struct {
RedisHost string `env:"REDIS_HOST" default:"localhost:6379"`
RedisPassword string `env:"REDIS_PASSWORD" default:""`
RedisDB uint64 `env:"REDIS_DB" default:"0"`
TgChatID uint64 `env:"TELEGRAM_CHAT_ID" default:"1001344671794"`
TgChatID uint64 `env:"TELEGRAM_CHAT_ID" default:"1001344671794"`
}
var (

@ -6,9 +6,9 @@ import (
"github.com/gofiber/fiber/v2/middleware/cors"
"github.com/gofiber/fiber/v2/middleware/recover"
"go.uber.org/zap"
"heruvym/dal/mongo"
"heruvym/middleware"
"heruvym/service"
"gitea.pena/PenaSide/heruvym/dal/mongo"
"gitea.pena/PenaSide/heruvym/middleware"
"gitea.pena/PenaSide/heruvym/service"
)
type AccountHTTP struct {

@ -8,7 +8,7 @@ import (
"github.com/minio/minio-go/v7"
"github.com/minio/minio-go/v7/pkg/credentials"
"github.com/themakers/hlog"
"gitea.pena/PenaSide/hlog"
)
type BlobStore struct {
@ -16,7 +16,10 @@ type BlobStore struct {
store *minio.Client
}
const bucket = "pair"
const (
bucket = "3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b"
folder = "angelsight"
)
func New(ctx context.Context, logger hlog.Logger,
endpoint, keyID, accessKey, token, region string,
@ -32,17 +35,6 @@ func New(ctx context.Context, logger hlog.Logger,
}
fmt.Println("monio", keyID, accessKey, token, region)
bucketExists, err := conn.BucketExists(ctx, bucket)
if err != nil {
return nil, err
}
if !bucketExists {
if err := conn.MakeBucket(ctx, bucket, minio.MakeBucketOptions{}); err != nil {
return nil, err
}
}
return &BlobStore{
log: logger.Module("minio"),
store: conn,
@ -54,7 +46,7 @@ func (bs *BlobStore) PutFile(
filename string,
reader io.Reader,
size int64) error {
info, err := bs.store.PutObject(ctx, bucket, filename, reader, size, minio.PutObjectOptions{
info, err := bs.store.PutObject(ctx, bucket, folder+"/"+filename, reader, size, minio.PutObjectOptions{
//UserMetadata: nil,
//UserTags: nil,
//Progress: nil,
@ -85,7 +77,7 @@ func (bs *BlobStore) PutFile(
}
func (bs *BlobStore) DeleteFile(ctx context.Context, id string) error {
if err := bs.store.RemoveObject(ctx, bucket, id, minio.RemoveObjectOptions{
if err := bs.store.RemoveObject(ctx, bucket, folder+"/"+id, minio.RemoveObjectOptions{
//GovernanceBypass: false,
//VersionID: "",
//Internal: AdvancedRemoveOptions
@ -97,7 +89,7 @@ func (bs *BlobStore) DeleteFile(ctx context.Context, id string) error {
}
func (bs *BlobStore) FileExists(ctx context.Context, filename string) (bool, error) {
_, err := bs.store.StatObject(ctx, bucket, filename, minio.StatObjectOptions{})
_, err := bs.store.StatObject(ctx, bucket, folder+"/"+filename, minio.StatObjectOptions{})
if err != nil {
if minio.ToErrorResponse(err).StatusCode == http.StatusNotFound {
return false, nil

@ -4,11 +4,11 @@ import (
"context"
"errors"
"fmt"
"heruvym/model"
"gitea.pena/PenaSide/heruvym/model"
"time"
"github.com/rs/xid"
"github.com/themakers/hlog"
"gitea.pena/PenaSide/hlog"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"

@ -3,9 +3,9 @@ package mongo
import (
"context"
"github.com/stretchr/testify/suite"
"github.com/themakers/hlog"
"gitea.pena/PenaSide/hlog"
"go.uber.org/zap"
"heruvym/model"
"gitea.pena/PenaSide/heruvym/model"
"testing"
)

@ -1,33 +1,24 @@
services:
heruvym:
container_name: heruvym
restart: unless-stopped
image: $CI_REGISTRY_IMAGE/staging:$CI_COMMIT_REF_SLUG.$CI_PIPELINE_ID
image: gitea.pena:3000/penaside/heruvym/staging:$GITHUB_RUN_NUMBER
ports:
- 1488:1488
expose:
- 1488
networks:
- backend_external
- default
hostname: heruvym
- 10.7.0.6:1487:1488
labels:
com.pena.upload: true
com.pena.allowed_headers: content-type,authorization,response-type
tty: true
environment:
- BB_PORT=1488
- BB_IS_PROD=true
- BB_MINIO_AK=$BB_MINIO_AK
- BB_MINIO_EP=$BB_MINIO_EP
- BB_MINIO_SK=$BB_MINIO_SK
- BB_MINIO_AK=5CV77KVDUU9H0II9R24M
- BB_MINIO_EP=s3.timeweb.cloud
- BB_MINIO_SK=0W0m8DyvdAKRJnsAy6mB5zndQ7RouJBLhqhtThcu
- BB_MONGO_URI=$BB_MONGO_URI
- S3_REGION=$S3_REGION
- S3_REGION=ru-1
- JWT_SECRET=$JWT_SECRET
- TELEGRAM_TOKEN=6414077478:AAFk03HezovLT2kO_i9OYswH8Weirsgp9GU
- TELEGRAM_CHAT_ID=1002089014760
- REDIS_HOST=10.8.0.6:6379
- REDIS_HOST=10.8.0.5:6379
- REDIS_PASSWORD=Redalert2
- REDIS_DB=4
networks:
backend_external:
driver: bridge
attachable: true
internal: true

8
go.mod

@ -1,9 +1,10 @@
module heruvym
module gitea.pena/PenaSide/heruvym
go 1.23.2
require (
gitea.pena/PenaSide/linters-golang.git v0.0.0-20241107123845-60e4981764af
gitea.pena/PenaSide/hlog v0.0.0-20241125221102-a54c29c002a9
gitea.pena/PenaSide/linters-golang v0.0.0-20241119212350-2759fa93724a
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/go-playground/validator/v10 v10.13.0
github.com/go-redis/redis/v8 v8.11.5
@ -16,7 +17,6 @@ require (
github.com/skeris/appInit v1.0.2
github.com/stretchr/testify v1.8.2
github.com/themakers/bdd v0.0.0-20210316111417-6b1dfe326f33
github.com/themakers/hlog v0.0.0-20191205140925-235e0e4baddf
go.mongodb.org/mongo-driver v1.10.3
go.uber.org/zap v1.27.0
gopkg.in/tucnak/telebot.v2 v2.5.0
@ -60,7 +60,7 @@ require (
github.com/xdg-go/scram v1.1.1 // indirect
github.com/xdg-go/stringprep v1.0.3 // indirect
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect
go.uber.org/multierr v1.10.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.7.0 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/sync v0.1.0 // indirect

14
go.sum

@ -1,7 +1,7 @@
gitea.pena/PenaSide/linters-golang v0.0.0-20241114215743-9a8e7d58cf96 h1:m4EMXEhsA/glI6eJeZnRGUhYPSQdcWj3hzT2IDNlWS0=
gitea.pena/PenaSide/linters-golang v0.0.0-20241114215743-9a8e7d58cf96/go.mod h1:gdd+vOT6up9STkEbxa2qESLIMZFjCmRbkcheFQCVgZU=
gitea.pena/PenaSide/linters-golang.git v0.0.0-20241107123845-60e4981764af h1:g9U+JXUI9daAZbSw+uW+5tlEdkejdRUwbJxu6FMHi24=
gitea.pena/PenaSide/linters-golang.git v0.0.0-20241107123845-60e4981764af/go.mod h1:KOzb6hT9ASsvA6RB41GoQIwRhFr/U+f8jx3fnQsknXk=
gitea.pena/PenaSide/hlog v0.0.0-20241125221102-a54c29c002a9 h1:tBkXWNIt8icmkMMnq8MA421RWkUy4OZh5P7C3q8uCu4=
gitea.pena/PenaSide/hlog v0.0.0-20241125221102-a54c29c002a9/go.mod h1:sanhSL8aEsfcq21P+eItYiAnKAre+B67nGJmDfk2cf0=
gitea.pena/PenaSide/linters-golang v0.0.0-20241119212350-2759fa93724a h1:UySqMgaOKNsR42Y6GQXoM2wn/waYNc9cakMUSvbEEAg=
gitea.pena/PenaSide/linters-golang v0.0.0-20241119212350-2759fa93724a/go.mod h1:gdd+vOT6up9STkEbxa2qESLIMZFjCmRbkcheFQCVgZU=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs=
github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
@ -130,8 +130,6 @@ github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/themakers/bdd v0.0.0-20210316111417-6b1dfe326f33 h1:N9f/Q+2Ssa+yDcbfaoLTYvXmdeyUUxsJKdPUVsjSmiA=
github.com/themakers/bdd v0.0.0-20210316111417-6b1dfe326f33/go.mod h1:rpcH99JknBh8seZmlOlUg51gasZH6QH34oXNsIwYT6E=
github.com/themakers/hlog v0.0.0-20191205140925-235e0e4baddf h1:TJJm6KcBssmbWzplF5lzixXl1RBAi/ViPs1GaSOkhwo=
github.com/themakers/hlog v0.0.0-20191205140925-235e0e4baddf/go.mod h1:1FsorU3vnXO9xS9SrhUp8fRb/6H/Zfll0rPt1i4GWaA=
github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
github.com/tinylib/msgp v1.1.6/go.mod h1:75BAfg2hauQhs3qedfdDZmWAPcFMAvJE5b9rGOMufyw=
@ -160,8 +158,8 @@ go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU=
go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ=
go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
go.uber.org/zap v1.16.0/go.mod h1:MA8QOfq0BHJwdXa996Y4dYkAqRKB8/1K1QMMZVaNZjQ=
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=

@ -2,8 +2,8 @@ package main
import (
"github.com/skeris/appInit"
"heruvym/app"
_ "gitea.pena/PenaSide/linters-golang.git/pkg/dummy"
"gitea.pena/PenaSide/heruvym/app"
_ "gitea.pena/PenaSide/linters-golang/pkg/dummy"
)
func main() {

@ -3,7 +3,7 @@ package middleware
import (
"github.com/gofiber/fiber/v2"
"github.com/rs/xid"
"heruvym/jwt_adapter"
"gitea.pena/PenaSide/heruvym/jwt_adapter"
"strings"
"time"
)

@ -3,14 +3,14 @@ package middleware
import (
"context"
"fmt"
"heruvym/jwt_adapter"
"gitea.pena/PenaSide/heruvym/jwt_adapter"
"net/http"
"strings"
"time"
errors2 "github.com/pkg/errors"
"github.com/rs/xid"
"github.com/themakers/hlog"
"gitea.pena/PenaSide/hlog"
)
// My MiddleWare with gorilla/mux

@ -1,10 +1,10 @@
package middleware
import (
"heruvym/jwt_adapter"
"gitea.pena/PenaSide/heruvym/jwt_adapter"
"net/http"
"github.com/themakers/hlog"
"gitea.pena/PenaSide/hlog"
)
func setJwtHeader(adapter *jwt_adapter.JwtAdapter, w http.ResponseWriter, logger hlog.Logger) error {

@ -2,7 +2,7 @@ package middleware
import (
"context"
"heruvym/jwt_adapter"
"gitea.pena/PenaSide/heruvym/jwt_adapter"
"net/http"
)

@ -8,7 +8,7 @@ import (
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
"heruvym/model"
"gitea.pena/PenaSide/heruvym/model"
)
const (

@ -8,13 +8,13 @@ import (
"errors"
"fmt"
"github.com/go-redis/redis/v8"
"heruvym/dal/minio"
"heruvym/dal/mongo"
"heruvym/jwt_adapter"
"heruvym/middleware"
"heruvym/model"
"heruvym/tools"
"heruvym/utils"
"gitea.pena/PenaSide/heruvym/dal/minio"
"gitea.pena/PenaSide/heruvym/dal/mongo"
"gitea.pena/PenaSide/heruvym/jwt_adapter"
"gitea.pena/PenaSide/heruvym/middleware"
"gitea.pena/PenaSide/heruvym/model"
"gitea.pena/PenaSide/heruvym/tools"
"gitea.pena/PenaSide/heruvym/utils"
"io"
"net/http"
"strings"
@ -22,7 +22,7 @@ import (
"time"
"github.com/rs/xid"
"github.com/themakers/hlog"
"gitea.pena/PenaSide/hlog"
tb "gopkg.in/tucnak/telebot.v2"
)

@ -3,9 +3,9 @@ package service
import (
"github.com/go-playground/validator/v10"
"github.com/gofiber/fiber/v2"
"heruvym/dal/mongo"
"heruvym/jwt_adapter"
"heruvym/model"
"gitea.pena/PenaSide/heruvym/dal/mongo"
"gitea.pena/PenaSide/heruvym/jwt_adapter"
"gitea.pena/PenaSide/heruvym/model"
"reflect"
)

@ -6,11 +6,11 @@ import (
"encoding/json"
"github.com/gofiber/fiber/v2"
"github.com/stretchr/testify/suite"
"github.com/themakers/hlog"
"gitea.pena/PenaSide/hlog"
"go.uber.org/zap"
"heruvym/dal/mongo"
"heruvym/middleware"
"heruvym/model"
"gitea.pena/PenaSide/heruvym/dal/mongo"
"gitea.pena/PenaSide/heruvym/middleware"
"gitea.pena/PenaSide/heruvym/model"
"net/http"
"testing"
)

@ -8,7 +8,7 @@ import (
"errors"
"fmt"
"github.com/skeris/appInit"
"heruvym/model"
"gitea.pena/PenaSide/heruvym/model"
"io"
"io/ioutil"
"mime/multipart"
@ -18,12 +18,12 @@ import (
"testing"
"time"
"heruvym/app"
"heruvym/service"
"gitea.pena/PenaSide/heruvym/app"
"gitea.pena/PenaSide/heruvym/service"
"github.com/stretchr/testify/assert"
"github.com/themakers/bdd"
"heruvym/jwt_adapter"
"gitea.pena/PenaSide/heruvym/jwt_adapter"
)
///create+

@ -7,4 +7,4 @@ var (
Commit = "unset"
// Release is a semantic version of current build
Release = "unset"
)
)