Skip to content

Commit

Permalink
docs(api): auto generate via annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
haveachin committed Jan 31, 2023
1 parent cb5c4fb commit 9850dee
Show file tree
Hide file tree
Showing 14 changed files with 180 additions and 333 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3
- name: Build
run: go build -ldflags "-X main.version=${{ github.ref_name }}" -o main .
run: |
make swag
go build -ldflags "-X main.version=${{ github.ref_name }}" -o main .
build-container:
name: Build Container
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@
/dev

# Generated files
*_mock_test.go
*_mock_test.go

# Generated Swagger Docs
api/swagger.yaml
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,8 @@ run:

plantuml:
plantuml -tsvg *.md docs/*.md docs/plugins/*.md docs/*.plantuml docs/plugins/*.plantuml

swag:
go install github.com/swaggo/swag/cmd/swag@latest
swag fmt -g internal/plugin/api/api.go
swag init -o api/ -g internal/plugin/api/api.go -ot yaml
4 changes: 2 additions & 2 deletions api/embed.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ package api

import _ "embed"

//go:embed openapi.yaml
var OpenAPISpecs []byte
//go:embed swagger.yaml
var SwaggerSpecs []byte
254 changes: 0 additions & 254 deletions api/openapi.yaml

This file was deleted.

1 change: 1 addition & 0 deletions build/package/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ ARG VERSION
COPY . /infrared
WORKDIR /infrared
ENV GO111MODULE=on
RUN make swag
RUN CGO_ENABLED=0 go build -ldflags "-X main.version=$VERSION" -o /main .

FROM alpine:latest
Expand Down
6 changes: 4 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ func onConfigChange(cfg map[string]any) {
mu.Lock()
defer mu.Unlock()

logger.Info("reloading configs")

javaPrxCfg, err := java.NewProxyConfigFromMap(cfg)
if err != nil {
logger.Error("failed to load java config",
Expand All @@ -245,7 +247,7 @@ func onConfigChange(cfg map[string]any) {
infrared.BedrockEdition: bedrockPrxCfg,
}

logger.Debug("Reloading proxies")
logger.Debug("reloading proxies")
for n, p := range proxies {
if err := p.Reload(prxCfgs[n]); err != nil {
logger.Error("failed to reload proxy",
Expand All @@ -254,6 +256,6 @@ func onConfigChange(cfg map[string]any) {
}
}

logger.Debug("Reloading plugins")
logger.Debug("reloading plugins")
pluginManager.ReloadPlugins(cfg)
}
8 changes: 4 additions & 4 deletions configs/proxies/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ defaults:
# The message that is displayed to a client when they try to connect via an invalid domain.
#
serverNotFoundMessage: Sorry {{username}}, but a server for {{serverDomain}} does not exist.
serverNotFoundMessage: Sorry {{username}}, but a server for {{requestedAddress}} does not exist.

# Servers are server configurations that redirect players to a minecraft server.
#
Expand All @@ -65,7 +65,7 @@ defaults:
listener:
# The message that is displayed to a client when they try to connect via an invalid domain.
#
serverNotFoundMessage: Sorry {{username}}, but {{serverDomain}} was not found.
serverNotFoundMessage: Sorry {{username}}, but {{requestedAddress}} was not found.

# The Java Edition has a different approach to handling status pings, than the Bedrock Edition.
# This makes it possible to display a custom message to clients if the domain that they want
Expand All @@ -81,7 +81,7 @@ defaults:
iconPath: icons/default.png
motd: |
Powered by Infrared
§c{{serverDomain}} was not found.
§c{{requestedAddress}} was not found.
server:
overrideAddress: true
dialTimeout: 1s
Expand All @@ -97,7 +97,7 @@ defaults:
iconPath: icons/default.png
motd: |
Powered by Infrared
§6Server at {{serverDomain}} is not responding.
§6Server at {{requestedAddress}} is not responding.
# Infrared caches the server ping response so that status pings don't spam the minecraft server.
# This is the Time To Live of the cache. Set this to <=0 to disable caching.
Expand Down
4 changes: 4 additions & 0 deletions deployments/docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ services:
- 25565:25565/tcp
# Port for Bedrock Edition
- 19132:19132/udp
# API
#- 8080:8080/tcp
# Prometheus
#- 9070:9070/tcp
volumes:
- ./data/infrared:/infrared
#- /var/run/docker.sock:/var/run/docker.sock:ro
Expand Down
2 changes: 2 additions & 0 deletions deployments/docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ services:
ports:
- 25565:25565/tcp
- 19132:19132/udp
- 8080:8080/tcp
- 9070:9070/tcp
volumes:
- ../dev:/infrared
- /var/run/docker.sock:/var/run/docker.sock:ro
Expand Down
Loading

0 comments on commit 9850dee

Please sign in to comment.