From 6f841fbbec52ca69ef05671a6d46645056999a68 Mon Sep 17 00:00:00 2001 From: 66james99 Date: Tue, 16 Dec 2025 15:27:15 +0000 Subject: [PATCH 01/34] Updated README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index c2bec0368b7..4c2c4467b22 100644 --- a/README.md +++ b/README.md @@ -21,3 +21,5 @@ go build -o notely && ./notely *This starts the server in non-database mode.* It will serve a simple webpage at `http://localhost:8080`. You do *not* need to set up a database or any interactivity on the webpage yet. Instructions for that will come later in the course! + +James' version of Boot.dev's Notely app. From 6e1cb0a33e866764ca852142ff10dbe88198a340 Mon Sep 17 00:00:00 2001 From: 66james99 Date: Tue, 16 Dec 2025 15:43:01 +0000 Subject: [PATCH 02/34] Updated README.md again --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4c2c4467b22..bfae6d175d4 100644 --- a/README.md +++ b/README.md @@ -22,4 +22,4 @@ go build -o notely && ./notely You do *not* need to set up a database or any interactivity on the webpage yet. Instructions for that will come later in the course! -James' version of Boot.dev's Notely app. +James Hammick's version of Boot.dev's Notely app. From ad1c48983e021592475136e377b13567ebc49799 Mon Sep 17 00:00:00 2001 From: 66james99 Date: Tue, 16 Dec 2025 15:48:31 +0000 Subject: [PATCH 03/34] Add CI configuration --- .github/workflow/ci.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflow/ci.yml diff --git a/.github/workflow/ci.yml b/.github/workflow/ci.yml new file mode 100644 index 00000000000..a54d8248d54 --- /dev/null +++ b/.github/workflow/ci.yml @@ -0,0 +1,22 @@ +name: ci + +on: + pull_request: + branches: [main] + +jobs: + tests: + name: Tests + runs-on: ubuntu-latest + + steps: + - name: Check out code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: "1.25.1" + + - name: Force Failure + run: (exit 1) \ No newline at end of file From cf56652f5458f8ae525e7aa951257c0b549b0e26 Mon Sep 17 00:00:00 2001 From: 66james99 Date: Tue, 16 Dec 2025 15:51:10 +0000 Subject: [PATCH 04/34] modified ci.yml --- .github/workflow/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflow/ci.yml b/.github/workflow/ci.yml index a54d8248d54..1457d627fbc 100644 --- a/.github/workflow/ci.yml +++ b/.github/workflow/ci.yml @@ -19,4 +19,5 @@ jobs: go-version: "1.25.1" - name: Force Failure - run: (exit 1) \ No newline at end of file + run: (exit 1) + \ No newline at end of file From 220a13b868015abe3c442e3dd83731e8254ce947 Mon Sep 17 00:00:00 2001 From: 66james99 Date: Tue, 16 Dec 2025 15:59:25 +0000 Subject: [PATCH 05/34] updated ci.yml to have lf/cr --- .github/workflow/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflow/ci.yml b/.github/workflow/ci.yml index 1457d627fbc..249cc5258a3 100644 --- a/.github/workflow/ci.yml +++ b/.github/workflow/ci.yml @@ -20,4 +20,3 @@ jobs: - name: Force Failure run: (exit 1) - \ No newline at end of file From 821e5aa2c0565af1459f2cde5f879225be13e952 Mon Sep 17 00:00:00 2001 From: 66james99 Date: Tue, 16 Dec 2025 16:16:28 +0000 Subject: [PATCH 06/34] trigger ci --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bfae6d175d4..4c2c4467b22 100644 --- a/README.md +++ b/README.md @@ -22,4 +22,4 @@ go build -o notely && ./notely You do *not* need to set up a database or any interactivity on the webpage yet. Instructions for that will come later in the course! -James Hammick's version of Boot.dev's Notely app. +James' version of Boot.dev's Notely app. From 0061d7be3cc59793040b907505364e3c47410e58 Mon Sep 17 00:00:00 2001 From: 66james99 Date: Tue, 16 Dec 2025 16:18:28 +0000 Subject: [PATCH 07/34] corected directory name to workflows from workflow --- .github/{workflow => workflows}/ci.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{workflow => workflows}/ci.yml (100%) diff --git a/.github/workflow/ci.yml b/.github/workflows/ci.yml similarity index 100% rename from .github/workflow/ci.yml rename to .github/workflows/ci.yml From b358d220db2b1afe0e351e52f57875de055fcf54 Mon Sep 17 00:00:00 2001 From: 66james99 Date: Tue, 16 Dec 2025 16:33:09 +0000 Subject: [PATCH 08/34] Change test to "go version" --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 249cc5258a3..ce9ce44f05f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,5 +18,5 @@ jobs: with: go-version: "1.25.1" - - name: Force Failure - run: (exit 1) + - name: Check Go Version + run: (go version) From df42bea2621cabf5e25b1398c315bb9628bcc605 Mon Sep 17 00:00:00 2001 From: 66james99 Date: Tue, 16 Dec 2025 16:41:46 +0000 Subject: [PATCH 09/34] updated test --- .github/workflows/ci.yml | 2 +- internal/auth/get_api_key_test.go | 62 +++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 internal/auth/get_api_key_test.go diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ce9ce44f05f..f3cff421254 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,4 +19,4 @@ jobs: go-version: "1.25.1" - name: Check Go Version - run: (go version) + run: go test ./... diff --git a/internal/auth/get_api_key_test.go b/internal/auth/get_api_key_test.go new file mode 100644 index 00000000000..5ac1cd99d36 --- /dev/null +++ b/internal/auth/get_api_key_test.go @@ -0,0 +1,62 @@ +package auth + +import ( + "fmt" + "net/http" + "strings" + "testing" +) + +func TestGetAPIKey(t *testing.T) { + tests := []struct { + key string + value string + expect string + expectErr string + }{ + { + expectErr: "no authorization header", + }, + { + key: "Authorization", + expectErr: "no authorization header", + }, + { + key: "Authorization", + value: "-", + expectErr: "malformed authorization header", + }, + { + key: "Authorization", + value: "Bearer xxxxxx", + expectErr: "malformed authorization header", + }, + { + key: "Authorization", + value: "ApiKey xxxxxx", + expect: "xxxxxx", + expectErr: "not expecting an error", + }, + } + + for i, test := range tests { + t.Run(fmt.Sprintf("TestGetAPIKey Case #%v:", i), func(t *testing.T) { + header := http.Header{} + header.Add(test.key, test.value) + + output, err := GetAPIKey(header) + if err != nil { + if strings.Contains(err.Error(), test.expectErr) { + return + } + t.Errorf("Unexpected: TestGetAPIKey:%v\n", err) + return + } + + if output != test.expect { + t.Errorf("Unexpected: TestGetAPIKey:%s", output) + return + } + }) + } +} From fb618ab35231e2bc45439077d452b961fc7355bd Mon Sep 17 00:00:00 2001 From: 66james99 Date: Tue, 16 Dec 2025 16:45:43 +0000 Subject: [PATCH 10/34] Add -cover to go test --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f3cff421254..79782e10b97 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,4 +19,4 @@ jobs: go-version: "1.25.1" - name: Check Go Version - run: go test ./... + run: go test ./... -cover From dd78f7655d025acaf62a082950a233e5de0897c5 Mon Sep 17 00:00:00 2001 From: 66james99 Date: Tue, 16 Dec 2025 16:50:39 +0000 Subject: [PATCH 11/34] Add test badge to README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 4c2c4467b22..4f1765fa0d7 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +![Github test badge](https://github.com/66james99/learn-cicd-starter/actions/workflows/ci/badge.svg) # learn-cicd-starter (Notely) This repo contains the starter code for the "Notely" application for the "Learn CICD" course on [Boot.dev](https://boot.dev). From f8ab041f41076e6d6cf19c9d73433c58516a7667 Mon Sep 17 00:00:00 2001 From: 66james99 Date: Tue, 16 Dec 2025 16:54:33 +0000 Subject: [PATCH 12/34] Corrected URL for test badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4f1765fa0d7..b6b2faeaae1 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -![Github test badge](https://github.com/66james99/learn-cicd-starter/actions/workflows/ci/badge.svg) +![Github test badge](https://github.com/66james99/learn-cicd-starter/actions/workflows/ci.yml/badge.svg) # learn-cicd-starter (Notely) This repo contains the starter code for the "Notely" application for the "Learn CICD" course on [Boot.dev](https://boot.dev). From 3f24ed76c4e094da24eda41e76f6ec4789f5af09 Mon Sep 17 00:00:00 2001 From: 66james99 Date: Tue, 16 Dec 2025 17:11:35 +0000 Subject: [PATCH 13/34] Add format test to ci jobs --- .github/workflows/ci.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 79782e10b97..ae031af4370 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,5 +18,20 @@ jobs: with: go-version: "1.25.1" - - name: Check Go Version + - name: Run Go tests with coverage information run: go test ./... -cover + style: + name: Style Check + runs-on: ubuntu-latest + + steps: + - name: Check out code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: "1.25.1" + + - name: Run go fmt + run: test -z $(go fmt ./...) \ No newline at end of file From fc684352c32cc23945213cc81f2e6f9f6826764b Mon Sep 17 00:00:00 2001 From: 66james99 Date: Tue, 16 Dec 2025 17:14:26 +0000 Subject: [PATCH 14/34] Upaded name of style job --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ae031af4370..69f4712d86f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: - name: Run Go tests with coverage information run: go test ./... -cover style: - name: Style Check + name: Style runs-on: ubuntu-latest steps: From 17271d3e7a53bd59daa347ed5428e8f6e057d83b Mon Sep 17 00:00:00 2001 From: 66james99 Date: Tue, 16 Dec 2025 17:22:45 +0000 Subject: [PATCH 15/34] Add static check to CI style --- .github/workflows/ci.yml | 7 ++++++- main.go | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 69f4712d86f..3819030f676 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,4 +34,9 @@ jobs: go-version: "1.25.1" - name: Run go fmt - run: test -z $(go fmt ./...) \ No newline at end of file + run: test -z $(go fmt ./...) + + - name: Run staticcheck + uses: dominikh/staticcheck-action@v1 + with: + version: "latest" \ No newline at end of file diff --git a/main.go b/main.go index 19d7366c5f7..0cdadac81f6 100644 --- a/main.go +++ b/main.go @@ -96,3 +96,8 @@ func main() { log.Printf("Serving on port: %s\n", port) log.Fatal(srv.ListenAndServe()) } + +func unused() { + // this function does nothing + // and is called nowhere +} From 841a3556a8334a2353b826ae0b6819afb073afd7 Mon Sep 17 00:00:00 2001 From: 66james99 Date: Tue, 16 Dec 2025 17:24:41 +0000 Subject: [PATCH 16/34] Fixed fmt of main.go --- main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 0cdadac81f6..a621713c2bd 100644 --- a/main.go +++ b/main.go @@ -98,6 +98,6 @@ func main() { } func unused() { - // this function does nothing - // and is called nowhere + // this function does nothing + // and is called nowhere } From 6f3e89d7877adbc456e2c1e44962925891f6006a Mon Sep 17 00:00:00 2001 From: 66james99 Date: Tue, 16 Dec 2025 17:26:48 +0000 Subject: [PATCH 17/34] Remove unused func in main.go --- main.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/main.go b/main.go index a621713c2bd..88920cdc395 100644 --- a/main.go +++ b/main.go @@ -97,7 +97,4 @@ func main() { log.Fatal(srv.ListenAndServe()) } -func unused() { - // this function does nothing - // and is called nowhere -} + From 4d3864581f1567d425368518922a94371a719d42 Mon Sep 17 00:00:00 2001 From: 66james99 Date: Tue, 16 Dec 2025 17:27:38 +0000 Subject: [PATCH 18/34] fixed fmt of main.go --- main.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/main.go b/main.go index 88920cdc395..19d7366c5f7 100644 --- a/main.go +++ b/main.go @@ -96,5 +96,3 @@ func main() { log.Printf("Serving on port: %s\n", port) log.Fatal(srv.ListenAndServe()) } - - From 651f8881ad41645e7fe870e300ed45a4b80a1207 Mon Sep 17 00:00:00 2001 From: 66james99 Date: Tue, 16 Dec 2025 17:36:04 +0000 Subject: [PATCH 19/34] Add go sec to CI tests --- .github/workflows/ci.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3819030f676..0e315057d67 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,9 +17,16 @@ jobs: uses: actions/setup-go@v5 with: go-version: "1.25.1" + + - name: Install gosec + run: go install github.com/securego/gosec/v2/cmd/gosec@latest - name: Run Go tests with coverage information run: go test ./... -cover + + - name: Run gosec security checks + run: gosec ./... + style: name: Style runs-on: ubuntu-latest From f648169f2f30dd348440d0a8f88d3b83deb80ede Mon Sep 17 00:00:00 2001 From: 66james99 Date: Tue, 16 Dec 2025 17:47:05 +0000 Subject: [PATCH 20/34] Fixed gosec issues --- json.go | 5 ++++- main.go | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/json.go b/json.go index 1e6e7985e18..c72d9a4f36f 100644 --- a/json.go +++ b/json.go @@ -30,5 +30,8 @@ func respondWithJSON(w http.ResponseWriter, code int, payload interface{}) { return } w.WriteHeader(code) - w.Write(dat) + _, err = w.Write(dat) + if err != nil { + log.Printf("Error writing response: %s", err) + } } diff --git a/main.go b/main.go index 19d7366c5f7..478cdc59bc9 100644 --- a/main.go +++ b/main.go @@ -91,6 +91,10 @@ func main() { srv := &http.Server{ Addr: ":" + port, Handler: router, + ReadHeaderTimeout: 15, + ReadTimeout: 15, + WriteTimeout: 10, + IdleTimeout: 30, } log.Printf("Serving on port: %s\n", port) From fc49547050f4009aca664a7ad70cb81ba0e84dc5 Mon Sep 17 00:00:00 2001 From: 66james99 Date: Tue, 16 Dec 2025 17:48:56 +0000 Subject: [PATCH 21/34] Fixed name of gosec ci test to that expected by Boot.dev --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0e315057d67..ba718a39f34 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,9 +24,9 @@ jobs: - name: Run Go tests with coverage information run: go test ./... -cover - - name: Run gosec security checks + - name: gosec run: gosec ./... - + style: name: Style runs-on: ubuntu-latest From 1fcc3bebc22beb8dcefb40428c3aaa122ed6b8cc Mon Sep 17 00:00:00 2001 From: 66james99 Date: Tue, 16 Dec 2025 17:52:50 +0000 Subject: [PATCH 22/34] Fixed fmt of main.go after security fixes --- main.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index 478cdc59bc9..6d9e33aacd2 100644 --- a/main.go +++ b/main.go @@ -89,12 +89,12 @@ func main() { router.Mount("/v1", v1Router) srv := &http.Server{ - Addr: ":" + port, - Handler: router, + Addr: ":" + port, + Handler: router, ReadHeaderTimeout: 15, - ReadTimeout: 15, - WriteTimeout: 10, - IdleTimeout: 30, + ReadTimeout: 15, + WriteTimeout: 10, + IdleTimeout: 30, } log.Printf("Serving on port: %s\n", port) From 81b6c7ca698f51f307164f2a5be1a682c1806c9c Mon Sep 17 00:00:00 2001 From: 66james99 Date: Tue, 16 Dec 2025 18:28:05 +0000 Subject: [PATCH 23/34] matching main.go to that expected by boot.dev --- Dockerfile | 2 +- main.go | 3 --- scripts/buildprod.sh | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2be3d18b812..d8bc2d39df8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM --platform=linux/amd64 debian:stable-slim +FROM --platform=linux/arm64 debian:stable-slim RUN apt-get update && apt-get install -y ca-certificates diff --git a/main.go b/main.go index 6d9e33aacd2..df67db5a664 100644 --- a/main.go +++ b/main.go @@ -92,9 +92,6 @@ func main() { Addr: ":" + port, Handler: router, ReadHeaderTimeout: 15, - ReadTimeout: 15, - WriteTimeout: 10, - IdleTimeout: 30, } log.Printf("Serving on port: %s\n", port) diff --git a/scripts/buildprod.sh b/scripts/buildprod.sh index f08d1a592e6..1bbeef30fbe 100755 --- a/scripts/buildprod.sh +++ b/scripts/buildprod.sh @@ -1,3 +1,3 @@ #!/bin/bash -CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o notely +CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o notely From 13a2177d13005a27426e0738424e96fd584185ff Mon Sep 17 00:00:00 2001 From: 66james99 Date: Tue, 16 Dec 2025 19:36:43 +0000 Subject: [PATCH 24/34] Trying to get notely to work on arm64 --- go.mod | 2 +- go.sum | 12 +++++++++-- vendor/github.com/go-chi/cors/README.md | 6 +++++- vendor/github.com/go-chi/cors/cors.go | 28 +++++++++++++------------ vendor/modules.txt | 2 +- 5 files changed, 32 insertions(+), 18 deletions(-) diff --git a/go.mod b/go.mod index 09e04f9c12b..e62f7b9c2c1 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.22 require ( github.com/go-chi/chi v1.5.4 - github.com/go-chi/cors v1.2.1 + github.com/go-chi/cors v1.2.2 github.com/google/uuid v1.3.0 github.com/joho/godotenv v1.5.1 github.com/tursodatabase/libsql-client-go v0.0.0-20240220085343-4ae0eb9d0898 diff --git a/go.sum b/go.sum index e3c6163bd09..1deeea6d43e 100644 --- a/go.sum +++ b/go.sum @@ -8,8 +8,8 @@ github.com/gin-gonic/gin v1.6.3 h1:ahKqKTFpO5KTPHxWZjEdPScmYaGtLo8Y4DMHoEsnp14= github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= github.com/go-chi/chi v1.5.4 h1:QHdzF2szwjqVV4wmByUnTcsbIg7UGaQ0tPF2t5GcAIs= github.com/go-chi/chi v1.5.4/go.mod h1:uaf8YgoFazUOkPBG7fxPftUylNumIev9awIWOENIuEg= -github.com/go-chi/cors v1.2.1 h1:xEC8UT3Rlp2QuWNEr4Fs/c2EAGVKBwy/1vHx3bppil4= -github.com/go-chi/cors v1.2.1/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58= +github.com/go-chi/cors v1.2.2 h1:Jmey33TE+b+rB7fT8MUy1u0I4L+NARQlK6LhzKPSyQE= +github.com/go-chi/cors v1.2.2/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= @@ -26,8 +26,10 @@ github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/E github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -37,6 +39,7 @@ github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.15.15 h1:EF27CXIuDsYJ6mmvtBRlEuB2UVOqHG1tAXgZ7yIO+lw= github.com/klauspost/compress v1.15.15/go.mod h1:ZcK2JAFqKOpnBlxcLsJzYfrS9X1akm9fHZNnD9+Vo/4= @@ -46,8 +49,10 @@ github.com/libsql/sqlite-antlr4-parser v0.0.0-20230802215326-5cb5bb604475 h1:6Pf github.com/libsql/sqlite-antlr4-parser v0.0.0-20230802215326-5cb5bb604475/go.mod h1:20nXSmcf0nAscrzqsXeC2/tA3KkV2eCiJqYuyAgl+ss= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.18 h1:DOKFKCQ7FNG2L1rbrmstDN4QVRdS89Nkh85u68Uwp98= +github.com/mattn/go-isatty v0.0.18/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -64,14 +69,17 @@ golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e h1:+WEEuIdZHnUeJJmEUjyYC2gfU golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e/go.mod h1:Kr81I6Kryrl9sr8s2FK3vxD90NdsKWRuOIl2O4CvYbA= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s= +golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= +google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= nhooyr.io/websocket v1.8.7 h1:usjR2uOr/zjjkVMy0lW+PPohFok7PCow5sDjLgX4P4g= nhooyr.io/websocket v1.8.7/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= diff --git a/vendor/github.com/go-chi/cors/README.md b/vendor/github.com/go-chi/cors/README.md index b41686b6aff..95dfa027383 100644 --- a/vendor/github.com/go-chi/cors/README.md +++ b/vendor/github.com/go-chi/cors/README.md @@ -7,6 +7,10 @@ are required for using the browser native [Fetch API](https://developer.mozilla. This middleware is designed to be used as a top-level middleware on the [chi](https://github.com/go-chi/chi) router. Applying with within a `r.Group()` or using `With()` will not work without routes matching `OPTIONS` added. +## Install + +`go get github.com/go-chi/cors` + ## Usage ```go @@ -36,4 +40,4 @@ func main() { ## Credits -All credit for the original work of this middleware goes out to [github.com/rs](github.com/rs). +All credit for the original work of this middleware goes out to [github.com/rs](https://github.com/rs). diff --git a/vendor/github.com/go-chi/cors/cors.go b/vendor/github.com/go-chi/cors/cors.go index 8df81636e3b..7005755da9d 100644 --- a/vendor/github.com/go-chi/cors/cors.go +++ b/vendor/github.com/go-chi/cors/cors.go @@ -3,15 +3,15 @@ // // You can configure it by passing an option struct to cors.New: // -// c := cors.New(cors.Options{ -// AllowedOrigins: []string{"foo.com"}, -// AllowedMethods: []string{"GET", "POST", "DELETE"}, -// AllowCredentials: true, -// }) +// c := cors.New(cors.Options{ +// AllowedOrigins: []string{"foo.com"}, +// AllowedMethods: []string{"GET", "POST", "DELETE"}, +// AllowCredentials: true, +// }) // // Then insert the handler in the chain: // -// handler = c.Handler(handler) +// handler = c.Handler(handler) // // See Options documentation for more options. // @@ -210,7 +210,10 @@ func AllowAll() *Cors { // as necessary. func (c *Cors) Handler(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if r.Method == http.MethodOptions && r.Header.Get("Access-Control-Request-Method") != "" { + // null or empty Origin header value is acceptable and it is considered having that header + _, hasOriginHeader := r.Header["Origin"] + + if r.Method == http.MethodOptions && r.Header.Get("Access-Control-Request-Method") != "" && hasOriginHeader { c.logf("Handler: Preflight request") c.handlePreflight(w, r) // Preflight requests are standalone and should stop the chain as some other @@ -246,10 +249,6 @@ func (c *Cors) handlePreflight(w http.ResponseWriter, r *http.Request) { headers.Add("Vary", "Access-Control-Request-Method") headers.Add("Vary", "Access-Control-Request-Headers") - if origin == "" { - c.logf("Preflight aborted: empty origin") - return - } if !c.isOriginAllowed(r, origin) { c.logf("Preflight aborted: origin '%s' not allowed", origin) return @@ -291,14 +290,17 @@ func (c *Cors) handlePreflight(w http.ResponseWriter, r *http.Request) { // handleActualRequest handles simple cross-origin requests, actual request or redirects func (c *Cors) handleActualRequest(w http.ResponseWriter, r *http.Request) { headers := w.Header() - origin := r.Header.Get("Origin") + // null Origin header value is acceptable and it is considered having that header + _, hasOriginHeader := r.Header["Origin"] // Always set Vary, see https://github.com/rs/cors/issues/10 headers.Add("Vary", "Origin") - if origin == "" { + + if !hasOriginHeader { c.logf("Actual request no headers added: missing origin") return } + origin := r.Header.Get("Origin") if !c.isOriginAllowed(r, origin) { c.logf("Actual request no headers added: origin '%s' not allowed", origin) return diff --git a/vendor/modules.txt b/vendor/modules.txt index 9fefa576859..14939d897ba 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -4,7 +4,7 @@ github.com/antlr/antlr4/runtime/Go/antlr/v4 # github.com/go-chi/chi v1.5.4 ## explicit; go 1.16 github.com/go-chi/chi -# github.com/go-chi/cors v1.2.1 +# github.com/go-chi/cors v1.2.2 ## explicit; go 1.14 github.com/go-chi/cors # github.com/google/uuid v1.3.0 From 556d11a9776c93ab659f8b1b00241f1995d659c0 Mon Sep 17 00:00:00 2001 From: 66james99 Date: Tue, 16 Dec 2025 23:38:26 +0000 Subject: [PATCH 25/34] Fix isssue with timeout being 15ms rather than 15 second --- main.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index df67db5a664..2112d4a1ec3 100644 --- a/main.go +++ b/main.go @@ -7,6 +7,7 @@ import ( "log" "net/http" "os" + "time" "github.com/go-chi/chi" "github.com/go-chi/cors" @@ -91,7 +92,7 @@ func main() { srv := &http.Server{ Addr: ":" + port, Handler: router, - ReadHeaderTimeout: 15, + ReadHeaderTimeout: 15 * time.Second, } log.Printf("Serving on port: %s\n", port) From beb6c62b8f35ccb4a75e16c224eb04bb3a777a5f Mon Sep 17 00:00:00 2001 From: 66james99 Date: Wed, 17 Dec 2025 00:01:39 +0000 Subject: [PATCH 26/34] Add CD job --- .github/workflows/cd.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/cd.yml diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 00000000000..72b01c89007 --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,22 @@ +name: cd + +on: + push: + branches: [main] + +jobs: + deploy: + name: DeployTests + runs-on: ubuntu-latest + + steps: + - name: Check out code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: "1.25.1" + + - name: Deploy + run: scripts/buildprod.sh \ No newline at end of file From b167e10550288c8545f137a2991df742c6671c12 Mon Sep 17 00:00:00 2001 From: 66james99 Date: Wed, 17 Dec 2025 00:11:19 +0000 Subject: [PATCH 27/34] cd.yml from Boot.dev CICD course --- .github/workflows/cd.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 72b01c89007..ae596471548 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -6,7 +6,7 @@ on: jobs: deploy: - name: DeployTests + name: Deploy runs-on: ubuntu-latest steps: @@ -17,6 +17,6 @@ jobs: uses: actions/setup-go@v5 with: go-version: "1.25.1" - - - name: Deploy - run: scripts/buildprod.sh \ No newline at end of file + + - name: Build app + run: ./scripts/buildprod.sh \ No newline at end of file From 172d7f07717c96c1321ea33c1dca071fd5b7ae52 Mon Sep 17 00:00:00 2001 From: 66james99 Date: Wed, 17 Dec 2025 01:02:20 +0000 Subject: [PATCH 28/34] Added GCP deployment --- .github/workflows/cd.yml | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index ae596471548..e52e75d7659 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -19,4 +19,31 @@ jobs: go-version: "1.25.1" - name: Build app - run: ./scripts/buildprod.sh \ No newline at end of file + run: ./scripts/buildprod.sh + + - id: auth + uses: google-github-actions/auth@v2 + with: + credentials_json: ${{ secrets.GCP_CREDENTIALS }} + + - name: Set up Cloud SDK + uses: google-github-actions/setup-gcloud@v2 + + - name: Use gcloud CLI + run: gcloud info + + - name: Build and push Docker image + run: gcloud builds submit --tag + - id: auth + uses: google-github-actions/auth@v2 + with: + credentials_json: ${{ secrets.GCP_CREDENTIALS }} + + - name: Set up Cloud SDK + uses: google-github-actions/setup-gcloud@v2 + + - name: Use gcloud CLI + run: gcloud info + + - name: Build and push Docker image + run: gcloud builds submit --tag urope-west2-docker.pkg.dev/notely-456378/notely-ar-repo . \ No newline at end of file From ff75fd8a8f1239d260c06adf90a582038164ce62 Mon Sep 17 00:00:00 2001 From: 66james99 Date: Wed, 17 Dec 2025 01:07:41 +0000 Subject: [PATCH 29/34] Fixed cd.yml --- .github/workflows/cd.yml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index e52e75d7659..a866eadc40e 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -32,18 +32,5 @@ jobs: - name: Use gcloud CLI run: gcloud info - - name: Build and push Docker image - run: gcloud builds submit --tag - - id: auth - uses: google-github-actions/auth@v2 - with: - credentials_json: ${{ secrets.GCP_CREDENTIALS }} - - - name: Set up Cloud SDK - uses: google-github-actions/setup-gcloud@v2 - - - name: Use gcloud CLI - run: gcloud info - - name: Build and push Docker image run: gcloud builds submit --tag urope-west2-docker.pkg.dev/notely-456378/notely-ar-repo . \ No newline at end of file From cade9cb752e50d21852937ee435346a3901a675a Mon Sep 17 00:00:00 2001 From: 66james99 Date: Wed, 17 Dec 2025 01:35:17 +0000 Subject: [PATCH 30/34] fixed changed from arm64 to amd64 and fixed repo target --- .github/workflows/cd.yml | 2 +- Dockerfile | 2 +- scripts/buildprod.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index a866eadc40e..2d3358cf8af 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -33,4 +33,4 @@ jobs: run: gcloud info - name: Build and push Docker image - run: gcloud builds submit --tag urope-west2-docker.pkg.dev/notely-456378/notely-ar-repo . \ No newline at end of file + run: gcloud builds submit --tag europe-west2-docker.pkg.dev/notely-456378/notely-ar-repo:latest . \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index d8bc2d39df8..2be3d18b812 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM --platform=linux/arm64 debian:stable-slim +FROM --platform=linux/amd64 debian:stable-slim RUN apt-get update && apt-get install -y ca-certificates diff --git a/scripts/buildprod.sh b/scripts/buildprod.sh index 1bbeef30fbe..f08d1a592e6 100755 --- a/scripts/buildprod.sh +++ b/scripts/buildprod.sh @@ -1,3 +1,3 @@ #!/bin/bash -CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o notely +CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o notely From 34804a38b7eec9b71c3029b39277b2a97647677d Mon Sep 17 00:00:00 2001 From: 66james99 Date: Wed, 17 Dec 2025 01:39:26 +0000 Subject: [PATCH 31/34] Fixed CD artifact name for GCP --- .github/workflows/cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 2d3358cf8af..14fac8fadf6 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -33,4 +33,4 @@ jobs: run: gcloud info - name: Build and push Docker image - run: gcloud builds submit --tag europe-west2-docker.pkg.dev/notely-456378/notely-ar-repo:latest . \ No newline at end of file + run: gcloud builds submit --tag europe-west2-docker.pkg.dev/notely-456378/notely-ar-repo/notely:latest . \ No newline at end of file From 3c9687bf1eb98b220a28e533ef5a4034ad0197a7 Mon Sep 17 00:00:00 2001 From: 66james99 Date: Wed, 17 Dec 2025 22:23:21 +0000 Subject: [PATCH 32/34] Add delopyment to Cloud Run --- .github/workflows/cd.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 14fac8fadf6..8a6fd816ab2 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -33,4 +33,7 @@ jobs: run: gcloud info - name: Build and push Docker image - run: gcloud builds submit --tag europe-west2-docker.pkg.dev/notely-456378/notely-ar-repo/notely:latest . \ No newline at end of file + run: gcloud builds submit --tag europe-west2-docker.pkg.dev/notely-456378/notely-ar-repo/notely:latest . + + - name: Deploy to Cloud Run + run: gcloud run deploy notely --image europe-west2-docker.pkg.dev/notely-456378/notely-ar-repo/notely:latest --region europe-west2 --allow-unauthenticated --project notely-456378 --max-instances=4 \ No newline at end of file From ef268e870ff05a844fb66a11dc8595146157d423 Mon Sep 17 00:00:00 2001 From: 66james99 Date: Wed, 17 Dec 2025 22:27:53 +0000 Subject: [PATCH 33/34] Update index.html to say Welcome to Notely --- static/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/index.html b/static/index.html index 72be101028c..5d4ad73c095 100644 --- a/static/index.html +++ b/static/index.html @@ -7,7 +7,7 @@ -

Notely

+

Welcome to Notely

From 59c925d6e723834415f15a5b5c2184ffa942e47e Mon Sep 17 00:00:00 2001 From: 66james99 Date: Wed, 17 Dec 2025 23:00:36 +0000 Subject: [PATCH 34/34] Update CD to use migrateup.sh --- .github/workflows/cd.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 8a6fd816ab2..8d451a31bca 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -9,6 +9,9 @@ jobs: name: Deploy runs-on: ubuntu-latest + env: + DATABASE_URL: ${{ secrets.DATABASE_URL }} + steps: - name: Check out code uses: actions/checkout@v4 @@ -18,6 +21,9 @@ jobs: with: go-version: "1.25.1" + - name: Install Goose + run: go install github.com/pressly/goose/v3/cmd/goose@latest + - name: Build app run: ./scripts/buildprod.sh @@ -35,5 +41,9 @@ jobs: - name: Build and push Docker image run: gcloud builds submit --tag europe-west2-docker.pkg.dev/notely-456378/notely-ar-repo/notely:latest . + - name: Update database + run: ./scripts/migrateup.sh + + - name: Deploy to Cloud Run run: gcloud run deploy notely --image europe-west2-docker.pkg.dev/notely-456378/notely-ar-repo/notely:latest --region europe-west2 --allow-unauthenticated --project notely-456378 --max-instances=4 \ No newline at end of file