Skip to content

Commit

Permalink
Merge branch 'KKGo-Software-engineering:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
AnuchitO authored May 19, 2024
2 parents cdab154 + 5cc27b5 commit e5884f8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .env.template
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ENV=LOCAL
LOCAL_DATABASE_POSTGRES_URI=postgres://postgres:password@db:5432/hongjot?sslmode=disable
LOCAL_DATABASE_POSTGRES_URI=postgres://postgres:password@localhost:5432/hongjot?sslmode=disable
LOCAL_SERVER_PORT=8080

# Features Flags
LOCAL_ENABLE_CREATE_SPENDER=false
LOCAL_ENABLE_CREATE_SPENDER=false
28 changes: 11 additions & 17 deletions api/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (c Config) PostgresURI() string {
}

type Server struct {
Port string `env:"SERVER_PORT"`
Port string `env:"SERVER_PORT" envDefault:"3000"`
}

type Database struct {
Expand Down Expand Up @@ -61,31 +61,25 @@ func parse(envPrefix string) (Config, error) {
Prefix: prefix(envPrefix),
}

dbconf := &Database{}
if err := env.ParseWithOptions(dbconf, opts); err != nil {
dbconf := Database{}
if err := env.ParseWithOptions(&dbconf, opts); err != nil {
return Config{}, errors.New("failed to parse database config:" + err.Error())
}

feats := &FeatureFlag{}
if err := env.ParseWithOptions(feats, opts); err != nil {
feats := FeatureFlag{}
if err := env.ParseWithOptions(&feats, opts); err != nil {
return Config{}, errors.New("failed to parse feature flag config:" + err.Error())
}

port := Env("SERVER_PORT")
if port == "" {
port = "8080"
sev := Server{}
if err := env.ParseWithOptions(&sev, opts); err != nil {
return Config{}, errors.New("failed to parse server config:" + err.Error())
}

return Config{
Database: Database{
PostgresURI: dbconf.PostgresURI,
},
Server: Server{
Port: port,
},
FeatureFlag: FeatureFlag{
EnableCreateSpender: feats.EnableCreateSpender,
},
Database: dbconf,
Server: sev,
FeatureFlag: feats,
}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion infra/iac/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module "eks" {
min_size = 2
subdomains = var.cf_subdomains
batch_no = var.workshop_batch_no
capacity_type = "SPOT"
capacity_type = "ON_DEMAND"
vpc_id = module.vpc.vpc_id
igw_id = module.vpc.igw_id
nat_id = module.vpc.nat_id
Expand Down
7 changes: 7 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ test-it:
@echo "Running integration tests..."
go test -v -run "Test.*IT" -tags=integration ./...

.PHONY: test-cover
test-cover:
@echo "Running tests with coverage..."
go test -v ./... -coverprofile=coverage.out ./...
@echo "Open Html report"
go tool cover -html=coverage.out

.PHONY: test-it-docker
test-it-docker:
docker-compose -f docker-compose.it.test.yaml down && \
Expand Down

0 comments on commit e5884f8

Please sign in to comment.