Compare commits
8 Commits
feat/swagg
...
trunk
| Author | SHA1 | Date |
|---|---|---|
|
|
b55917d4eb | |
|
|
1bbbd13606 | |
|
|
5bc4939db2 | |
|
|
d2ba8cb90f | |
|
|
e00e9c27d3 | |
|
|
70d300df5e | |
|
|
389c6ed5e8 | |
|
|
fc9307e359 |
275
.drone.yml
275
.drone.yml
|
|
@ -1,41 +1,296 @@
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
type: kubernetes
|
type: kubernetes
|
||||||
name: Build Images
|
name: Build & Push Images
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
|
branch:
|
||||||
|
- trunk
|
||||||
event:
|
event:
|
||||||
- push
|
- push
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Build & Publish Catalog
|
- name: Build & Publish Catalog
|
||||||
image: plugins/kaniko
|
image: git.vdhsn.com/barretthousen/drone-kaniko:v1.0.1
|
||||||
|
volumes:
|
||||||
|
- name: cache
|
||||||
|
path: /kaniko
|
||||||
settings:
|
settings:
|
||||||
|
verbosity: debug
|
||||||
dockerfile: "./src/Dockerfile.prod-backend"
|
dockerfile: "./src/Dockerfile.prod-backend"
|
||||||
context: "./src"
|
context: "./src"
|
||||||
|
target: production
|
||||||
registry: git.vdhsn.com
|
registry: git.vdhsn.com
|
||||||
repo: git.vdhsn.com/barretthousen/service-catalog
|
repo: git.vdhsn.com/barretthousen/service-catalog
|
||||||
|
enable_cache: true
|
||||||
|
cache_repo: git.vdhsn.com/barretthousen/ci-cache
|
||||||
|
skip_unused_stages: true
|
||||||
|
build_args:
|
||||||
|
- "service=catalog"
|
||||||
|
tags:
|
||||||
|
- ${DRONE_COMMIT_SHA}
|
||||||
|
- beta
|
||||||
|
custom_labels:
|
||||||
|
- com.barretthousen.service=catalog
|
||||||
|
- com.barretthousen.version=${DRONE_COMMIT_SHA}
|
||||||
|
- com.barretthousen.git-ref=${DRONE_COMMIT_SHA}
|
||||||
|
- com.barretthousen.build-date=${DRONE_BUILD_STARTED}
|
||||||
|
- com.barrethousen.builder=${DRONE_COMMIT_AUTHOR}
|
||||||
username:
|
username:
|
||||||
from_secret: DOCKER_USERNAME
|
from_secret: DOCKER_USERNAME
|
||||||
password:
|
password:
|
||||||
from_secret: DOCKER_PASSWORD
|
from_secret: DOCKER_PASSWORD
|
||||||
args:
|
|
||||||
- "service=catalog"
|
|
||||||
no-push: true
|
|
||||||
tags:
|
|
||||||
- ${DRONE_COMMIT_SHA}
|
|
||||||
- name: Build & Publish Runner
|
- name: Build & Publish Runner
|
||||||
image: plugins/kaniko
|
image: plugins/kaniko
|
||||||
settings:
|
settings:
|
||||||
|
verbosity: debug
|
||||||
dockerfile: "./src/Dockerfile.prod-backend"
|
dockerfile: "./src/Dockerfile.prod-backend"
|
||||||
context: "./src"
|
context: "./src"
|
||||||
|
target: production
|
||||||
registry: git.vdhsn.com
|
registry: git.vdhsn.com
|
||||||
repo: git.vdhsn.com/barretthousen/service-runner
|
repo: git.vdhsn.com/barretthousen/service-runner
|
||||||
|
enable_cache: true
|
||||||
|
cache_repo: git.vdhsn.com/barretthousen/ci-cache
|
||||||
|
snapshot_mode: redo
|
||||||
|
skip_unused_stages: true
|
||||||
|
build_args:
|
||||||
|
- "service=runner"
|
||||||
|
tags:
|
||||||
|
- ${DRONE_COMMIT_SHA}
|
||||||
|
custom_labels:
|
||||||
|
- com.barretthousen.service=runner
|
||||||
|
- com.barretthousen.version=${DRONE_COMMIT_SHA}
|
||||||
|
- com.barretthousen.git-ref=${DRONE_COMMIT_SHA}
|
||||||
|
- com.barretthousen.build-date=${DRONE_BUILD_STARTED}
|
||||||
|
- com.barrethousen.builder=${DRONE_COMMIT_AUTHOR}
|
||||||
username:
|
username:
|
||||||
from_secret: DOCKER_USERNAME
|
from_secret: DOCKER_USERNAME
|
||||||
password:
|
password:
|
||||||
from_secret: DOCKER_PASSWORD
|
from_secret: DOCKER_PASSWORD
|
||||||
args:
|
|
||||||
- "service=runner"
|
- name: Build & Publish Auth
|
||||||
no-push: true
|
image: plugins/kaniko
|
||||||
|
settings:
|
||||||
|
verbosity: debug
|
||||||
|
dockerfile: "./src/Dockerfile.prod-backend"
|
||||||
|
context: "./src"
|
||||||
|
target: production
|
||||||
|
registry: git.vdhsn.com
|
||||||
|
repo: git.vdhsn.com/barretthousen/service-auth
|
||||||
|
enable_cache: true
|
||||||
|
cache_repo: git.vdhsn.com/barretthousen/ci-cache
|
||||||
|
snapshot_mode: redo
|
||||||
|
skip_unused_stages: true
|
||||||
|
build_args:
|
||||||
|
- "service=auth"
|
||||||
tags:
|
tags:
|
||||||
- ${DRONE_COMMIT_SHA}
|
- ${DRONE_COMMIT_SHA}
|
||||||
|
- beta
|
||||||
|
custom_labels:
|
||||||
|
- com.barretthousen.service=auth
|
||||||
|
- com.barretthousen.version=${DRONE_COMMIT_SHA}
|
||||||
|
- com.barretthousen.git-ref=${DRONE_COMMIT_SHA}
|
||||||
|
- com.barretthousen.build-date=${DRONE_BUILD_STARTED}
|
||||||
|
- com.barrethousen.builder=${DRONE_COMMIT_AUTHOR}
|
||||||
|
username:
|
||||||
|
from_secret: DOCKER_USERNAME
|
||||||
|
password:
|
||||||
|
from_secret: DOCKER_PASSWORD
|
||||||
|
|
||||||
|
- name: Build & Publish Proxy Admin
|
||||||
|
image: plugins/kaniko
|
||||||
|
settings:
|
||||||
|
verbosity: debug
|
||||||
|
dockerfile: "./src/Dockerfile.prod-backend"
|
||||||
|
context: "./src"
|
||||||
|
target: production
|
||||||
|
registry: git.vdhsn.com
|
||||||
|
repo: git.vdhsn.com/barretthousen/service-proxy-admin
|
||||||
|
enable_cache: true
|
||||||
|
cache_repo: git.vdhsn.com/barretthousen/ci-cache
|
||||||
|
snapshot_mode: redo
|
||||||
|
skip_unused_stages: true
|
||||||
|
build_args:
|
||||||
|
- "service=proxy-admin"
|
||||||
|
tags:
|
||||||
|
- ${DRONE_COMMIT_SHA}
|
||||||
|
- beta
|
||||||
|
custom_labels:
|
||||||
|
- com.barretthousen.service=proxy-admin
|
||||||
|
- com.barretthousen.version=${DRONE_COMMIT_SHA}
|
||||||
|
- com.barretthousen.git-ref=${DRONE_COMMIT_SHA}
|
||||||
|
- com.barretthousen.build-date=${DRONE_BUILD_STARTED}
|
||||||
|
- com.barrethousen.builder=${DRONE_COMMIT_AUTHOR}
|
||||||
|
username:
|
||||||
|
from_secret: DOCKER_USERNAME
|
||||||
|
password:
|
||||||
|
from_secret: DOCKER_PASSWORD
|
||||||
|
depends_on:
|
||||||
|
- Build & Publish Catalog
|
||||||
|
- Build & Publish Runner
|
||||||
|
- Build & Publish Auth
|
||||||
|
|
||||||
|
- name: Build & Publish Proxy Web
|
||||||
|
image: plugins/kaniko
|
||||||
|
settings:
|
||||||
|
verbosity: debug
|
||||||
|
dockerfile: "./src/Dockerfile.prod-backend"
|
||||||
|
context: "./src"
|
||||||
|
target: production
|
||||||
|
registry: git.vdhsn.com
|
||||||
|
repo: git.vdhsn.com/barretthousen/service-proxy-web
|
||||||
|
enable_cache: true
|
||||||
|
cache_repo: git.vdhsn.com/barretthousen/ci-cache
|
||||||
|
snapshot_mode: redo
|
||||||
|
skip_unused_stages: true
|
||||||
|
build_args:
|
||||||
|
- "service=proxy-web"
|
||||||
|
tags:
|
||||||
|
- ${DRONE_COMMIT_SHA}
|
||||||
|
- beta
|
||||||
|
custom_labels:
|
||||||
|
- com.barretthousen.service=proxy-web
|
||||||
|
- com.barretthousen.version=${DRONE_COMMIT_SHA}
|
||||||
|
- com.barretthousen.git-ref=${DRONE_COMMIT_SHA}
|
||||||
|
- com.barretthousen.build-date=${DRONE_BUILD_STARTED}
|
||||||
|
- com.barrethousen.builder=${DRONE_COMMIT_AUTHOR}
|
||||||
|
username:
|
||||||
|
from_secret: DOCKER_USERNAME
|
||||||
|
password:
|
||||||
|
from_secret: DOCKER_PASSWORD
|
||||||
|
depends_on:
|
||||||
|
- Build & Publish Catalog
|
||||||
|
- Build & Publish Runner
|
||||||
|
- Build & Publish Auth
|
||||||
|
|
||||||
|
- name: Build & Publish Web Client
|
||||||
|
image: plugins/kaniko
|
||||||
|
settings:
|
||||||
|
verbosity: debug
|
||||||
|
dockerfile: "./src/Dockerfile.frontend"
|
||||||
|
context: "./src/web-client"
|
||||||
|
target: production
|
||||||
|
registry: git.vdhsn.com
|
||||||
|
repo: git.vdhsn.com/barretthousen/service-proxy-web
|
||||||
|
enable_cache: true
|
||||||
|
cache_repo: git.vdhsn.com/barretthousen/ci-cache
|
||||||
|
snapshot_mode: redo
|
||||||
|
skip_unused_stages: true
|
||||||
|
build_args:
|
||||||
|
- "service=proxy-web"
|
||||||
|
tags:
|
||||||
|
- ${DRONE_COMMIT_SHA}
|
||||||
|
- beta
|
||||||
|
custom_labels:
|
||||||
|
- com.barretthousen.service=proxy-web
|
||||||
|
- com.barretthousen.version=${DRONE_COMMIT_SHA}
|
||||||
|
- com.barretthousen.git-ref=${DRONE_COMMIT_SHA}
|
||||||
|
- com.barretthousen.build-date=${DRONE_BUILD_STARTED}
|
||||||
|
- com.barrethousen.builder=${DRONE_COMMIT_AUTHOR}
|
||||||
|
username:
|
||||||
|
from_secret: DOCKER_USERNAME
|
||||||
|
password:
|
||||||
|
from_secret: DOCKER_PASSWORD
|
||||||
|
depends_on:
|
||||||
|
- Build & Publish Catalog
|
||||||
|
- Build & Publish Runner
|
||||||
|
- Build & Publish Auth
|
||||||
|
- Build & Publish Proxy Admin
|
||||||
|
- Build & Publish Proxy Web
|
||||||
|
|
||||||
|
- name: Build & Publish Admin Client
|
||||||
|
image: plugins/kaniko
|
||||||
|
settings:
|
||||||
|
verbosity: debug
|
||||||
|
dockerfile: "./src/Dockerfile.frontend"
|
||||||
|
context: "./src/admin-client"
|
||||||
|
target: production
|
||||||
|
registry: git.vdhsn.com
|
||||||
|
repo: git.vdhsn.com/barretthousen/client-admin-client
|
||||||
|
enable_cache: true
|
||||||
|
cache_repo: git.vdhsn.com/barretthousen/ci-cache
|
||||||
|
snapshot_mode: redo
|
||||||
|
skip_unused_stages: true
|
||||||
|
build_args:
|
||||||
|
- "service=admin-client"
|
||||||
|
tags:
|
||||||
|
- ${DRONE_COMMIT_SHA}
|
||||||
|
- beta
|
||||||
|
username:
|
||||||
|
from_secret: DOCKER_USERNAME
|
||||||
|
password:
|
||||||
|
from_secret: DOCKER_PASSWORD
|
||||||
|
depends_on:
|
||||||
|
- Build & Publish Catalog
|
||||||
|
- Build & Publish Runner
|
||||||
|
- Build & Publish Auth
|
||||||
|
- Build & Publish Proxy Admin
|
||||||
|
- Build & Publish Proxy Web
|
||||||
|
|
||||||
|
- name: Build Success Notify
|
||||||
|
image: appleboy/drone-discord
|
||||||
|
environment:
|
||||||
|
DISCORD_WEBHOOK_ID:
|
||||||
|
from_secret: DISCORD_WEBHOOK_ID
|
||||||
|
DISCORD_WEBHOOK_TOKEN:
|
||||||
|
from_secret: DISCORD_WEBHOOK_TOKEN
|
||||||
|
settings:
|
||||||
|
username: Drone CI
|
||||||
|
message: Barretthousen Image Builds Complete
|
||||||
|
webhook_id:
|
||||||
|
from_secret: DISCORD_WEBHOOK_ID
|
||||||
|
webhook_token:
|
||||||
|
from_secret: DISCORD_WEBHOOK_TOKEN
|
||||||
|
depends_on:
|
||||||
|
- Build & Publish Catalog
|
||||||
|
- Build & Publish Runner
|
||||||
|
- Build & Publish Auth
|
||||||
|
- Build & Publish Proxy Admin
|
||||||
|
- Build & Publish Proxy Web
|
||||||
|
- Build & Publish Web Client
|
||||||
|
- Build & Publish Admin Client
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
type: kubernetes
|
||||||
|
name: Promote Beta -> Prod
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
branch:
|
||||||
|
- trunk
|
||||||
|
event:
|
||||||
|
- promote
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Promote Services
|
||||||
|
image: alpine
|
||||||
|
environment:
|
||||||
|
REGISTRY_NAME: "https://git.vdhsn.com"
|
||||||
|
CONTENT_TYPE: "application/vnd.docker.distribution.manifest.v2+json"
|
||||||
|
DOCKER_USERNAME:
|
||||||
|
from_secret: DOCKER_USERNAME
|
||||||
|
DOCKER_PASSWORD:
|
||||||
|
from_secret: DOCKER_PASSWORD
|
||||||
|
commands:
|
||||||
|
- ./hack/promote.sh barretthousen/catalog beta prod
|
||||||
|
|
||||||
|
- name: Deploy Success
|
||||||
|
image: appleboy/drone-discord
|
||||||
|
environment:
|
||||||
|
DISCORD_WEBHOOK_ID:
|
||||||
|
from_secret: DISCORD_WEBHOOK_ID
|
||||||
|
DISCORD_WEBHOOK_TOKEN:
|
||||||
|
from_secret: DISCORD_WEBHOOK_TOKEN
|
||||||
|
settings:
|
||||||
|
username: Drone CI
|
||||||
|
message: Barretthousen Prod deployment success
|
||||||
|
webhook_id:
|
||||||
|
from_secret: DISCORD_WEBHOOK_ID
|
||||||
|
webhook_token:
|
||||||
|
from_secret: DISCORD_WEBHOOK_TOKEN
|
||||||
|
depends_on:
|
||||||
|
- Promote Services
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
- name: cache
|
||||||
|
temp:
|
||||||
|
medium: memory
|
||||||
|
|
|
||||||
25
Makefile
25
Makefile
|
|
@ -52,23 +52,19 @@ VERSION = $(shell git rev-parse --verify --short HEAD)
|
||||||
GIT_REF = $(shell git rev-parse --verify HEAD)
|
GIT_REF = $(shell git rev-parse --verify HEAD)
|
||||||
BUILD_DATE := $(shell date +%Y-%m-%d-%T)
|
BUILD_DATE := $(shell date +%Y-%m-%d-%T)
|
||||||
|
|
||||||
.PHONY: build-swagger-image
|
.PHONY: build-tools-image
|
||||||
build-swagger-image:
|
build-tools-image:
|
||||||
@docker build \
|
@docker build \
|
||||||
--label 'com.barretthousen.service=swagger' \
|
|
||||||
--label 'com.barretthousen.version=$(VERSION)' \
|
--label 'com.barretthousen.version=$(VERSION)' \
|
||||||
--label 'com.barretthousen.git-ref=$(GIT_REF)' \
|
--label 'com.barretthousen.git-ref=$(GIT_REF)' \
|
||||||
--label 'com.barretthousen.build-date=$(BUILD_DATE)' \
|
--label 'com.barretthousen.build-date=$(BUILD_DATE)' \
|
||||||
--label 'com.barrethousen.builder=$(BUILD_INITIATOR)' \
|
--label 'com.barrethousen.builder=$(BUILD_INITIATOR)' \
|
||||||
-t barretthousen/service-swagger:$(VERSION) \
|
-t git.vdhsn.com/barretthousen/tools):$(VERSION) \
|
||||||
-t git.vdhsn.com/barretthousen/service-swagger:$(VERSION) \
|
-t git.vdhsn.com/barretthousen/tools):v1 \
|
||||||
-f ./src/Dockerfile.swagger ./src
|
-f ./src/Dockerfile.tools ./src
|
||||||
|
|
||||||
@docker push git.vdhsn.com/barretthousen/service-swagger:$(VERSION)
|
|
||||||
|
|
||||||
@[ ! -z $(ENV) ] && docker tag git.vdhsn.com/barretthousen/service-swagger:$(VERSION) git.vdhsn.com/barretthousen/service-swagger:$(ENV) || true
|
|
||||||
@[ ! -z $(ENV) ] && docker push git.vdhsn.com/barretthousen/service-swagger:$(ENV) || true
|
|
||||||
|
|
||||||
|
@docker push git.vdhsn.com/barretthousen/tools:$(VERSION)
|
||||||
|
@docker push git.vdhsn.com/barretthousen/tools:v1
|
||||||
|
|
||||||
.PHONY: build-client-image
|
.PHONY: build-client-image
|
||||||
build-client-image:
|
build-client-image:
|
||||||
|
|
@ -84,7 +80,7 @@ build-client-image:
|
||||||
-f ./src/Dockerfile.frontend ./src/$(SERVICE)
|
-f ./src/Dockerfile.frontend ./src/$(SERVICE)
|
||||||
|
|
||||||
@docker push git.vdhsn.com/barretthousen/client-$(SERVICE):$(VERSION)
|
@docker push git.vdhsn.com/barretthousen/client-$(SERVICE):$(VERSION)
|
||||||
@[ ! -z $(ENV) ] && docker tag git.vdhsn.com/barretthousen/client-$(SERVICE):$(VERSION) git.vdhsn.com/barretthousen/client-$(SERVICE):beta || true
|
@[ ! -z $(ENV) ] && docker tag git.vdhsn.com/barretthousen/client-$(SERVICE):$(VERSION) git.vdhsn.com/barretthousen/client-$(SERVICE):$(ENV) || true
|
||||||
@[ ! -z $(ENV) ] && docker push git.vdhsn.com/barretthousen/client-$(SERVICE):$(ENV) || true
|
@[ ! -z $(ENV) ] && docker push git.vdhsn.com/barretthousen/client-$(SERVICE):$(ENV) || true
|
||||||
|
|
||||||
.PHONY: build-backend-image
|
.PHONY: build-backend-image
|
||||||
|
|
@ -102,8 +98,8 @@ build-backend-image:
|
||||||
|
|
||||||
@docker push git.vdhsn.com/barretthousen/service-$(SERVICE):$(VERSION)
|
@docker push git.vdhsn.com/barretthousen/service-$(SERVICE):$(VERSION)
|
||||||
|
|
||||||
@[ ! -z $(ENV) ] && docker tag git.vdhsn.com/barretthousen/service-$(SERVICE):$(VERSION) git.vdhsn.com/barretthousen/service-$(SERVICE):beta || true
|
@[ ! -z $(ENV) ] && docker tag git.vdhsn.com/barretthousen/service-$(SERVICE):$(VERSION) git.vdhsn.com/barretthousen/service-$(SERVICE):$(ENV) || true
|
||||||
@[ ! -z $(ENV) ] && docker push git.vdhsn.com/barretthousen/service-$(SERVICE):beta || true
|
@[ ! -z $(ENV) ] && docker push git.vdhsn.com/barretthousen/service-$(SERVICE):$(ENV) || true
|
||||||
|
|
||||||
# TODO: investigate tagging without needing to pull? https://dille.name/blog/2018/09/20/how-to-tag-docker-images-without-pulling-them/
|
# TODO: investigate tagging without needing to pull? https://dille.name/blog/2018/09/20/how-to-tag-docker-images-without-pulling-them/
|
||||||
.PHONY: promote-client-prod
|
.PHONY: promote-client-prod
|
||||||
|
|
@ -142,3 +138,4 @@ age_identity=$(shell sops -d ./env/master.json)
|
||||||
@echo "# public key: $(shell echo '$(age_identity)' | jq -r '.public_key')" >> $@
|
@echo "# public key: $(shell echo '$(age_identity)' | jq -r '.public_key')" >> $@
|
||||||
@echo "$(shell echo '$(age_identity)' | jq -r '.private_key')" >> $@
|
@echo "$(shell echo '$(age_identity)' | jq -r '.private_key')" >> $@
|
||||||
@echo "$@ created!"
|
@echo "$@ created!"
|
||||||
|
@echo "export SOPS_AGE_KEY_FILE=$(PWD)/env/.age.txt"
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
# [Barretthousen](https://barretthousen.com)
|
# [Barretthousen](https://barretthousen.com)
|
||||||
|
|
||||||
|
[](https://ci.vdhsn.com/Barretthousen/barretthousen)
|
||||||
Search and get alerts for items across the most popular auction sites.
|
Search and get alerts for items across the most popular auction sites.
|
||||||
|
|
||||||
Built with microservice architecture and various fancy tools for learning purposes
|
Built with microservice architecture and various fancy tools for learning purposes
|
||||||
|
|
|
||||||
50
Tiltfile
50
Tiltfile
|
|
@ -7,6 +7,7 @@ print("""
|
||||||
load('ext://helm_resource', 'helm_resource', 'helm_repo')
|
load('ext://helm_resource', 'helm_resource', 'helm_repo')
|
||||||
load('ext://deployment', 'deployment_create')
|
load('ext://deployment', 'deployment_create')
|
||||||
load('ext://restart_process', 'docker_build_with_restart')
|
load('ext://restart_process', 'docker_build_with_restart')
|
||||||
|
load('ext://uibutton', 'cmd_button', 'location', 'text_input')
|
||||||
|
|
||||||
helm_repo('bitnami', 'https://charts.bitnami.com/bitnami', labels=["9-repos"])
|
helm_repo('bitnami', 'https://charts.bitnami.com/bitnami', labels=["9-repos"])
|
||||||
helm_repo('traefik', 'https://traefik.github.io/charts', labels=["9-repos"])
|
helm_repo('traefik', 'https://traefik.github.io/charts', labels=["9-repos"])
|
||||||
|
|
@ -131,9 +132,6 @@ def bh_backend_service(service="", port_forwards=[], migrateDB=False, devMode=Tr
|
||||||
port_forwards=port_forwards,
|
port_forwards=port_forwards,
|
||||||
labels=labels,
|
labels=labels,
|
||||||
resource_deps=deps,
|
resource_deps=deps,
|
||||||
links=[
|
|
||||||
link(url='http://{}.localhost:8000'.format(service), name='Swagger'),
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -146,21 +144,6 @@ k8s_resource(
|
||||||
labels='2-services'
|
labels='2-services'
|
||||||
)
|
)
|
||||||
|
|
||||||
docker_build(
|
|
||||||
ref="barretthousen/service-swagger",
|
|
||||||
dockerfile="./src/Dockerfile.swagger",
|
|
||||||
context="./src",
|
|
||||||
only = [
|
|
||||||
'./auth/api/grpc/auth.swagger.json',
|
|
||||||
'./catalog/api/grpc/catalog.swagger.json',
|
|
||||||
'./runner/api/grpc/runner.swagger.json',
|
|
||||||
],
|
|
||||||
live_update=[
|
|
||||||
sync('./src/auth/api/grpc/auth.swagger.json', '/var/doc'),
|
|
||||||
sync('./src/catalog/api/grpc/catalog.swagger.json', '/var/doc'),
|
|
||||||
sync('./src/runner/api/grpc/runner.swagger.json', '/var/doc')
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
bh_backend_service(service="auth", migrateDB=True, port_forwards=[
|
bh_backend_service(service="auth", migrateDB=True, port_forwards=[
|
||||||
port_forward(2345, name='Delve port')
|
port_forward(2345, name='Delve port')
|
||||||
|
|
@ -184,3 +167,34 @@ bh_backend_service(service="proxy-web", port_forwards=[
|
||||||
|
|
||||||
bh_client(service='web', deps=["proxy-web-local"])
|
bh_client(service='web', deps=["proxy-web-local"])
|
||||||
bh_client(service='admin', deps=["proxy-admin-local"])
|
bh_client(service='admin', deps=["proxy-admin-local"])
|
||||||
|
|
||||||
|
createAdminCmd = [
|
||||||
|
'./hack/create_user.sh', 'admin@barretthousen.com', 'admin', 'ADMINISTRATOR'
|
||||||
|
]
|
||||||
|
|
||||||
|
loginAdminCmd = [
|
||||||
|
'curl', '-vvvv', '-X POST', '-H "Content-Type: application/json"',
|
||||||
|
'-d "{\"email\":\"admin@barretthousen.com\", \"password\":\"admin\"}"',
|
||||||
|
'http://bh.localhost:8000/api/v1/user'
|
||||||
|
]
|
||||||
|
|
||||||
|
syncCatalogsCmd = [
|
||||||
|
'curl', '-vvvv', '-X', 'PUT',
|
||||||
|
'-H', 'Content-Type: application/json',
|
||||||
|
'-H', 'bh-session-id: 2',
|
||||||
|
'-d', '{\"targetSite\":\"All\"}',
|
||||||
|
'http://admin.localhost:8000/api/v1/sync'
|
||||||
|
]
|
||||||
|
|
||||||
|
local(createAdminCmd, quiet=False, echo_off=True)
|
||||||
|
local(loginAdminCmd, quiet=False, echo_off=True)
|
||||||
|
local(syncCatalogsCmd, quiet=False, echo_off=True)
|
||||||
|
|
||||||
|
cmd_button(
|
||||||
|
name='Sync Catalogs',
|
||||||
|
argv=syncCatalogsCmd,
|
||||||
|
text='Sync Catalogs',
|
||||||
|
location=location.NAV,
|
||||||
|
icon_name='sync')
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,7 @@ helm install --upgrade bh-db bitnami/postgresql -n 'barretthousen-beta' \
|
||||||
export ENV=beta; # if not specified, will only build and push for the git commit
|
export ENV=beta; # if not specified, will only build and push for the git commit
|
||||||
make build-backend-image SERVICE=catalog
|
make build-backend-image SERVICE=catalog
|
||||||
make build-backend-image SERVICE=runner
|
make build-backend-image SERVICE=runner
|
||||||
|
make build-backend-image SERVICE=auth
|
||||||
make build-backend-image SERVICE=proxy-admin
|
make build-backend-image SERVICE=proxy-admin
|
||||||
make build-backend-image SERVICE=proxy-web
|
make build-backend-image SERVICE=proxy-web
|
||||||
|
|
||||||
|
|
@ -78,6 +79,9 @@ kubectl rollout status -n barretthousen-beta deployment runner-beta -w
|
||||||
kubectl rollout restart -n barretthousen-beta deployment catalog-beta
|
kubectl rollout restart -n barretthousen-beta deployment catalog-beta
|
||||||
kubectl rollout status -n barretthousen-beta deployment catalog-beta -w
|
kubectl rollout status -n barretthousen-beta deployment catalog-beta -w
|
||||||
|
|
||||||
|
kubectl rollout restart -n barretthousen-beta deployment auth-beta
|
||||||
|
kubectl rollout status -n barretthousen-beta deployment auth-beta -w
|
||||||
|
|
||||||
kubectl rollout restart -n barretthousen-beta deployment proxy-admin-beta
|
kubectl rollout restart -n barretthousen-beta deployment proxy-admin-beta
|
||||||
kubectl rollout status -n barretthousen-beta deployment proxy-admin-beta -w
|
kubectl rollout status -n barretthousen-beta deployment proxy-admin-beta -w
|
||||||
|
|
||||||
|
|
@ -95,6 +99,7 @@ kubectl rollout status -n barretthousen-beta deployment admin-client-beta -w
|
||||||
```sh
|
```sh
|
||||||
make promote-backend-prod SERVICE=catalog
|
make promote-backend-prod SERVICE=catalog
|
||||||
make promote-backend-prod SERVICE=runner
|
make promote-backend-prod SERVICE=runner
|
||||||
|
make promote-backend-prod SERVICE=auth
|
||||||
make promote-backend-prod SERVICE=proxy-admin
|
make promote-backend-prod SERVICE=proxy-admin
|
||||||
make promote-backend-prod SERVICE=proxy-web
|
make promote-backend-prod SERVICE=proxy-web
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ spec:
|
||||||
ports:
|
ports:
|
||||||
- port: 5001
|
- port: 5001
|
||||||
targetPort: 5001
|
targetPort: 5001
|
||||||
|
name: grpc
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Secret
|
kind: Secret
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ spec:
|
||||||
ports:
|
ports:
|
||||||
- port: 5001
|
- port: 5001
|
||||||
targetPort: 5001
|
targetPort: 5001
|
||||||
|
name: grpc
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Secret
|
kind: Secret
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ spec:
|
||||||
ports:
|
ports:
|
||||||
- port: 5001
|
- port: 5001
|
||||||
targetPort: 5001
|
targetPort: 5001
|
||||||
|
name: grpc
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Secret
|
kind: Secret
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Secret
|
||||||
|
metadata:
|
||||||
|
name: auth-config
|
||||||
|
stringData:
|
||||||
|
config.yaml: |
|
||||||
|
log_level: 2
|
||||||
|
port: 5001
|
||||||
|
db_service:
|
||||||
|
scheme: postgres
|
||||||
|
port: 5432
|
||||||
|
host: bh-db
|
||||||
|
name: bh
|
||||||
|
user: auth-service
|
||||||
|
password: auth-service
|
||||||
|
db_migrate:
|
||||||
|
scheme: postgres
|
||||||
|
port: 5432
|
||||||
|
host: bh-db
|
||||||
|
name: bh
|
||||||
|
user: postgres
|
||||||
|
password: bh-admin-beta
|
||||||
|
|
@ -7,10 +7,11 @@ namespace: barretthousen-beta
|
||||||
|
|
||||||
patchesStrategicMerge:
|
patchesStrategicMerge:
|
||||||
- sync-cronjob.yaml
|
- sync-cronjob.yaml
|
||||||
|
- auth-secret.yaml
|
||||||
- catalog-secret.yaml
|
- catalog-secret.yaml
|
||||||
|
- runner-secret.yaml
|
||||||
- proxy-admin-secret.yaml
|
- proxy-admin-secret.yaml
|
||||||
- proxy-web-secret.yaml
|
- proxy-web-secret.yaml
|
||||||
- runner-secret.yaml
|
|
||||||
|
|
||||||
patches:
|
patches:
|
||||||
- target:
|
- target:
|
||||||
|
|
@ -29,11 +30,11 @@ patches:
|
||||||
value: beta.barretthousen.com
|
value: beta.barretthousen.com
|
||||||
- target:
|
- target:
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
name: swagger
|
name: auth
|
||||||
patch: |-
|
patch: |-
|
||||||
- op: replace
|
- op: replace
|
||||||
path: /spec/template/spec/containers/0/image
|
path: /spec/template/spec/containers/0/image
|
||||||
value: git.vdhsn.com/barretthousen/service-swagger:beta
|
value: git.vdhsn.com/barretthousen/service-auth:beta
|
||||||
- target:
|
- target:
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
name: catalog
|
name: catalog
|
||||||
|
|
|
||||||
|
|
@ -8,4 +8,5 @@ stringData:
|
||||||
port: 80
|
port: 80
|
||||||
access_control_allow_origin: "beta.barretthousen.com"
|
access_control_allow_origin: "beta.barretthousen.com"
|
||||||
endpoints:
|
endpoints:
|
||||||
|
auth: auth-beta:5001
|
||||||
catalog: catalog-beta:5001
|
catalog: catalog-beta:5001
|
||||||
|
|
|
||||||
|
|
@ -6,23 +6,6 @@ spec:
|
||||||
template:
|
template:
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: swagger
|
|
||||||
image: barretthousen/service-swagger:latest
|
|
||||||
env:
|
|
||||||
- name: SWAGGER_JSON
|
|
||||||
value: /var/doc/auth.swagger.json
|
|
||||||
ports:
|
|
||||||
- containerPort: 8080
|
|
||||||
- name: auth
|
- name: auth
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 2345
|
- containerPort: 2345
|
||||||
---
|
|
||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: auth
|
|
||||||
spec:
|
|
||||||
ports:
|
|
||||||
- port: 81
|
|
||||||
targetPort: 8080
|
|
||||||
name: swagger
|
|
||||||
|
|
|
||||||
|
|
@ -6,23 +6,6 @@ spec:
|
||||||
template:
|
template:
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: swagger
|
|
||||||
image: barretthousen/service-swagger:latest
|
|
||||||
env:
|
|
||||||
- name: SWAGGER_JSON
|
|
||||||
value: /var/doc/catalog.swagger.json
|
|
||||||
ports:
|
|
||||||
- containerPort: 8080
|
|
||||||
- name: catalog
|
- name: catalog
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 2345
|
- containerPort: 2345
|
||||||
---
|
|
||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: catalog
|
|
||||||
spec:
|
|
||||||
ports:
|
|
||||||
- port: 81
|
|
||||||
targetPort: 8080
|
|
||||||
name: swagger
|
|
||||||
|
|
|
||||||
|
|
@ -6,23 +6,6 @@ spec:
|
||||||
template:
|
template:
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: swagger
|
|
||||||
image: barretthousen/service-swagger:latest
|
|
||||||
env:
|
|
||||||
- name: SWAGGER_JSON
|
|
||||||
value: /var/doc/runner.swagger.json
|
|
||||||
ports:
|
|
||||||
- containerPort: 8080
|
|
||||||
- name: runner
|
- name: runner
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 2345
|
- containerPort: 2345
|
||||||
---
|
|
||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: runner
|
|
||||||
spec:
|
|
||||||
ports:
|
|
||||||
- port: 81
|
|
||||||
targetPort: 8080
|
|
||||||
name: swagger
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@ patchesStrategicMerge:
|
||||||
- image-pull-secret.yaml
|
- image-pull-secret.yaml
|
||||||
- proxy-admin-secret.yaml
|
- proxy-admin-secret.yaml
|
||||||
- proxy-web-secret.yaml
|
- proxy-web-secret.yaml
|
||||||
- swagger.yaml
|
|
||||||
|
|
||||||
patches:
|
patches:
|
||||||
- target:
|
- target:
|
||||||
|
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
apiVersion: networking.k8s.io/v1
|
|
||||||
kind: Ingress
|
|
||||||
metadata:
|
|
||||||
name: web
|
|
||||||
spec:
|
|
||||||
rules:
|
|
||||||
- host: bh.localhost
|
|
||||||
http:
|
|
||||||
paths:
|
|
||||||
- pathType: Prefix
|
|
||||||
path: "/swagger/auth"
|
|
||||||
backend:
|
|
||||||
service:
|
|
||||||
name: auth
|
|
||||||
port:
|
|
||||||
number: 81
|
|
||||||
- pathType: Prefix
|
|
||||||
path: "/swagger/catalog"
|
|
||||||
backend:
|
|
||||||
service:
|
|
||||||
name: catalog
|
|
||||||
port:
|
|
||||||
number: 81
|
|
||||||
- pathType: Prefix
|
|
||||||
path: "/swagger/runner"
|
|
||||||
backend:
|
|
||||||
service:
|
|
||||||
name: runner
|
|
||||||
port:
|
|
||||||
number: 81
|
|
||||||
|
|
@ -8,6 +8,13 @@ patchesStrategicMerge:
|
||||||
- sync-cronjob.yaml
|
- sync-cronjob.yaml
|
||||||
|
|
||||||
patches:
|
patches:
|
||||||
|
- target:
|
||||||
|
kind: Deployment
|
||||||
|
name: auth
|
||||||
|
patch: |-
|
||||||
|
- op: replace
|
||||||
|
path: /spec/template/spec/containers/0/image
|
||||||
|
value: git.vdhsn.com/barretthousen/service-auth:prod
|
||||||
- target:
|
- target:
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
name: catalog
|
name: catalog
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,6 @@ spec:
|
||||||
[
|
[
|
||||||
"curl",
|
"curl",
|
||||||
"http://proxy-admin/api/v1/sync",
|
"http://proxy-admin/api/v1/sync",
|
||||||
'-d=''{"target":"liveauctioneers"}''',
|
'-d=''{"target":"All"}''',
|
||||||
"-vvvv",
|
"-vvvv",
|
||||||
]
|
]
|
||||||
|
|
|
||||||
4
go.work
4
go.work
|
|
@ -1,10 +1,10 @@
|
||||||
go 1.19
|
go 1.19
|
||||||
|
|
||||||
use (
|
use (
|
||||||
./src/lib
|
|
||||||
./src/auth
|
./src/auth
|
||||||
./src/catalog
|
./src/catalog
|
||||||
./src/runner
|
./src/lib
|
||||||
./src/proxy-admin
|
./src/proxy-admin
|
||||||
./src/proxy-web
|
./src/proxy-web
|
||||||
|
./src/runner
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,64 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
|
build(){
|
||||||
|
export ENV=${1:-beta}; # if not specified, will only build and push for the git commit
|
||||||
|
make build-backend-image SERVICE=auth &
|
||||||
|
make build-backend-image SERVICE=catalog &
|
||||||
|
make build-backend-image SERVICE=runner &
|
||||||
|
make build-backend-image SERVICE=proxy-admin &
|
||||||
|
make build-backend-image SERVICE=proxy-web &
|
||||||
|
time wait;
|
||||||
|
|
||||||
|
# for prod drop `beta prefix
|
||||||
|
make build-client-image SERVICE=web-client &
|
||||||
|
make build-client-image SERVICE=admin-client &
|
||||||
|
time wait;
|
||||||
|
|
||||||
|
kubectl rollout restart -n barretthousen-beta deployment runner-beta &
|
||||||
|
kubectl rollout restart -n barretthousen-beta deployment catalog-beta &
|
||||||
|
kubectl rollout restart -n barretthousen-beta deployment auth-beta &
|
||||||
|
kubectl rollout restart -n barretthousen-beta deployment proxy-admin-beta &
|
||||||
|
kubectl rollout restart -n barretthousen-beta deployment proxy-web-beta &
|
||||||
|
kubectl rollout restart -n barretthousen-beta deployment web-client-beta &
|
||||||
|
kubectl rollout restart -n barretthousen-beta deployment admin-client-beta &
|
||||||
|
|
||||||
|
kubectl rollout status -n barretthousen-beta deployment runner-beta -w
|
||||||
|
kubectl rollout status -n barretthousen-beta deployment catalog-beta -w
|
||||||
|
kubectl rollout status -n barretthousen-beta deployment auth-beta -w
|
||||||
|
kubectl rollout status -n barretthousen-beta deployment proxy-admin-beta -w
|
||||||
|
kubectl rollout status -n barretthousen-beta deployment proxy-web-beta -w
|
||||||
|
kubectl rollout status -n barretthousen-beta deployment admin-client-beta -w
|
||||||
|
kubectl rollout status -n barretthousen-beta deployment web-client-beta -w
|
||||||
|
}
|
||||||
|
|
||||||
|
promote() {
|
||||||
|
make promote-backend-prod SERVICE=catalog &
|
||||||
|
make promote-backend-prod SERVICE=runner &
|
||||||
|
make promote-backend-prod SERVICE=auth &
|
||||||
|
make promote-backend-prod SERVICE=proxy-admin &
|
||||||
|
make promote-backend-prod SERVICE=proxy-web &
|
||||||
|
|
||||||
|
make promote-client-prod SERVICE=web-client &
|
||||||
|
make promote-client-prod SERVICE=admin-client &
|
||||||
|
|
||||||
|
time wait;
|
||||||
|
|
||||||
|
kubectl rollout restart -n barretthousen deployment runner &
|
||||||
|
kubectl rollout restart -n barretthousen deployment catalog &
|
||||||
|
kubectl rollout restart -n barretthousen deployment auth &
|
||||||
|
kubectl rollout restart -n barretthousen deployment proxy-admin &
|
||||||
|
kubectl rollout restart -n barretthousen deployment proxy-web &
|
||||||
|
kubectl rollout restart -n barretthousen deployment web-client &
|
||||||
|
kubectl rollout restart -n barretthousen deployment admin-client &
|
||||||
|
|
||||||
|
kubectl rollout status -n barretthousen deployment runner -w
|
||||||
|
kubectl rollout status -n barretthousen deployment catalog -w
|
||||||
|
kubectl rollout status -n barretthousen deployment auth -w
|
||||||
|
kubectl rollout status -n barretthousen deployment proxy-admin -w
|
||||||
|
kubectl rollout status -n barretthousen deployment proxy-web -w
|
||||||
|
kubectl rollout status -n barretthousen deployment admin-client -w
|
||||||
|
kubectl rollout status -n barretthousen deployment web-client -w
|
||||||
|
}
|
||||||
|
|
||||||
|
build $@
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
|
main(){
|
||||||
|
local EMAIL=${1};
|
||||||
|
if [ -z "${EMAIL}" ]; then
|
||||||
|
echo "first argument must be an EMAIL address"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
local PASSWORD=${2};
|
||||||
|
if [ -z "${PASSWORD}" ]; then
|
||||||
|
echo "second argument must be a PASSWORD"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
local ROLE=${3:-USER};
|
||||||
|
local HOST=${4:-"http://bh.localhost:8000"};
|
||||||
|
|
||||||
|
curl -X PUT -H 'Content-Type: application/json' \
|
||||||
|
-d "{ \"email\":\"${EMAIL}\", \"password\":\"${PASSWORD}\", \"role\":\"${ROLE}\" }" \
|
||||||
|
"${HOST}/api/v1/user";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
main $@;
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
docker run --rm \
|
||||||
|
-e DRONE_COMMIT_REF=refs/heads/trunk \
|
||||||
|
-e DRONE_REPO_BRANCH=trunk \
|
||||||
|
-e PLUGIN_REGISTRY=git.vdhsn.com \
|
||||||
|
-e PLUGIN_REPO=git.vdhsn.com/barretthousen/service-catalog \
|
||||||
|
-e PLUGIN_BUILD_ARGS="service=catalog" \
|
||||||
|
-e PLUGIN_TAGS=$(git rev-parse --verify --short HEAD) \
|
||||||
|
-e PLUGIN_CONTEXT="./src" \
|
||||||
|
-e PLUGIN_DOCKERFILE="./src/Dockerfile.prod-backend" \
|
||||||
|
-e PLUGIN_USERNAME=${DOCKER_USERNAME} \
|
||||||
|
-e PLUGIN_PASSWORD=${DOCKER_PASSWORD} \
|
||||||
|
-e PLUGIN_ENABLE_CACHE=true \
|
||||||
|
-e PLUGIN_CACHE_REPO='git.vdhsn.com/barretthousen/ci-cache' \
|
||||||
|
-e PLUGIN_SKIP_UNUSED_STAGES=true \
|
||||||
|
-v $(pwd):/drone \
|
||||||
|
-w /drone \
|
||||||
|
plugins/kaniko:linux-amd64
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
|
||||||
|
main(){
|
||||||
|
local REPOSITORY=${1};
|
||||||
|
if [ -z "${REPOSITORY}" ]; then
|
||||||
|
echo "First argument must be container repository";
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
local FROM=${2:-beta};
|
||||||
|
local TO=${3:-prod};
|
||||||
|
|
||||||
|
local CONTENT_TYPE="application/vnd.docker.distribution.manifest.v2+json";
|
||||||
|
local REGISTRY_URL="https://git.vdhsn.com/v2/${REPOSITORY}/manifests";
|
||||||
|
|
||||||
|
export MANIFEST=$(curl -u "${DOCKER_USERNAME}:${DOCKER_PASSWORD}" \
|
||||||
|
-H "Accept: ${CONTENT_TYPE}" "${REGISTRY_URL}/${FROM}");
|
||||||
|
|
||||||
|
|
||||||
|
curl -u "${DOCKER_USERNAME}:${DOCKER_PASSWORD}" \
|
||||||
|
-X PUT -H "Content-Type: ${CONTENT_TYPE}" -d "${MANIFEST}" "${REGISTRY_URL}/${TO}";
|
||||||
|
|
||||||
|
echo "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -1 +1,4 @@
|
||||||
.idea
|
.idea
|
||||||
|
web-client/*
|
||||||
|
admin-client/*
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,11 @@
|
||||||
FROM golang:1.19 as prod-builder
|
FROM git.vdhsn.com/barretthousen/tools:v1 as prod-builder
|
||||||
|
|
||||||
RUN go install github.com/bufbuild/buf/cmd/buf@v1.17.0
|
|
||||||
RUN go install github.com/kyleconroy/sqlc/cmd/sqlc@latest
|
|
||||||
|
|
||||||
COPY . /go/src
|
|
||||||
|
|
||||||
WORKDIR /go/src/
|
WORKDIR /go/src/
|
||||||
|
|
||||||
RUN /go/bin/sqlc generate -f /go/src/sqlc.yaml
|
COPY . /go/src/
|
||||||
RUN /go/bin/buf mod update /go/src && /go/bin/buf generate
|
|
||||||
|
RUN /go/bin/sqlc generate -f /go/src/sqlc.yaml \
|
||||||
|
&& /go/bin/buf mod update /go/src && /go/bin/buf generate
|
||||||
|
|
||||||
ARG service
|
ARG service
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
FROM swaggerapi/swagger-ui
|
|
||||||
|
|
||||||
COPY ./auth/api/grpc/auth.swagger.json /var/doc/
|
|
||||||
COPY ./catalog/api/grpc/catalog.swagger.json /var/doc/
|
|
||||||
COPY ./runner/api/grpc/runner.swagger.json /var/doc
|
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
FROM golang:1.19
|
||||||
|
|
||||||
|
RUN go install github.com/bufbuild/buf/cmd/buf@v1.17.0
|
||||||
|
RUN go install github.com/kyleconroy/sqlc/cmd/sqlc@latest
|
||||||
|
|
@ -6,7 +6,6 @@ require (
|
||||||
git.vdhsn.com/barretthousen/barretthousen/src/lib v1.0.0
|
git.vdhsn.com/barretthousen/barretthousen/src/lib v1.0.0
|
||||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2
|
||||||
go.uber.org/dig v1.16.1
|
go.uber.org/dig v1.16.1
|
||||||
golang.org/x/sync v0.2.0
|
|
||||||
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1
|
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1
|
||||||
google.golang.org/protobuf v1.30.0
|
google.golang.org/protobuf v1.30.0
|
||||||
)
|
)
|
||||||
|
|
@ -19,6 +18,7 @@ require (
|
||||||
github.com/joho/godotenv v1.5.1 // indirect
|
github.com/joho/godotenv v1.5.1 // indirect
|
||||||
github.com/pressly/goose/v3 v3.11.0 // indirect
|
github.com/pressly/goose/v3 v3.11.0 // indirect
|
||||||
golang.org/x/net v0.9.0 // indirect
|
golang.org/x/net v0.9.0 // indirect
|
||||||
|
golang.org/x/sync v0.2.0 // indirect
|
||||||
golang.org/x/sys v0.8.0 // indirect
|
golang.org/x/sys v0.8.0 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
olympos.io/encoding/edn v0.0.0-20201019073823-d3554ca0b0a3 // indirect
|
olympos.io/encoding/edn v0.0.0-20201019073823-d3554ca0b0a3 // indirect
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ require (
|
||||||
github.com/joho/godotenv v1.5.1 // indirect
|
github.com/joho/godotenv v1.5.1 // indirect
|
||||||
github.com/pressly/goose/v3 v3.11.0 // indirect
|
github.com/pressly/goose/v3 v3.11.0 // indirect
|
||||||
golang.org/x/net v0.9.0 // indirect
|
golang.org/x/net v0.9.0 // indirect
|
||||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect
|
golang.org/x/sync v0.2.0 // indirect
|
||||||
golang.org/x/sys v0.8.0 // indirect
|
golang.org/x/sys v0.8.0 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
olympos.io/encoding/edn v0.0.0-20201019073823-d3554ca0b0a3 // indirect
|
olympos.io/encoding/edn v0.0.0-20201019073823-d3554ca0b0a3 // indirect
|
||||||
|
|
|
||||||
|
|
@ -180,8 +180,8 @@ golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||||
golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM=
|
golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM=
|
||||||
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
|
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw=
|
|
||||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI=
|
||||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ go 1.19
|
||||||
require (
|
require (
|
||||||
github.com/jackc/pgx/v4 v4.18.1
|
github.com/jackc/pgx/v4 v4.18.1
|
||||||
go.uber.org/automaxprocs v1.5.2
|
go.uber.org/automaxprocs v1.5.2
|
||||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4
|
golang.org/x/sync v0.2.0
|
||||||
google.golang.org/grpc v1.55.0
|
google.golang.org/grpc v1.55.0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -175,8 +175,8 @@ golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||||
golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM=
|
golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM=
|
||||||
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
|
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw=
|
|
||||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI=
|
||||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,11 @@ module git.vdhsn.com/barretthousen/barretthousen/src/proxy-admin
|
||||||
go 1.19
|
go 1.19
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
git.vdhsn.com/barretthousen/barretthousen/src/auth v1.0.0
|
||||||
git.vdhsn.com/barretthousen/barretthousen/src/lib v1.0.0
|
git.vdhsn.com/barretthousen/barretthousen/src/lib v1.0.0
|
||||||
git.vdhsn.com/barretthousen/barretthousen/src/runner v1.0.0
|
git.vdhsn.com/barretthousen/barretthousen/src/runner v1.0.0
|
||||||
git.vdhsn.com/barretthousen/barretthousen/src/auth v1.0.0
|
|
||||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2
|
||||||
|
go.uber.org/dig v1.16.1
|
||||||
google.golang.org/grpc v1.55.0
|
google.golang.org/grpc v1.55.0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -143,6 +143,7 @@ go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
|
||||||
go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
|
go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
|
||||||
go.uber.org/automaxprocs v1.5.2 h1:2LxUOGiR3O6tw8ui5sZa2LAaHnsviZdVOUZw4fvbnME=
|
go.uber.org/automaxprocs v1.5.2 h1:2LxUOGiR3O6tw8ui5sZa2LAaHnsviZdVOUZw4fvbnME=
|
||||||
go.uber.org/automaxprocs v1.5.2/go.mod h1:eRbA25aqJrxAbsLO0xy5jVwPt7FQnRgjW+efnwa1WM0=
|
go.uber.org/automaxprocs v1.5.2/go.mod h1:eRbA25aqJrxAbsLO0xy5jVwPt7FQnRgjW+efnwa1WM0=
|
||||||
|
go.uber.org/dig v1.16.1 h1:+alNIBsl0qfY0j6epRubp/9obgtrObRAc5aD+6jbWY8=
|
||||||
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
||||||
go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4=
|
go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4=
|
||||||
go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU=
|
go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU=
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ require (
|
||||||
go.uber.org/automaxprocs v1.5.2 // indirect
|
go.uber.org/automaxprocs v1.5.2 // indirect
|
||||||
golang.org/x/crypto v0.8.0 // indirect
|
golang.org/x/crypto v0.8.0 // indirect
|
||||||
golang.org/x/net v0.9.0 // indirect
|
golang.org/x/net v0.9.0 // indirect
|
||||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect
|
golang.org/x/sync v0.2.0 // indirect
|
||||||
golang.org/x/sys v0.8.0 // indirect
|
golang.org/x/sys v0.8.0 // indirect
|
||||||
golang.org/x/text v0.9.0 // indirect
|
golang.org/x/text v0.9.0 // indirect
|
||||||
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
|
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
|
||||||
|
|
@ -39,3 +39,5 @@ require (
|
||||||
replace git.vdhsn.com/barretthousen/barretthousen/src/lib v1.0.0 => ../lib
|
replace git.vdhsn.com/barretthousen/barretthousen/src/lib v1.0.0 => ../lib
|
||||||
|
|
||||||
replace git.vdhsn.com/barretthousen/barretthousen/src/catalog v1.0.0 => ../catalog
|
replace git.vdhsn.com/barretthousen/barretthousen/src/catalog v1.0.0 => ../catalog
|
||||||
|
|
||||||
|
replace git.vdhsn.com/barretthousen/barretthousen/src/auth v1.0.0 => ../auth
|
||||||
|
|
|
||||||
|
|
@ -178,8 +178,8 @@ golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||||
golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM=
|
golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM=
|
||||||
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
|
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw=
|
|
||||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI=
|
||||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,158 @@
|
||||||
|
package catawiki
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
catalog "git.vdhsn.com/barretthousen/barretthousen/src/catalog/api"
|
||||||
|
"git.vdhsn.com/barretthousen/barretthousen/src/lib/kernel"
|
||||||
|
"git.vdhsn.com/barretthousen/barretthousen/src/runner/internal/domain"
|
||||||
|
"golang.org/x/sync/errgroup"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
kernel.TraceLog.Println("Registering AuctionFinder catawiki")
|
||||||
|
domain.RegisterAuctionFinder(
|
||||||
|
CatawikiAuctionFinder("catawiki"),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
type CatawikiAuctionFinder string
|
||||||
|
|
||||||
|
func (cw CatawikiAuctionFinder) String() string {
|
||||||
|
return string(cw)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cw CatawikiAuctionFinder) Find(ctx context.Context, limit int, results chan<- catalog.Auction) (err error) {
|
||||||
|
defer close(results)
|
||||||
|
|
||||||
|
pageSize := 50
|
||||||
|
|
||||||
|
if limit > 2500 {
|
||||||
|
limit = 2500
|
||||||
|
}
|
||||||
|
|
||||||
|
if limit <= 0 {
|
||||||
|
limit = 2500
|
||||||
|
}
|
||||||
|
|
||||||
|
errg, errgCtx := errgroup.WithContext(ctx)
|
||||||
|
errg.SetLimit(5)
|
||||||
|
|
||||||
|
kernel.TraceLog.Printf("[Catawiki] fetching %d pages or up to %d results in %d batches", limit/pageSize, limit, pageSize)
|
||||||
|
for p := 1; p <= limit/pageSize; p++ {
|
||||||
|
pageIdx := p
|
||||||
|
errg.Go(func() error {
|
||||||
|
auctionR, err := GetUpcomingAuctions(errgCtx, limit, pageIdx)
|
||||||
|
if errors.Is(err, ErrNoResults) {
|
||||||
|
kernel.TraceLog.Println("no more results from catawiki api")
|
||||||
|
return err
|
||||||
|
} else if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, r := range auctionR {
|
||||||
|
select {
|
||||||
|
case <-errgCtx.Done():
|
||||||
|
kernel.TraceLog.Println("[Catawiki] group context exited early")
|
||||||
|
return nil
|
||||||
|
default:
|
||||||
|
results <- r
|
||||||
|
kernel.TraceLog.Printf("[Catawiki]: %+v", r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = errg.Wait(); err != nil {
|
||||||
|
kernel.ErrorLog.Printf("[Catawiki] could not get results f: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var ErrNoResults = errors.New("No results found")
|
||||||
|
|
||||||
|
func GetUpcomingAuctions(ctx context.Context, limit int, page int) (results []catalog.Auction, err error) {
|
||||||
|
if limit <= 25 {
|
||||||
|
limit = 25
|
||||||
|
} else if limit >= 50 {
|
||||||
|
limit = 50
|
||||||
|
}
|
||||||
|
|
||||||
|
if page < 1 {
|
||||||
|
page = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
url := fmt.Sprintf("https://www.catawiki.com/buyer/api/v1/auctions?locale=en&=published_at_desc&per_page=%d&page=%d", limit, page)
|
||||||
|
|
||||||
|
req, _ := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
|
||||||
|
|
||||||
|
req.Header.Add("Accept", "application/json")
|
||||||
|
req.Header.Add("Accept-Language", "en-US,en;q=0.5")
|
||||||
|
req.Header.Add("User-Agent", "barretthousen.com Auction Search Engine")
|
||||||
|
|
||||||
|
kernel.TraceLog.Printf("[Catawiki] Loading page %d of %d results", page, limit)
|
||||||
|
var res *http.Response
|
||||||
|
if res, err = http.DefaultClient.Do(req); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
defer res.Body.Close()
|
||||||
|
|
||||||
|
if res.StatusCode != http.StatusOK {
|
||||||
|
err = fmt.Errorf("bad response code: %d", res.StatusCode)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
type Payload struct {
|
||||||
|
Auctions []struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
StartAt string `json:"start_at"`
|
||||||
|
CloseAt string `json:"close_at"`
|
||||||
|
LotCount int `json:"lot_count"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
URL string `json:"url"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
Sellers []struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
} `json:"sellers"`
|
||||||
|
} `json:"auctions"`
|
||||||
|
}
|
||||||
|
|
||||||
|
var p Payload
|
||||||
|
if err = json.NewDecoder(res.Body).Decode(&p); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(p.Auctions) <= 0 {
|
||||||
|
err = ErrNoResults
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
results = make([]catalog.Auction, len(p.Auctions))
|
||||||
|
for idx, auction := range p.Auctions {
|
||||||
|
results[idx] = catalog.Auction{
|
||||||
|
Title: auction.Title,
|
||||||
|
Description: "",
|
||||||
|
SourceSiteURL: "https://www.catawiki.com",
|
||||||
|
SourceSiteName: "CataWiki",
|
||||||
|
SourceURL: auction.URL,
|
||||||
|
Country: "",
|
||||||
|
Province: "",
|
||||||
|
ItemCount: auction.LotCount,
|
||||||
|
}
|
||||||
|
|
||||||
|
results[idx].Start, _ = time.Parse(time.RFC3339, auction.StartAt)
|
||||||
|
results[idx].End, _ = time.Parse(time.RFC3339, auction.CloseAt)
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
package catawiki
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"reflect"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
catalog "git.vdhsn.com/barretthousen/barretthousen/src/catalog/api"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestGetUpcomingAuctions(t *testing.T) {
|
||||||
|
type args struct {
|
||||||
|
limit int
|
||||||
|
page int
|
||||||
|
}
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
args args
|
||||||
|
wantResults []catalog.Auction
|
||||||
|
wantErr bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "1 Page, 25 Results",
|
||||||
|
args: args{
|
||||||
|
limit: 25,
|
||||||
|
page: 1,
|
||||||
|
},
|
||||||
|
wantResults: make([]catalog.Auction, 25),
|
||||||
|
wantErr: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
gotResults, err := GetUpcomingAuctions(context.TODO(), tt.args.limit, tt.args.page)
|
||||||
|
if (err != nil) != tt.wantErr {
|
||||||
|
t.Errorf("GetUpcomingAuctions() error = %v, wantErr %v", err, tt.wantErr)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(gotResults, tt.wantResults) {
|
||||||
|
t.Errorf("GetUpcomingAuctions() = %v, want %v", gotResults, tt.wantResults)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2,6 +2,7 @@ package domain
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -60,17 +61,32 @@ type (
|
||||||
func (domain Domain) StartSync(ctx context.Context, in FindNewUpcomingInput) (out FindNewUpcomingOutput, err error) {
|
func (domain Domain) StartSync(ctx context.Context, in FindNewUpcomingInput) (out FindNewUpcomingOutput, err error) {
|
||||||
kernel.TraceLog.Printf("%+v", in)
|
kernel.TraceLog.Printf("%+v", in)
|
||||||
|
|
||||||
finder := targetsImpls["liveauctioneers"]
|
if in.TargetSite == "All" || in.TargetSite == "" {
|
||||||
|
for k, v := range targetsImpls {
|
||||||
|
|
||||||
|
if out.Job, err = domain.Storage.CreateScrapeJob(ctx, k); err != nil {
|
||||||
|
err = fmt.Errorf("could not create new scrape job record: %w", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
kernel.InfoLog.Printf("Scrape Job %d starting", out.Job.ID)
|
||||||
|
|
||||||
|
go domain.executeScrapeJob(v, out.Job.ID)
|
||||||
|
}
|
||||||
|
} else if finder, ok := targetsImpls[in.TargetSite]; ok {
|
||||||
if out.Job, err = domain.Storage.CreateScrapeJob(ctx, in.TargetSite); err != nil {
|
if out.Job, err = domain.Storage.CreateScrapeJob(ctx, in.TargetSite); err != nil {
|
||||||
err = fmt.Errorf("could not create new scrape job record: %w", err)
|
err = fmt.Errorf("could not create new scrape job record: %w", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
kernel.InfoLog.Printf("Scrape Job %d starting", out.Job.ID)
|
kernel.InfoLog.Printf("Scrape Job %d starting", out.Job.ID)
|
||||||
|
|
||||||
// TODO: make everything after this line async and run after return
|
|
||||||
go domain.executeScrapeJob(finder, out.Job.ID)
|
go domain.executeScrapeJob(finder, out.Job.ID)
|
||||||
|
} else {
|
||||||
|
kernel.TraceLog.Println("could not find target")
|
||||||
|
err = errors.New("No scrape job found by name")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -116,13 +132,13 @@ func (domain *Domain) executeScrapeJob(finder UpcomingAuctionFinder, jobID int)
|
||||||
errs := &strings.Builder{}
|
errs := &strings.Builder{}
|
||||||
for auction := range found {
|
for auction := range found {
|
||||||
total++
|
total++
|
||||||
if !auction.Start.After(time.Now()) {
|
if !auction.Start.After(time.Now().Add(-24 * time.Hour)) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
ace, err := domain.CatalogService.UpdateUpcomingAuction(ctx, auction)
|
ace, err := domain.CatalogService.UpdateUpcomingAuction(ctx, auction)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
kernel.TraceLog.Printf("could not import upcoming auction: %s", err.Error())
|
kernel.ErrorLog.Printf("[%s] could not import upcoming auction: %s", finder.String(), err.Error())
|
||||||
fmt.Fprintf(errs, "{ \"AuctionFingerprint\": \"%s\", \"error\": \"%s\" }\n", ace.Fingerprint, err.Error())
|
fmt.Fprintf(errs, "{ \"AuctionFingerprint\": \"%s\", \"error\": \"%s\" }\n", ace.Fingerprint, err.Error())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
@ -132,6 +148,7 @@ func (domain *Domain) executeScrapeJob(finder UpcomingAuctionFinder, jobID int)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
kernel.TraceLog.Printf("[%s] waiting for results...", finder.String())
|
||||||
if err := errGroup.Wait(); err != nil {
|
if err := errGroup.Wait(); err != nil {
|
||||||
err = fmt.Errorf("an issue occurred while finding upcoming items iteration: %w", err)
|
err = fmt.Errorf("an issue occurred while finding upcoming items iteration: %w", err)
|
||||||
fmt.Fprintf(errs, "{\"error\": \"%s\" }", err.Error())
|
fmt.Fprintf(errs, "{\"error\": \"%s\" }", err.Error())
|
||||||
|
|
@ -143,9 +160,9 @@ func (domain *Domain) executeScrapeJob(finder UpcomingAuctionFinder, jobID int)
|
||||||
AuctionCount: count,
|
AuctionCount: count,
|
||||||
Errors: errs.String(),
|
Errors: errs.String(),
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
kernel.ErrorLog.Printf("Could not complete scrape job, failing: %v", err)
|
kernel.ErrorLog.Printf("[%s] Could not complete scrape job, failing: %v", finder.String(), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
kernel.InfoLog.Printf("Scrape Job %d completed in %v. Successfully imported %d/%d", jobID, completedJob.Completed.Sub(completedJob.Started), count, total)
|
kernel.InfoLog.Printf("[%s] Scrape Job %d completed in %v. Successfully imported %d/%d", finder.String(), jobID, completedJob.Completed.Sub(completedJob.Started), count, total)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ import (
|
||||||
"go.uber.org/dig"
|
"go.uber.org/dig"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
|
|
||||||
|
_ "git.vdhsn.com/barretthousen/barretthousen/src/runner/internal/domain/catawiki"
|
||||||
_ "git.vdhsn.com/barretthousen/barretthousen/src/runner/internal/domain/liveauctioneers"
|
_ "git.vdhsn.com/barretthousen/barretthousen/src/runner/internal/domain/liveauctioneers"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,10 +39,10 @@
|
||||||
},
|
},
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"analytics": "^0.8.9",
|
|
||||||
"analytics-plugin-do-not-track": "^0.1.5",
|
|
||||||
"@analytics/google-analytics": "^1.0.7",
|
"@analytics/google-analytics": "^1.0.7",
|
||||||
"@segment/snippet": "^4.16.2",
|
"@segment/snippet": "^4.16.2",
|
||||||
|
"analytics": "^0.8.9",
|
||||||
|
"analytics-plugin-do-not-track": "^0.1.5",
|
||||||
"luxon": "^3.3.0"
|
"luxon": "^3.3.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,16 +4,16 @@
|
||||||
|
|
||||||
import Analytics from 'analytics';
|
import Analytics from 'analytics';
|
||||||
// import doNotTrack from 'analytics-plugin-do-not-track';
|
// import doNotTrack from 'analytics-plugin-do-not-track';
|
||||||
import googleAnalytics from '@analytics/google-analytics';
|
// import googleAnalytics from '@analytics/google-analytics';
|
||||||
|
|
||||||
const analytics = Analytics({
|
const analytics = Analytics({
|
||||||
app: 'Barretthousen - Web Client',
|
app: 'Barretthousen - Web Client',
|
||||||
version: '1.0',
|
version: '1.0',
|
||||||
debug: process.env.NODE_ENV !== 'production',
|
debug: process.env.NODE_ENV !== 'production',
|
||||||
plugins: [
|
plugins: [
|
||||||
googleAnalytics({
|
// googleAnalytics({
|
||||||
measurementIds: ['UA-143763293-1']
|
// measurementIds: ['UA-143763293-1']
|
||||||
})
|
// })
|
||||||
// doNotTrack()
|
// doNotTrack()
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue