Add infrastructure
This commit is contained in:
parent
f5fee55905
commit
919705c114
5
infrastructure/create-resources/.gitignore
vendored
Normal file
5
infrastructure/create-resources/.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
*.tfvars
|
||||
.terraform/
|
||||
.terraform.lock.hcl
|
||||
terraform.tfstate
|
||||
terraform.tfstate.backup
|
43
infrastructure/create-resources/main.tf
Normal file
43
infrastructure/create-resources/main.tf
Normal file
@ -0,0 +1,43 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
hcloud = {
|
||||
source = "hetznercloud/hcloud"
|
||||
version = "1.32.2"
|
||||
}
|
||||
}
|
||||
|
||||
backend "s3" {
|
||||
bucket = "serverctl-terraform"
|
||||
key = "terraform.tfstate"
|
||||
|
||||
endpoint = "https://api.minio.front.kjuulh.io"
|
||||
|
||||
region = "main"
|
||||
|
||||
skip_credentials_validation = true
|
||||
skip_metadata_api_check = true
|
||||
skip_region_validation = true
|
||||
force_path_style = true
|
||||
}
|
||||
}
|
||||
|
||||
variable "hcloud_token" {
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
provider "hcloud" {
|
||||
token = var.hcloud_token
|
||||
}
|
||||
|
||||
resource "hcloud_placement_group" "serverctl_master" {
|
||||
name = "serverctl_master_group"
|
||||
type = "spread"
|
||||
}
|
||||
|
||||
resource "hcloud_server" "serverctl_master" {
|
||||
count = 2
|
||||
name = "serverctl-master-${count.index}"
|
||||
image = "debian-11"
|
||||
server_type = "cx11"
|
||||
placement_group_id = hcloud_placement_group.serverctl_master.id
|
||||
}
|
28
services/entry/pkg/db/postgres/userrepo.go
Normal file
28
services/entry/pkg/db/postgres/userrepo.go
Normal file
@ -0,0 +1,28 @@
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
)
|
||||
|
||||
type UserDto struct {
|
||||
}
|
||||
|
||||
type InMemoryUserRepository struct {
|
||||
users map[int]*UserDto
|
||||
}
|
||||
|
||||
func NewInMemoryUserRepository() *InMemoryUserRepository {
|
||||
return &InMemoryUserRepository{
|
||||
users: make(map[int]*UserDto),
|
||||
}
|
||||
}
|
||||
|
||||
func (ur *InMemoryUserRepository) Get(ctx context.Context, id int) (*UserDto, error) {
|
||||
user := ur.users[id]
|
||||
if user == nil {
|
||||
return nil, errors.New("user is not in database")
|
||||
}
|
||||
|
||||
return user, nil
|
||||
}
|
Loading…
Reference in New Issue
Block a user