Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
130 commits
Select commit Hold shift + click to select a range
036911c
Merge pull request #527 from kthcloud/dev
saffronjam Apr 29, 2024
9767a75
Merge pull request #529 from kthcloud/dev
saffronjam Apr 30, 2024
3622be9
Merge pull request #530 from kthcloud/dev
saffronjam Apr 30, 2024
5885abb
Merge pull request #531 from kthcloud/dev
saffronjam Apr 30, 2024
46b4709
Merge pull request #532 from kthcloud/dev
saffronjam Apr 30, 2024
cfc4875
Merge pull request #533 from kthcloud/dev
saffronjam Apr 30, 2024
a8716c1
Merge pull request #534 from kthcloud/dev
saffronjam Apr 30, 2024
f3d1f9e
Merge pull request #535 from kthcloud/dev
saffronjam Apr 30, 2024
7bda2dd
Merge pull request #536 from kthcloud/dev
saffronjam Apr 30, 2024
917e579
Merge pull request #537 from kthcloud/dev
saffronjam Apr 30, 2024
07bb8d7
Merge pull request #538 from kthcloud/dev
saffronjam Apr 30, 2024
2a42bdc
Merge pull request #539 from kthcloud/dev
saffronjam Apr 30, 2024
8241941
Merge pull request #540 from kthcloud/dev
saffronjam Apr 30, 2024
a75f5e7
Merge pull request #541 from kthcloud/dev
saffronjam Apr 30, 2024
a003c06
Merge pull request #542 from kthcloud/dev
saffronjam Apr 30, 2024
208a4bc
Merge pull request #543 from kthcloud/dev
saffronjam Apr 30, 2024
220a163
Merge pull request #544 from kthcloud/dev
saffronjam Apr 30, 2024
5fcb892
Merge pull request #545 from kthcloud/dev
saffronjam Apr 30, 2024
cc6cd9d
Merge pull request #546 from kthcloud/dev
saffronjam Apr 30, 2024
b59cce1
Merge pull request #547 from kthcloud/dev
saffronjam Apr 30, 2024
25c8100
Merge pull request #548 from kthcloud/dev
saffronjam Apr 30, 2024
b46e774
Merge pull request #549 from kthcloud/dev
saffronjam Apr 30, 2024
a7330ec
Merge pull request #557 from kthcloud/dev
saffronjam May 2, 2024
29665b7
Merge pull request #558 from kthcloud/dev
saffronjam May 2, 2024
6c2f524
Merge pull request #559 from kthcloud/dev
saffronjam May 2, 2024
df39c24
Merge pull request #560 from kthcloud/dev
saffronjam May 2, 2024
9079444
Merge pull request #563 from kthcloud/dev
saffronjam May 3, 2024
559be27
Merge pull request #574 from kthcloud/dev
saffronjam May 10, 2024
134dab4
Merge pull request #577 from kthcloud/dev
saffronjam May 10, 2024
baeaca4
Merge pull request #578 from kthcloud/dev
saffronjam May 10, 2024
156a399
Merge pull request #583 from kthcloud/dev
saffronjam May 14, 2024
e355c85
Merge pull request #584 from kthcloud/dev
saffronjam May 14, 2024
b34fd3b
Merge pull request #585 from kthcloud/dev
saffronjam May 14, 2024
f67630d
Merge pull request #591 from kthcloud/dev
saffronjam May 16, 2024
7aa924d
Merge pull request #592 from kthcloud/dev
saffronjam May 16, 2024
edaddd1
Merge pull request #593 from kthcloud/dev
saffronjam May 16, 2024
b10e95e
Merge pull request #597 from kthcloud/dev
saffronjam May 17, 2024
3995a65
Merge pull request #598 from kthcloud/dev
saffronjam May 18, 2024
d86c57e
Merge pull request #605 from kthcloud/dev
saffronjam May 22, 2024
21e7125
Merge pull request #606 from kthcloud/dev
saffronjam May 22, 2024
eab6e09
Merge pull request #607 from kthcloud/dev
saffronjam May 22, 2024
96a692e
Merge pull request #608 from kthcloud/dev
saffronjam May 22, 2024
8a84c98
Merge pull request #609 from kthcloud/dev
saffronjam May 22, 2024
766aad7
Merge pull request #610 from kthcloud/dev
saffronjam May 22, 2024
0724f9b
Merge pull request #611 from kthcloud/dev
saffronjam May 22, 2024
ad48d6c
Merge pull request #612 from kthcloud/dev
saffronjam May 22, 2024
2e2db84
Merge pull request #613 from kthcloud/dev
saffronjam May 22, 2024
373a941
Merge pull request #614 from kthcloud/dev
saffronjam May 23, 2024
20370fa
Merge pull request #615 from kthcloud/dev
saffronjam May 23, 2024
9b41bac
Merge pull request #616 from kthcloud/dev
saffronjam May 23, 2024
d7cc7aa
Merge pull request #618 from kthcloud/dev
saffronjam May 24, 2024
d1a4a36
Merge pull request #620 from kthcloud/dev
saffronjam May 26, 2024
1a90c21
Merge pull request #621 from kthcloud/dev
saffronjam May 31, 2024
eafd73f
Merge pull request #624 from kthcloud/dev
saffronjam May 31, 2024
b1dc566
Merge pull request #625 from kthcloud/dev
saffronjam May 31, 2024
4c76338
Merge pull request #627 from kthcloud/dev
saffronjam May 31, 2024
c46cb8b
Merge pull request #628 from kthcloud/dev
saffronjam May 31, 2024
2c9eafa
Merge pull request #629 from kthcloud/dev
saffronjam May 31, 2024
aec0795
Merge pull request #630 from kthcloud/dev
saffronjam May 31, 2024
61802e0
Merge pull request #631 from kthcloud/dev
saffronjam May 31, 2024
f550702
Merge pull request #632 from kthcloud/dev
saffronjam May 31, 2024
109be64
Merge pull request #633 from kthcloud/dev
saffronjam Jun 1, 2024
e44cd34
Merge pull request #634 from kthcloud/dev
saffronjam Jun 1, 2024
ee2eed2
Merge pull request #636 from kthcloud/dev
saffronjam Jun 1, 2024
a3fe776
Merge pull request #637 from kthcloud/dev
saffronjam Jun 2, 2024
ee35b42
Merge pull request #638 from kthcloud/dev
saffronjam Jun 3, 2024
aefd73e
Merge pull request #642 from kthcloud/dev
saffronjam Jun 3, 2024
ebb34c4
Merge pull request #643 from kthcloud/dev
saffronjam Jun 3, 2024
bc97ecc
Merge pull request #644 from kthcloud/dev
saffronjam Jun 3, 2024
cd5fe98
Merge pull request #645 from kthcloud/dev
saffronjam Jun 3, 2024
7452062
Merge pull request #646 from kthcloud/dev
saffronjam Jun 3, 2024
376e03d
Update README.md
Phillezi Jun 5, 2024
5f6d5a7
Merge pull request #648 from Phillezi/patch-1
saffronjam Jun 7, 2024
aca144d
Merge pull request #651 from kthcloud/dev
saffronjam Jun 8, 2024
0e8f0ce
Merge pull request #653 from kthcloud/dev
saffronjam Jun 8, 2024
8814236
Merge pull request #654 from kthcloud/dev
saffronjam Jun 8, 2024
86940d5
Merge pull request #658 from kthcloud/dev
saffronjam Jun 8, 2024
5dc3dbe
Merge pull request #662 from kthcloud/dev
saffronjam Jun 9, 2024
c8caffa
Merge pull request #663 from kthcloud/dev
saffronjam Jun 9, 2024
6031f23
Merge pull request #664 from kthcloud/dev
saffronjam Jun 9, 2024
f355079
Merge pull request #665 from kthcloud/dev
saffronjam Jun 10, 2024
4662d95
Merge pull request #666 from kthcloud/dev
saffronjam Jun 13, 2024
bd7c938
Merge pull request #672 from kthcloud/dev
saffronjam Jul 27, 2024
c4fbae2
update go module name
Phillezi Sep 12, 2024
7261d64
updated OpenAPI spec to v 3.0 and added keycloak authentication to sw…
Phillezi Jan 15, 2025
31df7b6
update tygo to use new module name
Phillezi Jan 15, 2025
90e8348
add makefile with targets to simplify building and running tests
Phillezi Jan 15, 2025
8d89060
update docs to openapi 3.1.0
Phillezi Jan 20, 2025
aa1ed7d
rm @accept json annotation on GET requests so they dont have a reques…
Phillezi Jan 20, 2025
f607d69
add caching header to the docs files
Phillezi Jan 20, 2025
b24fe35
add scruot that does linting checks
Phillezi Jan 20, 2025
3cefa38
fix typo in script
Phillezi Jan 20, 2025
8218ff5
fix formatting to follow gos standard formatting
Phillezi Jan 20, 2025
d83c390
fix go vet check in script
Phillezi Jan 20, 2025
6577ae0
pass go vet
Phillezi Jan 20, 2025
6da31c3
Improve go-staticcheck results
Phillezi Jan 20, 2025
20b136e
add test target to run acc and e2e tests
Phillezi Jan 20, 2025
6d9f952
Merge pull request #1 from Phillezi/dx-updates
Phillezi Jan 20, 2025
a8d9be9
Merge pull request #2 from Phillezi/pass-linting
Phillezi Jan 20, 2025
bfe6ebf
Add target to lint the code
Phillezi Jan 20, 2025
ccfdda0
dockerfile improvements
Phillezi Jan 20, 2025
9a9f35d
update readme to reflect changes
Phillezi Jan 20, 2025
993b5a1
fix typo in openapi definition for delete storagemanager endpoint
Phillezi Jan 20, 2025
baf7b0d
Merge pull request #676 from Phillezi/main
Phillezi Jan 20, 2025
d85e48e
Update generate-build-branch.yml
Phillezi Jan 20, 2025
1c2334b
Merge pull request #677 from kthcloud/Phillezi-patch-1
Phillezi Jan 20, 2025
1d8a32e
Fix openapi basepath when being served behind proxy
Phillezi Jan 20, 2025
ae3e723
Merge branch 'kthcloud:main' into main
Phillezi Jan 20, 2025
04e01d8
Merge pull request #678 from Phillezi/main
Phillezi Jan 20, 2025
568db31
Added field for neverStale, which admins can change on deployments an…
Phillezi Jan 23, 2025
f4f9a46
Merge pull request #680 from Phillezi/main
Phillezi Jan 23, 2025
0cac3ef
added endpoint for verbose host information for troubleshooting
Phillezi Jan 23, 2025
141ae0b
added endpoint for verbose host information for troubleshooting
Phillezi Jan 23, 2025
b1bf39a
Merge branch 'main' of github.com:Phillezi/go-deploy
Phillezi Jan 23, 2025
e5e28db
rm temp test file
Phillezi Jan 23, 2025
cd51e4f
Merge pull request #681 from Phillezi/main
Phillezi Jan 23, 2025
8cd4bff
include lastSeenAt in verboseHost DTO
Phillezi Jan 30, 2025
e71a76f
Merge pull request #682 from Phillezi/main
Phillezi Jan 30, 2025
b860b58
add support for exposing multiple internal ports
Phillezi Apr 21, 2025
f2eaf83
fix persist in db + spellfix
Phillezi Apr 22, 2025
6dd7e44
fix persist on update
Phillezi Apr 22, 2025
d688632
fix typo on bson binding key
Phillezi Apr 22, 2025
0406ccb
fix typo on bson binding
Phillezi Apr 22, 2025
d354e15
fix conv to dto
Phillezi Apr 22, 2025
3d97808
only set env if it is provided
Phillezi Apr 22, 2025
639cc68
fix conversion related issues
Phillezi Apr 22, 2025
1811cdc
update tygo types
Phillezi Apr 22, 2025
2a43829
Merge pull request #685 from Phillezi/multiple-internal-ports
Phillezi Apr 22, 2025
ac2ec4e
Set filebrowser image to track a tag before breaking changes from the…
Phillezi Sep 9, 2025
c94c68f
Merge pull request #687 from kthcloud/fix-filebrowser-image-version
Phillezi Sep 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.github
bin
config.local.yml
kube
README.md
LICENSE
Makefile
28 changes: 12 additions & 16 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,24 @@ name: Build docs

on:
pull_request:
branches: [ "main" ]
branches: ["main"]
paths:
- "routers/**"
- '.github/workflows/build-docs.yml'
- ".github/workflows/build-docs.yml"

jobs:
build-docs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3

- name: Build docs
run: |
cd scripts
source ./path-cmd.sh

chmod +x ./generate-docs.sh
./generate-docs.sh

chmod +x ./convert-to-v3-docs.sh
./convert-to-v3-docs.sh

cd ..

- name: Build docs
run: |
cd scripts
source ./path-cmd.sh

chmod +x ./generate-docs.sh
./generate-docs.sh

cd ..
6 changes: 2 additions & 4 deletions .github/workflows/generate-build-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ jobs:
chmod +x ./generate-types.sh
./generate-types.sh
chmod +x ./generate-docs.sh
./generate-docs.sh
chmod +x ./convert-to-v3-docs.sh
./convert-to-v3-docs.sh
./generate-docs.sh
cd ..

echo "Cloning build branch"
Expand Down Expand Up @@ -57,4 +55,4 @@ jobs:
git push
else
echo "No changes to commit"
fi
fi
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,12 @@ cache/


# KubeConfig dir
kube/
kube/

# binary
bin
go-deploy
go-deploy.exe

# export package-lock.json
export/package-lock.json
17 changes: 11 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
############################
# STEP 1 build executable binary
############################
FROM golang:alpine AS builder
FROM --platform=$BUILDPLATFORM golang:alpine AS builder
# Install git.
RUN apk update && apk add --no-cache git=~2

# Set up working directory
WORKDIR /app
COPY . .
# Copy go.mod and go.sum separately so we only invalidate the downloading layers if we need to
COPY go.mod go.sum ./

# Fetch dependencies and build the binary
ENV GO111MODULE=on
RUN go get -d -v
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main .
RUN go mod download

# Copy the rest of the project to ensure code changes doesnt trigger re-download of all deps
COPY . .

RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -a -installsuffix cgo -o main .


############################
Expand All @@ -33,8 +38,8 @@ COPY --from=builder /app/index index
COPY --from=builder /app/docs docs

# Set environment variables and expose necessary port
ENV PORT 8080
ENV GIN_MODE release
ENV PORT=8080
ENV GIN_MODE=release
EXPOSE 8080

# Run the Go Gin binary
Expand Down
74 changes: 74 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Variables
BINARY_NAME=go-deploy
BUILD_DIR=bin
MAIN_FILE=main.go
BUILDTIMESTAMP=$(shell date -u +%Y%m%d%H%M%S)
EXT=$(if $(filter windows,$(GOOS)),.exe,)

# Targets
.PHONY: all clean build run clean docs release test acc e2e lint

all: build

build:
@echo "Building the application..."
@mkdir -p $(BUILD_DIR)
@CGO_ENABLED=0 go build -o $(BUILD_DIR)/$(BINARY_NAME)$(EXT) .
@echo "Build complete."

run: build
@echo "Running the application..."
@./$(BUILD_DIR)/$(BINARY_NAME)$(EXT)

clean:
@echo "Cleaning up..."
@rm -rf $(BUILD_DIR)
@echo "Clean complete."

docs:
@cd scripts && ./generate-docs.sh && ./generate-types.sh

release: docs
@echo "Building the application..."
@mkdir -p $(BUILD_DIR)
@CGO_ENABLED=0 go build -mod=readonly -ldflags "-w -s" -o $(BUILD_DIR)/$(BINARY_NAME)$(EXT) .
@echo "Build complete."

test: clean build
@go test ./test/acc/...
@echo "Starting go-deploy in test mode..."
@./$(BUILD_DIR)/$(BINARY_NAME)$(EXT) --mode=test & echo $$! > go_deploy.pid
@echo "Waiting for API to become ready..."
@until curl --output /dev/null --silent --head --fail http://localhost:8080/healthz; do \
echo "Waiting for API to start"; \
sleep 1; \
done
@echo "API is ready!"
@echo "Running e2e tests..."
@go test ./test/e2e/...
@if [ -f go_deploy.pid ]; then \
echo "Stopping go-deploy..."; \
kill $$(cat go_deploy.pid) && rm -f go_deploy.pid; \
fi

acc: clean build
@go test ./test/acc/...

e2e: clean build
@echo "Starting go-deploy in test mode..."
@./$(BUILD_DIR)/$(BINARY_NAME)$(EXT) --mode=test & echo $$! > go_deploy.pid
@echo "Waiting for API to become ready..."
@until curl --output /dev/null --silent --head --fail http://localhost:8080/healthz; do \
echo "Waiting for API to start"; \
sleep 1; \
done
@echo "API is ready!"
@echo "Running e2e tests..."
@go test ./test/e2e/...
@if [ -f go_deploy.pid ]; then \
echo "Stopping go-deploy..."; \
kill $$(cat go_deploy.pid) && rm -f go_deploy.pid; \
fi

lint:
@./scripts/check-lint.sh
22 changes: 6 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,35 +24,25 @@ You can install a local development environment by following the [local environm

Remember to run the tests before creating a pull request.

#### Acceptance Tests
```bash
go test ./test/acc/...
```
#### End-to-End Tests
```bash
go build -o go-deploy . # Build
./go-deploy --mode=test # Start

# Wait for the API to return 200 on /healthz
until $(curl --output /dev/null --silent --head --fail http://localhost:8080/healthz); do
echo "Waiting for API to start"
sleep 1
done
go test ./test/e2e/... # Run e2e tests
make test
# or
# make acc
# make e2e
```

## 📚 Docs

### Codebase
The code base is documented using godoc. You can view the documentation by running the documentation server locally.

1. Install godoc `go install golang.org/x/tools/cmd/godoc`
1. Install godoc `go install golang.org/x/tools/cmd/godoc@latest`
2. Run godoc `godoc -http=:6060`
3. Visit [http://localhost:6060/pkg/go-deploy/](http://localhost:6060/pkg/go-deploy/)


### API
The API is documented using OpenAPI 3.0 specification and is available at [https://api.cloud.cbh.kth.se/deploy/v2/docs/index.html](https://api.cloud.cbh.kth.se/deploy/v2/docs/index.html).
The API is documented using OpenAPI 3.1.0 specification and is available at [https://api.cloud.cbh.kth.se/deploy/v2/docs/index.html](https://api.cloud.cbh.kth.se/deploy/v2/docs/index.html).

You can also run the API locally by [setting up the local environment](scripts/local/README.md) and visiting [http://localhost:8080/v2/docs/index.html](http://localhost:8080/v2/docs/index.html).

Expand Down
53 changes: 53 additions & 0 deletions cached.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
############################
# STEP 1 build executable binary
############################
FROM --platform=$BUILDPLATFORM golang:alpine AS builder
# Install git.
RUN apk update && apk add --no-cache git=~2

# Set up working directory
WORKDIR /app
# Copy go.mod and go.sum separately so we only invalidate the downloading layers if we need to
COPY go.mod go.sum ./

# Fetch dependencies and build the binary
ENV GO111MODULE=on
RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=bind,source=go.sum,target=go.sum \
--mount=type=bind,source=go.mod,target=go.mod \
go mod download -x

# Copy the rest of the project to ensure code changes doesnt trigger re-download of all deps
COPY . .

ENV GOCACHE=/root/.cache/go-build
RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=cache,target="/root/.cache/go-build" \
CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -a -installsuffix cgo -o main .


############################
# STEP 2 build a small image
############################
FROM alpine:3

# Set up the working directory
WORKDIR /go

# Copy the binary from the builder stage
COPY --from=builder /app/main .

# Copy the "index" folder
COPY --from=builder /app/index index

# Copy the "docs" folder
COPY --from=builder /app/docs docs

# Set environment variables and expose necessary port
ENV PORT=8080
ENV GIN_MODE=release
EXPOSE 8080

# Run the Go Gin binary
ENTRYPOINT ["./main"]

18 changes: 9 additions & 9 deletions cmd/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ package cmd

import (
"context"
"go-deploy/pkg/services/cleaner"
"go-deploy/pkg/services/confirm"
"go-deploy/pkg/services/job_execute"
"go-deploy/pkg/services/job_schedule"
"go-deploy/pkg/services/logger"
metricsWorker "go-deploy/pkg/services/metrics_update"
"go-deploy/pkg/services/status_update"
"go-deploy/pkg/services/synchronize"
"go-deploy/pkg/services/system_state_poll"
"github.com/kthcloud/go-deploy/pkg/services/cleaner"
"github.com/kthcloud/go-deploy/pkg/services/confirm"
"github.com/kthcloud/go-deploy/pkg/services/job_execute"
"github.com/kthcloud/go-deploy/pkg/services/job_schedule"
"github.com/kthcloud/go-deploy/pkg/services/logger"
metricsWorker "github.com/kthcloud/go-deploy/pkg/services/metrics_update"
"github.com/kthcloud/go-deploy/pkg/services/status_update"
"github.com/kthcloud/go-deploy/pkg/services/synchronize"
"github.com/kthcloud/go-deploy/pkg/services/system_state_poll"
)

// FlagDefinition represents a definition for a flag that is passed to the program's executable.
Expand Down
27 changes: 13 additions & 14 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@ import (
"errors"
argFlag "flag"
"fmt"
"github.com/gin-gonic/gin"
"go-deploy/models/mode"
"go-deploy/pkg/config"
"go-deploy/pkg/db"
"go-deploy/pkg/db/migrate"
"go-deploy/pkg/db/resources/job_repo"
"go-deploy/pkg/intializer"
"go-deploy/pkg/log"
"go-deploy/pkg/metrics"
"go-deploy/routers"
"net/http"
"os"
"time"

"github.com/gin-gonic/gin"
"github.com/kthcloud/go-deploy/models/mode"
"github.com/kthcloud/go-deploy/pkg/config"
"github.com/kthcloud/go-deploy/pkg/db"
migrator "github.com/kthcloud/go-deploy/pkg/db/migrate"
"github.com/kthcloud/go-deploy/pkg/db/resources/job_repo"
"github.com/kthcloud/go-deploy/pkg/intializer"
"github.com/kthcloud/go-deploy/pkg/log"
"github.com/kthcloud/go-deploy/pkg/metrics"
"github.com/kthcloud/go-deploy/routers"
)

type Options struct {
Expand Down Expand Up @@ -128,10 +129,8 @@ func (app *App) Stop() {
log.Fatalln(fmt.Errorf("failed to shutdown server. details: %w", err))
}

select {
case <-ctx.Done():
log.Println("Saiting for http server to shutdown...")
}
<-ctx.Done()
log.Println("Saiting for http server to shutdown...")
}

shutdown()
Expand Down
Loading