Skip to content

Commit 76c6e35

Browse files
authored
Centralize db and partial openapi models packages in a single models package (#317)
* fix bad array element removal * Project to ProjectName to prevent clash * suffix for clashing rest and db models * update gen * update oapi-codegen * gen test client server * update gen - pending Db rename to Models everywhere * can generate * fixed gen and tests - pending old models removal * try update crud gen * update test client gen * rest test client with rest types bodies for simpler tests * bring back rest models for crud gen * migration ci * check no type grouping in models.go * suffix magic file rest models * refactor client-server gen * refactor * schema name guards * faster camel and pascal and fix spec parameter helper gen * run go generate separately - current noop * lint sql dirs concurrently * memoized to_pascal * fix crud gen * update forms * discriminated ui form * typed discriminated form default values * intercept id types in schema arrays * dont use deprecated swaggest interceptor * linter update * cache gen db migrations * refactor * update gen * clean old models
1 parent 7167ced commit 76c6e35

File tree

515 files changed

+13466
-14412
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

515 files changed

+13466
-14412
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Lint Migrations
2+
3+
# on: pull_request
4+
5+
jobs:
6+
lint_migrations:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v1
10+
- name: Find modified migrations
11+
run: |
12+
modified_migrations=$(git diff --name-only origin/$GITHUB_BASE_REF...origin/$GITHUB_HEAD_REF 'db/migrations/*.sql')
13+
echo "$modified_migrations"
14+
echo "::set-output name=file_names::$modified_migrations"
15+
id: modified-migrations
16+
- uses: sbdchd/squawk-action@v1
17+
with:
18+
pattern: ${{ steps.modified-migrations.outputs.file_names }}

.golangci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ run:
77
linters:
88
enable-all: true
99
disable:
10+
- dupword
1011
- ireturn # oapi-codegen strict handlers
1112
# - interfacebloat
1213
- thelper

Dockerfile.oidc-server

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM golang:1.21-alpine3.18 AS build
33
WORKDIR /go/src
44
COPY ./vendor/ ./vendor/
55
COPY ./cmd/oidc-server/main.go go.mod go.sum ./
6-
COPY ./internal/models/ ./internal/models/
6+
COPY ./internal/repos/postgresql/gen/models/ ./internal/repos/postgresql/gen/models/
77
# RUN go mod download # it will access network/cache, which is not necessary with -mod=vendor
88
ENV CGO_ENABLED=0
99
RUN --mount=type=cache,target=/root/.cache/go-build \

bin/.helpers.sh

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,22 @@ array.add_suffix() {
189189
printf "%s\n" "${@/%/$suffix}"
190190
}
191191

192+
# modifies in place
193+
array.remove_element() {
194+
local -n array=$1
195+
local value=$2
196+
local temp_array=()
197+
198+
# Loop through the array and keep only elements that are not equal to the value
199+
for element in "${array[@]}"; do
200+
if [ "$element" != "$value" ]; then
201+
temp_array+=("$element")
202+
fi
203+
done
204+
205+
# Assign the modified array back to the original array
206+
array=("${temp_array[@]}")
207+
}
192208
# breaks when separator has spaces, e.g. " | "
193209
# join_by() {
194210
# [ "$#" -ge 1 ] || return 1
@@ -207,9 +223,20 @@ to_snake() {
207223
echo "${kebab//-/_}"
208224
}
209225

226+
# https://stackoverflow.com/questions/57804252/consistent-syntax-for-obtaining-output-of-a-command-efficiently-in-bash
227+
# also see https://github.com/dimo414/bash-cache if needed for more expensive functions
228+
declare -Ag memoized_to_pascal
229+
230+
# via nameref
210231
to_pascal() {
211-
local string=$1
212-
local pascal_case=""
232+
local -n __to_pascal_res="$1"
233+
local string="$2"
234+
235+
local memoized="${memoized_to_pascal[$string]}"
236+
if [[ -n "$memoized" ]]; then
237+
__to_pascal_res="$memoized"
238+
return
239+
fi
213240

214241
# Replace spaces with nothing and capitalize the following letter
215242
string="${string// \([a-z]\)/\U\1}"
@@ -223,18 +250,22 @@ to_pascal() {
223250

224251
for word in $string; do
225252
if [[ " ${exceptions[*]} " =~ " $word " ]]; then
226-
pascal_case+="${word^^}" # Uppercase the whole word
253+
__to_pascal_res+="${word^^}" # Uppercase the whole word
227254
else
228-
pascal_case+="${word^}" # Capitalize the first letter
255+
__to_pascal_res+="${word^}" # Capitalize the first letter
229256
fi
230257
done
231258

232-
echo "$pascal_case"
259+
memoized_to_pascal["$string"]="$__to_pascal_res"
233260
}
234261

262+
# via nameref
235263
to_camel() {
236-
local pascal_case=$(to_pascal "$1")
237-
echo "${pascal_case,}"
264+
local -n __to_camel_res="$1"
265+
local string="$2"
266+
267+
to_pascal __to_camel_res "$string"
268+
__to_camel_res="${__to_camel_res,}"
238269
}
239270

240271
function to_kebab() {

0 commit comments

Comments
 (0)