diff --git a/infrastructure/create-resources/.gitignore b/infrastructure/create-resources/.gitignore new file mode 100644 index 0000000..077a987 --- /dev/null +++ b/infrastructure/create-resources/.gitignore @@ -0,0 +1,5 @@ +*.tfvars +.terraform/ +.terraform.lock.hcl +terraform.tfstate +terraform.tfstate.backup diff --git a/infrastructure/create-resources/main.tf b/infrastructure/create-resources/main.tf new file mode 100644 index 0000000..f87586a --- /dev/null +++ b/infrastructure/create-resources/main.tf @@ -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 +} diff --git a/services/entry/pkg/db/postgres/userrepo.go b/services/entry/pkg/db/postgres/userrepo.go new file mode 100644 index 0000000..0ec2485 --- /dev/null +++ b/services/entry/pkg/db/postgres/userrepo.go @@ -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 +}