cohabitaters

package module
v0.0.0-...-52de14c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2023 License: MIT Imports: 6 Imported by: 0

README

cohabitaters

A little web app to generate a Christmas card address list from Google Contacts.

I like to store my data centrally but Google doesn't make it easy to aggregate contacts by where they live. I don't want to send multiple cards to the same address.

Architecture

Cohabitaters uses several platforms and libraries. On the front-end:

and on the the back-end:

Deployment uses a healthy mix of Google Domains, GCP, and fly.io.

Development

Standards

The Go code in this project should adhere to Google's Go Style Guide and CodeReviewComments.

Local Dev

Operations are driven from the top-level Makefile:

❯ make -C deploy local-cookie-store-key.txt
openssl rand -base64 96 >local-cookie-store-key.txt
❯ make bin/cohab-server
cd cmd/cohab-server && go build -o ../../bin/cohab-server
❯ make air

  __    _   ___
 / /\  | | | |_)
/_/--\ |_| |_| \_ , built with Go

watching .
!exclude air-tmp
watching bin
watching cmd
watching cmd/cohab-server
watching cmd/cohabcli
watching deploy
watching html
watching html/fontawesome-free-6.2.1-web
watching html/fontawesome-free-6.2.1-web/css
watching html/fontawesome-free-6.2.1-web/webfonts
watching html/templates
watching html/templates/partials
watching mapcache
!exclude terraform
building...
make[1]: Entering directory '/home/bfallik/sandbox/cohabitaters'
cd cmd/cohab-server && go build -o ../../bin/cohab-server
make[1]: Leaving directory '/home/bfallik/sandbox/cohabitaters'
running...
^Ccleaning...
see you again~

Dockerfile.fedora contains a verifiable script to prove the build dependencies for make check.

❯ make image-fedora-test-build
podman build -f Dockerfile.fedora -t fedora-test-build .
STEP 1/6: FROM fedora:37 AS builder
STEP 2/6: WORKDIR /build
...

Deployment

This tool requires a GCP Project for access to the People API. For simplicity, that configuration is tracked in Terraform.

Initial Import
$ cd terraform && terraform import google_project_service.people_api xmas-card-addresses/people.googleapis.com
Deploy Locally

make air will build and launch the web server and repeat when any source files have changed. By default the server will listen on localhost:8080.

Deploy locally with Podman

Use cohab-server-dev-podman.sh:

  ❯ ./deploy/cohab-server-dev-podman.sh

Deploy remotely

The final version gets deployed to fly.io.

Prerequisite 1: create the DNS record and then the certificate:

❯ flyctl certs create cohabitaters.bfallik.net

Prerequisite 2: create the applications secret from the downloaded OAuth2 client credentials:

❯ flyctl secrets set GOOGLE_APP_CREDENTIALS="$(< path/to/downloaded/client_secret.json)"

To have fly.io build and deploy the image:

❯ flyctl deploy

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyGroup = errors.New("group is empty")
)

Functions

func BuildInfo

func BuildInfo() string

func FuzzyAddressMatch

func FuzzyAddressMatch(a *people.Address, b Address) bool

func FuzzyTrimMatch

func FuzzyTrimMatch(a, b string) bool

func PickHomeAddress

func PickHomeAddress(in []*people.Address) (*people.Address, error)

Types

type Address

type Address struct {
	StreetAddress  string
	StreetAddress2 string
	City           string
	Region         string
	Country        string
	PostalCode     string
}

func NewAddress

func NewAddress(in *people.Address) Address

type XmasCard

type XmasCard struct {
	Names   []string
	Address Address
}

func GetXmasCards

func GetXmasCards(svc *people.Service, contactGroupResourceName string) ([]XmasCard, error)

Directories

Path Synopsis
cmd
templs
templ: version: 0.2.432
templ: version: 0.2.432

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL