-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from isd-sgcu/make-monolith
Make monolith
- Loading branch information
Showing
143 changed files
with
7,734 additions
and
5,915 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
root = "." | ||
testdata_dir = "testdata" | ||
tmp_dir = "tmp" | ||
|
||
[build] | ||
args_bin = [] | ||
bin = "./tmp/main" | ||
cmd = "go build -o ./tmp/main ./cmd/main.go" | ||
delay = 1000 | ||
exclude_dir = ["assets", "tmp", "vendor", "testdata"] | ||
exclude_file = [] | ||
exclude_regex = ["_test.go"] | ||
exclude_unchanged = false | ||
follow_symlink = false | ||
full_bin = "" | ||
include_dir = [] | ||
include_ext = ["go", "tpl", "tmpl", "html"] | ||
include_file = [] | ||
kill_delay = "0s" | ||
log = "build-errors.log" | ||
poll = false | ||
poll_interval = 0 | ||
post_cmd = [] | ||
pre_cmd = [] | ||
rerun = false | ||
rerun_delay = 500 | ||
send_interrupt = false | ||
stop_on_error = false | ||
|
||
[color] | ||
app = "" | ||
build = "yellow" | ||
main = "magenta" | ||
runner = "green" | ||
watcher = "cyan" | ||
|
||
[log] | ||
main_only = false | ||
time = false | ||
|
||
[misc] | ||
clean_on_exit = false | ||
|
||
[proxy] | ||
app_port = 0 | ||
enabled = false | ||
proxy_port = 0 | ||
|
||
[screen] | ||
clear_on_rebuild = false | ||
keep_scroll = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,26 @@ APP_PORT=3001 | |
APP_ENV=development | ||
APP_MAX_FILE_SIZE=10 | ||
|
||
SERVICE_AUTH=localhost:3002 | ||
SERVICE_BACKEND=localhost:3003 | ||
SERVICE_FILE=localhost:3004 | ||
DB_URL=postgres://root:root@localhost:5432/johnjud_db | ||
|
||
JWT_SECRET=secret | ||
JWT_EXPIRES_IN=3600 | ||
JWT_REFRESH_TOKEN_TTL=604800 | ||
JWT_ISSUER=issuer | ||
JWT_RESET_TOKEN_TTL=900 | ||
|
||
REDIS_HOST=localhost | ||
REDIS_PORT=6379 | ||
REDIS_PASSWORD= | ||
|
||
AUTH_CLIENT_URL=http://localhost:3000 | ||
|
||
SENDGRID_API_KEY=api_key | ||
SENDGRID_NAME=johnjud | ||
[email protected] | ||
|
||
BUCKET_ENDPOINT=BUCKET_ENDPOINT | ||
BUCKET_ACCESS_KEY=BUCKET_ACCESS_KEY | ||
BUCKET_SECRET_KEY=BUCKET_SECRET_KEY | ||
BUCKET_NAME=johnjud-pet-images | ||
BUCKET_USE_SSL=true |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,26 +54,26 @@ jobs: | |
cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache | ||
cache-to: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache,mode=max | ||
|
||
update-gitops: | ||
name: Update gitops repository | ||
runs-on: ubuntu-latest | ||
# update-gitops: | ||
# name: Update gitops repository | ||
# runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout gitops repository | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: isd-sgcu/isd-gitops | ||
token: ${{ secrets.GITOPS_TOKEN }} | ||
# steps: | ||
# - name: Checkout gitops repository | ||
# uses: actions/checkout@v4 | ||
# with: | ||
# repository: isd-sgcu/isd-gitops | ||
# token: ${{ secrets.GITOPS_TOKEN }} | ||
|
||
- name: Update image tag | ||
uses: mikefarah/yq@master | ||
env: | ||
NEW_TAG: ${{ github.ref_type == 'tag' && github.ref_name || env.IMAGE_TAG }} | ||
with: | ||
cmd: yq -i '.gateway.imageTag = strenv(NEW_TAG)' projects/johnjud/values/gateway-dev.values.yaml | ||
# - name: Update image tag | ||
# uses: mikefarah/yq@master | ||
# env: | ||
# NEW_TAG: ${{ github.ref_type == 'tag' && github.ref_name || env.IMAGE_TAG }} | ||
# with: | ||
# cmd: yq -i '.gateway.imageTag = strenv(NEW_TAG)' projects/johnjud/values/gateway-dev.values.yaml | ||
|
||
- name: Commit & Push changes | ||
uses: actions-js/[email protected] | ||
with: | ||
github_token: ${{ secrets.GITOPS_TOKEN }} | ||
repository: isd-sgcu/isd-gitops | ||
# - name: Commit & Push changes | ||
# uses: actions-js/[email protected] | ||
# with: | ||
# github_token: ${{ secrets.GITOPS_TOKEN }} | ||
# repository: isd-sgcu/isd-gitops |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,4 +54,6 @@ github.com | |
coverage.out | ||
coverage.html | ||
|
||
token.txt | ||
token.txt | ||
tmp | ||
docker-compose.qa.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package bucket | ||
|
||
import ( | ||
"bytes" | ||
"context" | ||
"time" | ||
|
||
"github.com/isd-sgcu/johnjud-backend/config" | ||
"github.com/minio/minio-go/v7" | ||
"github.com/pkg/errors" | ||
"github.com/rs/zerolog/log" | ||
) | ||
|
||
type Client interface { | ||
Upload([]byte, string) (string, string, error) | ||
Delete(string) error | ||
DeleteMany([]string) error | ||
} | ||
|
||
type clientImpl struct { | ||
conf config.Bucket | ||
minio *minio.Client | ||
} | ||
|
||
func NewClient(conf config.Bucket, minioClient *minio.Client) Client { | ||
return &clientImpl{conf: conf, minio: minioClient} | ||
} | ||
|
||
func (c *clientImpl) Upload(file []byte, objectKey string) (string, string, error) { | ||
ctx := context.Background() | ||
_, cancel := context.WithTimeout(ctx, 50*time.Second) | ||
defer cancel() | ||
|
||
buffer := bytes.NewReader(file) | ||
|
||
uploadOutput, err := c.minio.PutObject(context.Background(), c.conf.BucketName, objectKey, buffer, | ||
buffer.Size(), minio.PutObjectOptions{ContentType: "application/octet-stream"}) | ||
if err != nil { | ||
log.Error(). | ||
Err(err). | ||
Str("service", "file"). | ||
Str("module", "bucket client"). | ||
Msgf("Couldn't upload object to %v:%v.", c.conf.BucketName, objectKey) | ||
|
||
return "", "", errors.Wrap(err, "Error while uploading the object") | ||
} | ||
|
||
return c.getURL(objectKey), uploadOutput.Key, nil | ||
} | ||
|
||
func (c *clientImpl) Delete(objectKey string) error { | ||
ctx := context.Background() | ||
_, cancel := context.WithTimeout(ctx, 50*time.Second) | ||
defer cancel() | ||
|
||
opts := minio.RemoveObjectOptions{ | ||
GovernanceBypass: true, | ||
} | ||
err := c.minio.RemoveObject(context.Background(), c.conf.BucketName, objectKey, opts) | ||
if err != nil { | ||
log.Error(). | ||
Err(err). | ||
Str("service", "file"). | ||
Str("module", "bucket client"). | ||
Msgf("Couldn't delete object from bucket %v:%v.", c.conf.BucketName, objectKey) | ||
|
||
return errors.Wrap(err, "Error while deleting the object") | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (c *clientImpl) DeleteMany(objectKeys []string) error { | ||
ctx := context.Background() | ||
_, cancel := context.WithTimeout(ctx, 50*time.Second) | ||
defer cancel() | ||
|
||
opts := minio.RemoveObjectOptions{ | ||
GovernanceBypass: true, | ||
} | ||
for _, objectKey := range objectKeys { | ||
err := c.minio.RemoveObject(context.Background(), c.conf.BucketName, objectKey, opts) | ||
if err != nil { | ||
log.Error(). | ||
Err(err). | ||
Str("service", "file"). | ||
Str("module", "bucket client"). | ||
Msgf("Couldn't delete object from bucket %v:%v.", c.conf.BucketName, objectKey) | ||
|
||
return errors.Wrap(err, "Error while deleting the object") | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (c *clientImpl) getURL(objectKey string) string { | ||
return "https://" + c.conf.Endpoint + "/" + c.conf.BucketName + "/" + objectKey | ||
} |
Oops, something went wrong.