Add infrastructure

This commit is contained in:
Kasper Juul Hermansen 2022-02-17 21:39:56 +01:00
parent f5fee55905
commit 919705c114
Signed by: kjuulh
GPG Key ID: 0F95C140730F2F23
3 changed files with 76 additions and 0 deletions

View File

@ -0,0 +1,5 @@
*.tfvars
.terraform/
.terraform.lock.hcl
terraform.tfstate
terraform.tfstate.backup

View 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
}

View 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
}