Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Lint

on:
push:
pull_request:

jobs:
lint:
name: golangci-lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: golangci-lint
uses: golangci/golangci-lint-action@v8
with:
version: v2.4.0
62 changes: 62 additions & 0 deletions .github/workflows/mirror-gitlab.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Mirror to GitLab after CI; GitLab CI publishes the operator image to Harbor.
# Uses org secret GITLAB_TOKEN; Harbor vars inherited from dk-raas/dkai GitLab group.
name: Mirror to GitLab

on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:

permissions:
contents: read

env:
GITLAB_MIRROR_PATH: dk-raas/dkai/game-servers/windrose-operator

jobs:
verify:
name: Verify
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: golangci-lint
uses: golangci/golangci-lint-action@v8
with:
version: v2.4.0

- name: make ci
run: make ci

mirror:
name: Push to GitLab
runs-on: ubuntu-latest
needs: [verify]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Push to GitLab
env:
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git remote remove gitlab 2>/dev/null || true
git remote add gitlab "https://gitlab.com/${{ env.GITLAB_MIRROR_PATH }}.git"
git config credential.helper '!f() { echo "username=oauth2"; echo "password=${GITLAB_TOKEN}"; }; f'
git fetch gitlab main 2>/dev/null || true
git push gitlab HEAD:main --force
14 changes: 10 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,25 @@ on:

jobs:
test:
name: Run on Ubuntu
name: go test
runs-on: ubuntu-latest
steps:
- name: Clone the code
- name: Checkout
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: Running Tests
- name: Verify generated code
run: |
go mod tidy
make generate manifests
make test
git diff --exit-code

- name: go vet
run: go vet ./...

- name: go test
run: make test
88 changes: 88 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# GitLab CI: test/build the operator, publish image to Harbor
#
# Workflow: main or tag → build → publish windrose-operator to Harbor
#
# Harbor variables are inherited from the dk-raas/dkai GitLab group:
# HARBOR_REGISTRY, HARBOR_PROJECT, HARBOR_USERNAME, HARBOR_PASSWORD, DOCKER_AUTH_CONFIG

stages:
- build
- docker

variables:
IMAGE_NAME: windrose-operator
HARBOR_PROJECT: library

.build_template: &build_template
image: golang:1.25-alpine
before_script:
- cd "$CI_PROJECT_DIR"
- apk add --no-cache git make
- go version
- go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.17.2
- go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.4.0
- export PATH="$(go env GOPATH)/bin:$PATH"

build:
stage: build
<<: *build_template
script:
- go mod download
# Alpine has no CGO by default; skip -race (GitHub Actions runs race tests on ubuntu)
- make generate manifests vet lint
- go test ./... -coverprofile cover.out
- make build
artifacts:
paths:
- bin/manager
expire_in: 1 week
rules:
- if: $CI_COMMIT_BRANCH == "main"
- if: $CI_COMMIT_TAG

.docker_build_template: &docker_build_template
stage: docker
image:
name: moby/buildkit:rootless
entrypoint: [""]
needs: [build]
rules:
- if: $CI_COMMIT_BRANCH == "main"
- if: $CI_COMMIT_TAG
tags:
- kubernetes

publish-windrose-operator:
<<: *docker_build_template
script:
- |
if [ -z "$HARBOR_REGISTRY" ] || [ -z "$HARBOR_PROJECT" ]; then
echo "❌ Error: HARBOR_REGISTRY or HARBOR_PROJECT not set"
echo "HARBOR_REGISTRY: ${HARBOR_REGISTRY:-NOT SET}"
echo "HARBOR_PROJECT: ${HARBOR_PROJECT:-NOT SET}"
exit 1
fi

HARBOR_AUTH_USER="${HARBOR_USERNAME:-${HARBOR_USER:-}}"
if [ -n "$HARBOR_AUTH_USER" ] && [ -n "${HARBOR_PASSWORD:-}" ]; then
AUTH=$(printf '%s' "$HARBOR_AUTH_USER:$HARBOR_PASSWORD" | base64 | tr -d '\n')
mkdir -p ~/.docker
echo "{\"auths\":{\"$HARBOR_REGISTRY\":{\"auth\":\"$AUTH\"}}}" > ~/.docker/config.json
fi

echo "Building windrose-operator image..."
echo "Registry: $HARBOR_REGISTRY/$HARBOR_PROJECT/$IMAGE_NAME"

IMAGE_TAG="${CI_COMMIT_SHORT_SHA:-$CI_PIPELINE_ID}"
OUTPUT_FLAGS="--output type=image,name=$HARBOR_REGISTRY/$HARBOR_PROJECT/$IMAGE_NAME:latest,push=true"
OUTPUT_FLAGS="$OUTPUT_FLAGS --output type=image,name=$HARBOR_REGISTRY/$HARBOR_PROJECT/$IMAGE_NAME:$IMAGE_TAG,push=true"

if [ -n "$CI_COMMIT_TAG" ]; then
OUTPUT_FLAGS="$OUTPUT_FLAGS --output type=image,name=$HARBOR_REGISTRY/$HARBOR_PROJECT/$IMAGE_NAME:$CI_COMMIT_TAG,push=true"
fi

buildctl-daemonless.sh build \
--frontend dockerfile.v0 \
--local context=. \
--local dockerfile=. \
$OUTPUT_FLAGS
40 changes: 40 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
version: "2"
run:
allow-parallel-runners: true
timeout: 5m
linters:
default: none
enable:
- copyloopvar
- errcheck
- goconst
- govet
- ineffassign
- misspell
- revive
- staticcheck
- unconvert
- unused
settings:
revive:
rules:
- name: comment-spacings
- name: import-shadowing
exclusions:
generated: lax
rules:
- linters:
- revive
path: api/v1alpha1/zz_generated.deepcopy.go
paths:
- third_party$
- bin$
formatters:
enable:
- gofmt
- goimports
exclusions:
generated: lax
paths:
- third_party$
- bin$
13 changes: 12 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,18 @@ build: generate

.PHONY: test
test: generate
go test ./... -coverprofile cover.out
go test ./... -race -coverprofile cover.out

.PHONY: lint
lint:
golangci-lint run ./...

.PHONY: lint-fix
lint-fix:
golangci-lint run --fix ./...

.PHONY: ci
ci: generate manifests vet lint test

.PHONY: run
run: manifests generate
Expand Down
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,19 +214,24 @@ docker run --user ue_user --name WindroseServer \

## Development

Requires Go 1.25+.
Requires Go 1.25+ and [golangci-lint](https://golangci-lint.run/) for local linting.

```shell
make generate manifests # CRD, RBAC, deepcopy
make test
make build # bin/manager
make run # local controller
make test # unit tests with race detector
make lint # golangci-lint
make ci # generate, vet, lint, and test
make build # bin/manager
make run # local controller
make docker-build IMG=harbor.dataknife.net/library/windrose-operator:latest
```

CI runs lint and tests on every push and pull request.

## Related projects

- [DataKnifeAI/windrose-server-k8s](https://github.com/DataKnifeAI/windrose-server-k8s) — Wine-based image and Kustomize manifests
- [GitLab mirror](docs/GITLAB_MIRROR.md) — CI builds `harbor.dataknife.net/library/windrose-operator`
- [Windrose Dedicated Server Guide](https://playwindrose.com/dedicated-server-guide)
- [windroseserver/windroseserver on Docker Hub](https://hub.docker.com/r/windroseserver/windroseserver)

Expand Down
2 changes: 1 addition & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import (
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"

egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1"
windrosev1alpha1 "github.com/DataKnifeAI/windrose-operator/api/v1alpha1"
"github.com/DataKnifeAI/windrose-operator/internal/controller"
egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1"
)

var (
Expand Down
84 changes: 84 additions & 0 deletions docs/GITLAB_MIRROR.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# GitLab mirror and Harbor publish

The operator image is built and pushed to Harbor from GitLab CI on the mirror at
`gitlab.com/dk-raas/dkai/game-servers/windrose-operator`.

GitHub Actions on `main` runs verification, then mirrors the repository to GitLab.
GitLab CI runs tests, builds the Docker image, and publishes to
`harbor.dataknife.net/library/windrose-operator`.

## Credentials (already configured at org/group level)

No per-repo secrets or CI variables are required for normal operation.

### GitHub — org secret `GITLAB_TOKEN`

The DataKnifeAI organization provides `GITLAB_TOKEN` to repositories that mirror
to GitLab. Verify access for this repo:

```bash
gh api repos/DataKnifeAI/windrose-operator/actions/organization-secrets
```

Expected: `GITLAB_TOKEN` in the `secrets` list.

The **Mirror to GitLab** workflow reads `${{ secrets.GITLAB_TOKEN }}` on pushes
to `main`. Sibling repos (for example `windrose-server-k8s`) use the same
org secret successfully.

### GitLab — group variables on `dk-raas/dkai`

Harbor and registry credentials are inherited from the parent group. Verify:

```bash
glab variable list --group dk-raas/dkai
```

Expected variables include `HARBOR_REGISTRY`, `HARBOR_PROJECT`, `HARBOR_USERNAME`,
`HARBOR_PASSWORD`, and `DOCKER_AUTH_CONFIG`. The `game-servers` subgroup and
`windrose-operator` project do not need their own copies.

Non-secret values (safe to print):

```bash
glab variable get HARBOR_REGISTRY --group dk-raas/dkai
glab variable get HARBOR_PROJECT --group dk-raas/dkai
```

## Authenticate GitLab CLI (`glab`)

For manual pushes or project management:

```bash
glab auth login --hostname gitlab.com
glab auth status
```

## Mirror project

https://gitlab.com/dk-raas/dkai/game-servers/windrose-operator

Created once with:

```bash
glab repo create windrose-operator \
--group dk-raas/dkai/game-servers \
--private \
--description "Mirror of DataKnifeAI/windrose-operator — CI builds operator image to Harbor"
```

## Image tags

Pushes produce `:latest`, `:<commit-sha>`, and `:<git-tag>` when applicable.

## Manual mirror push

If GitHub Actions has not run yet:

```bash
git remote add gitlab https://gitlab.com/dk-raas/dkai/game-servers/windrose-operator.git
git push gitlab main
```

Note: `main` on GitLab may be branch-protected; prefer merging to GitHub `main`
and letting the mirror workflow sync.
Loading
Loading