diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..302cfc4 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +indent_size = 4 +indent_style = tab + +[*.{md,yml,yaml}] +indent_size = 2 +indent_style = space diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 35ec746..c8bcff2 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -15,28 +15,8 @@ updates: - "nginxinc/kic" - package-ecosystem: "docker" - directory: "/grpc" - schedule: - interval: weekly - reviewers: - - "nginxinc/kic" - - - package-ecosystem: "docker" - directory: "/tcp" - schedule: - interval: weekly - reviewers: - - "nginxinc/kic" - - - package-ecosystem: "docker" - directory: "/udp" - schedule: - interval: weekly - reviewers: - - "nginxinc/kic" - - - package-ecosystem: "docker" - directory: "/nap-dos" + directories: + - "**/*" schedule: interval: weekly reviewers: diff --git a/.github/labeler.yml b/.github/labeler.yml index fd2e4b6..408aaa6 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -1,22 +1,22 @@ change: - - head-branch: ['^change/'] + - head-branch: ["^change/"] enhancement: - - head-branch: ['^feature/', '^feat/', '^enhancement/', '^enh/'] + - head-branch: ["^feature/", "^feat/", "^enhancement/", "^enh/"] bug: - - head-branch: ['^fix/', '^bug/'] + - head-branch: ["^fix/", "^bug/"] chore: - - head-branch: ['^chore/'] + - head-branch: ["^chore/"] documentation: - - head-branch: ['^docs/', '^doc/'] - - changed-files: '**/*.md' + - head-branch: ["^docs/", "^doc/"] + - changed-files: + - any-glob-to-any-file: "**/*.md" dependencies: - - head-branch: ['^deps/', '^dep/', '^dependabot/', 'pre-commit-ci-update-config'] - - changed-files: ['go.mod', 'go.sum'] - -helm_chart: - - changed-files: ['deployments/helm-chart/**/*'] + - head-branch: + ["^deps/", "^dep/", "^dependabot/", "pre-commit-ci-update-config"] + - changed-files: + - any-glob-to-any-file: ["go.mod", "go.sum"] diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml deleted file mode 100644 index 8cf50f9..0000000 --- a/.github/workflows/ci.yaml +++ /dev/null @@ -1,253 +0,0 @@ -name: CI - -on: - push: - branches: - - main - tags: - - 'v[0-9]+.[0-9]+.[0-9]+' - pull_request: - branches: - - main - -env: - PLATFORMS: "linux/amd64, linux/arm64, linux/s390x, linux/ppc64le" - -concurrency: - group: ${{ github.ref_name }}-ci - cancel-in-progress: true - -jobs: - build: - name: Build Binaries TCP/UDP - runs-on: ubuntu-22.04 - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Setup Golang Environment - uses: actions/setup-go@v5 - with: - go-version-file: go.mod - - name: Build binary - uses: goreleaser/goreleaser-action@v6 - with: - version: latest - args: build --clean ${{ !startsWith(github.ref, 'refs/tags/') && '--snapshot' || '' }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GOPATH: ${{ needs.checks.outputs.go_path }} - - - name: Store Artifacts in Cache - uses: actions/cache@v4 - with: - path: ${{ github.workspace }}/dist - key: test-containers-${{ github.run_id }}-${{ github.run_number }} - - build-docker: - name: Build Docker Images TCP/UDP - runs-on: ubuntu-22.04 - needs: build - strategy: - matrix: - type: [tcp, udp] - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - name: Fetch Cached Artifacts - uses: actions/cache@v4 - with: - path: ${{ github.workspace }}/dist - key: test-containers-${{ github.run_id }}-${{ github.run_number }} - - name: Setup QEMU - uses: docker/setup-qemu-action@v3 - with: - platforms: arm64,ppc64le,s390x - if: github.event_name != 'pull_request' - - - name: Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - if: github.event_name != 'pull_request' - - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - images: | - ghcr.io/nginxinc/kic-test-${{ matrix.type }}-server - tags: | - type=edge - type=ref,event=pr - type=semver,pattern={{version}} - labels: | - org.opencontainers.image.description=KIC Test ${{ matrix.type }} Server - - - name: Build Docker image - uses: docker/build-push-action@v6 - id: build-push - with: - file: ${{ matrix.type }}/Dockerfile - context: '.' - cache-from: type=gha,scope=${{ matrix.type }} - cache-to: type=gha,scope=${{ matrix.type }},mode=max - target: goreleaser - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - platforms: ${{ github.event_name != 'pull_request' && env.PLATFORMS || '' }} - load: ${{ github.event_name == 'pull_request' }} - push: ${{ github.event_name != 'pull_request' }} - pull: true - no-cache: ${{ github.event_name != 'pull_request' }} - - - name: Run Grype vulnerability scanner - uses: anchore/scan-action@v4 - continue-on-error: true - id: scan - with: - image: ghcr.io/nginxinc/kic-test-${{ matrix.type }}-server:${{ steps.meta.outputs.version }} - only-fixed: true - add-cpes-if-none: true - - name: upload Anchore scan SARIF report - uses: github/codeql-action/upload-sarif@v3 - with: - sarif_file: ${{ steps.scan.outputs.sarif }} - - build-grpc: - name: Build Docker Image gRPC - runs-on: ubuntu-22.04 - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - - name: Setup QEMU - uses: docker/setup-qemu-action@v3 - with: - platforms: arm64,ppc64le,s390x - if: github.event_name != 'pull_request' - - - name: Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - if: github.event_name != 'pull_request' - - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - images: | - ghcr.io/nginxinc/kic-test-grpc-server - tags: | - type=edge - type=ref,event=pr - type=semver,pattern={{version}} - labels: | - org.opencontainers.image.description=KIC Test gRPC Server - - - name: Build Docker image - uses: docker/build-push-action@v6 - id: build-push - with: - file: grpc/Dockerfile - context: '.' - cache-from: type=gha,scope=grpc - cache-to: type=gha,scope=grpc,mode=max - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - platforms: ${{ github.event_name != 'pull_request' && env.PLATFORMS || '' }} - load: ${{ github.event_name == 'pull_request' }} - push: ${{ github.event_name != 'pull_request' }} - pull: true - no-cache: ${{ github.event_name != 'pull_request' }} - - - name: Run Grype vulnerability scanner - uses: anchore/scan-action@v4 - continue-on-error: true - id: scan - with: - image: ghcr.io/nginxinc/kic-test-grpc-server:${{ steps.meta.outputs.version }} - only-fixed: true - add-cpes-if-none: true - - name: upload Anchore scan SARIF report - uses: github/codeql-action/upload-sarif@v3 - with: - sarif_file: ${{ steps.scan.outputs.sarif }} - - build-dos-server: - name: Build Docker Image DOS Server - runs-on: ubuntu-22.04 - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - - name: Setup QEMU - uses: docker/setup-qemu-action@v3 - with: - platforms: arm64,ppc64le,s390x - if: github.event_name != 'pull_request' - - - name: Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - if: github.event_name != 'pull_request' - - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - images: | - ghcr.io/nginxinc/kic-test-dos-server - tags: | - type=edge - type=ref,event=pr - type=semver,pattern={{version}} - labels: | - org.opencontainers.image.description=KIC Test DOS Server - - - name: Build Docker image - uses: docker/build-push-action@v6 - id: build-push - with: - file: nap-dos/Dockerfile - context: '.' - cache-from: type=gha,scope=dos-server - cache-to: type=gha,scope=dos-server,mode=max - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - platforms: ${{ github.event_name != 'pull_request' && env.PLATFORMS || '' }} - load: ${{ github.event_name == 'pull_request' }} - push: ${{ github.event_name != 'pull_request' }} - pull: true - no-cache: ${{ github.event_name != 'pull_request' }} - - - name: Run Grype vulnerability scanner - uses: anchore/scan-action@v4 - continue-on-error: true - id: scan - with: - image: ghcr.io/nginxinc/kic-test-dos-server:${{ steps.meta.outputs.version }} - only-fixed: true - add-cpes-if-none: true - - name: upload Anchore scan SARIF report - uses: github/codeql-action/upload-sarif@v3 - with: - sarif_file: ${{ steps.scan.outputs.sarif }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..28f9b96 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,276 @@ +name: CI + +on: + push: + branches: + - main + tags: + - "v[0-9]+.[0-9]+.[0-9]+" + pull_request: + branches: + - main + +env: + PLATFORMS: "linux/amd64, linux/arm64, linux/s390x, linux/ppc64le" + +concurrency: + group: ${{ github.ref_name }}-ci + cancel-in-progress: true + +jobs: + build: + name: Build Binaries TCP/UDP + runs-on: ubuntu-22.04 + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Golang Environment + uses: actions/setup-go@v5 + with: + go-version: stable + + - name: Determine GOPATH + id: go + run: echo "go_path=$(go env GOPATH)" >> $GITHUB_OUTPUT + + - name: Build binary + uses: goreleaser/goreleaser-action@v6 + with: + version: latest + args: build --clean ${{ !startsWith(github.ref, 'refs/tags/') && '--snapshot' || '' }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GOPATH: ${{ steps.go.outputs.go_path }} + + - name: Store Artifacts in Cache + uses: actions/cache@v4 + with: + path: ${{ github.workspace }}/dist + key: test-containers-${{ github.run_id }}-${{ github.run_number }} + + build-docker: + name: Build Docker Images TCP/UDP + runs-on: ubuntu-22.04 + needs: build + strategy: + matrix: + type: [tcp, udp] + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Fetch Cached Artifacts + uses: actions/cache@v4 + with: + path: ${{ github.workspace }}/dist + key: test-containers-${{ github.run_id }}-${{ github.run_number }} + + - name: Setup QEMU + uses: docker/setup-qemu-action@v3 + with: + platforms: arm64,ppc64le,s390x + if: github.event_name != 'pull_request' + + - name: Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + if: github.event_name != 'pull_request' + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ghcr.io/nginxinc/kic-test-${{ matrix.type }}-server + tags: | + type=edge + type=ref,event=pr + type=semver,pattern={{version}} + labels: | + org.opencontainers.image.description=KIC Test ${{ matrix.type }} Server + + - name: Build Docker image + uses: docker/build-push-action@v6 + id: build-push + with: + file: ${{ matrix.type }}/Dockerfile + context: "." + cache-from: type=gha,scope=${{ matrix.type }} + cache-to: type=gha,scope=${{ matrix.type }},mode=max + target: goreleaser + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: ${{ github.event_name != 'pull_request' && env.PLATFORMS || '' }} + load: ${{ github.event_name == 'pull_request' }} + push: ${{ github.event_name != 'pull_request' }} + pull: true + no-cache: ${{ github.event_name != 'pull_request' }} + + - name: Run Grype vulnerability scanner + uses: anchore/scan-action@v4 + continue-on-error: true + id: scan + with: + image: ghcr.io/nginxinc/kic-test-${{ matrix.type }}-server:${{ steps.meta.outputs.version }} + only-fixed: true + add-cpes-if-none: true + - name: upload Anchore scan SARIF report + uses: github/codeql-action/upload-sarif@v3 + with: + sarif_file: ${{ steps.scan.outputs.sarif }} + + build-grpc: + name: Build Docker Image gRPC + runs-on: ubuntu-22.04 + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Setup QEMU + uses: docker/setup-qemu-action@v3 + with: + platforms: arm64,ppc64le,s390x + if: github.event_name != 'pull_request' + + - name: Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + if: github.event_name != 'pull_request' + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ghcr.io/nginxinc/kic-test-grpc-server + tags: | + type=edge + type=ref,event=pr + type=semver,pattern={{version}} + labels: | + org.opencontainers.image.description=KIC Test gRPC Server + + - name: Build Docker image + uses: docker/build-push-action@v6 + id: build-push + with: + file: grpc/Dockerfile + context: "." + cache-from: type=gha,scope=grpc + cache-to: type=gha,scope=grpc,mode=max + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: ${{ github.event_name != 'pull_request' && env.PLATFORMS || '' }} + load: ${{ github.event_name == 'pull_request' }} + push: ${{ github.event_name != 'pull_request' }} + pull: true + no-cache: ${{ github.event_name != 'pull_request' }} + + - name: Run Grype vulnerability scanner + uses: anchore/scan-action@v4 + continue-on-error: true + id: scan + with: + image: ghcr.io/nginxinc/kic-test-grpc-server:${{ steps.meta.outputs.version }} + only-fixed: true + add-cpes-if-none: true + - name: upload Anchore scan SARIF report + uses: github/codeql-action/upload-sarif@v3 + with: + sarif_file: ${{ steps.scan.outputs.sarif }} + + build-dos-server: + name: Build Docker Image DOS Server + runs-on: ubuntu-22.04 + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Setup QEMU + uses: docker/setup-qemu-action@v3 + with: + platforms: arm64,ppc64le,s390x + if: github.event_name != 'pull_request' + + - name: Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + if: github.event_name != 'pull_request' + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ghcr.io/nginxinc/kic-test-dos-server + tags: | + type=edge + type=ref,event=pr + type=semver,pattern={{version}} + labels: | + org.opencontainers.image.description=KIC Test DOS Server + + - name: Build Docker image + uses: docker/build-push-action@v6 + id: build-push + with: + file: nap-dos/Dockerfile + context: "." + cache-from: type=gha,scope=dos-server + cache-to: type=gha,scope=dos-server,mode=max + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: ${{ github.event_name != 'pull_request' && env.PLATFORMS || '' }} + load: ${{ github.event_name == 'pull_request' }} + push: ${{ github.event_name != 'pull_request' }} + pull: true + no-cache: ${{ github.event_name != 'pull_request' }} + + - name: Run Grype vulnerability scanner + uses: anchore/scan-action@v4 + continue-on-error: true + id: scan + with: + image: ghcr.io/nginxinc/kic-test-dos-server:${{ steps.meta.outputs.version }} + only-fixed: true + add-cpes-if-none: true + - name: upload Anchore scan SARIF report + uses: github/codeql-action/upload-sarif@v3 + with: + sarif_file: ${{ steps.scan.outputs.sarif }} + + draft-release: + name: Create Release Draft + runs-on: ubuntu-22.04 + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Create/Update Draft + uses: lucacome/draft-release@v1.1.1 + with: + minor-label: "enhancement" + major-label: "change" + collapse-after: 20 + publish: ${{ github.ref_type == 'tag' }} diff --git a/.github/workflows/draft-release.yaml b/.github/workflows/draft-release.yaml deleted file mode 100644 index d1f9fcc..0000000 --- a/.github/workflows/draft-release.yaml +++ /dev/null @@ -1,21 +0,0 @@ -name: Create Release Draft - -on: - push: - branches: - - main - -jobs: - - draft-release: - name: Create Release Draft - runs-on: ubuntu-22.04 - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - - name: Create/Update Draft - uses: lucacome/draft-release@v1.1.1 - with: - minor-label: 'enhancement' - major-label: 'change' diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 2862bde..a77851e 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -9,9 +9,10 @@ jobs: triage: permissions: contents: read - pull-requests: write - runs-on: ubuntu-22.04 + pull-requests: write # for actions/labeler to add labels + runs-on: ubuntu-24.04 steps: - - uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9 # v5.0.0-alpha.1 + - uses: actions/labeler@v5.0.0 with: repo-token: "${{ secrets.GITHUB_TOKEN }}" + sync-labels: true diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index c7ce58c..9ec3352 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -14,7 +14,6 @@ concurrency: cancel-in-progress: true jobs: - lint: name: Lint runs-on: ubuntu-22.04 diff --git a/.golangci.yml b/.golangci.yml index 6727117..88a7206 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -14,9 +14,9 @@ linters-settings: - name: error-strings - name: errorf - name: exported - - name: if-return - name: increment-decrement - name: indent-error-flow + - name: package-comments - name: range - name: receiver-naming - name: redefines-builtin-id @@ -27,38 +27,66 @@ linters-settings: - name: unused-parameter - name: var-declaration - name: var-naming - gocyclo: - min-complexity: 15 - + govet: + enable-all: true linters: - enable: + enable: + - asasalint - asciicheck + - bidichk + - contextcheck + - dupword + - durationcheck + - err113 + - errcheck + - errchkjson + - errname - errorlint + - exportloopref + - fatcontext + - forcetypeassert + - gocheckcompilerdirectives + - gochecksumtype + - gocritic - gocyclo + - godot - gofmt - gofumpt - goimports - gosec - gosimple + - gosmopolitan - govet - ineffassign + - intrange - makezero - misspell + - musttag - nilerr - noctx + - nolintlint + - perfsprint + - prealloc - predeclared - - promlinter + - reassign - revive - staticcheck + - stylecheck + - tagalign + - tenv + - thelper + - tparallel - typecheck - unconvert - unparam - unused + - usestdlibvars - wastedassign - disable-all: true + - whitespace + - wrapcheck + disable-all: true issues: max-issues-per-linter: 0 max-same-issues: 0 - exclude-use-default: false run: timeout: 5m diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 47d1bad..7639233 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -1,3 +1,4 @@ +version: 2 env: - CGO_ENABLED=0 @@ -39,3 +40,6 @@ builds: - all=-trimpath={{.Env.GOPATH}} ldflags: - -s -w -X main.version={{.Version}} + +changelog: + disable: true diff --git a/.markdownlint-cli2.yaml b/.markdownlint-cli2.yaml new file mode 100644 index 0000000..1932609 --- /dev/null +++ b/.markdownlint-cli2.yaml @@ -0,0 +1,18 @@ +# Rule configuration. +# For rule descriptions and how to fix: https://github.com/DavidAnson/markdownlint/tree/main#rules--aliases +config: + ul-style: + style: dash + no-duplicate-heading: + siblings_only: true + line-length: + line_length: 120 + code_blocks: false + tables: false + +# Define glob expressions to ignore +ignores: + - ".github/" + +# Fix any fixable errors +fix: true diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..e314b03 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,60 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + args: [--allow-multiple-documents] + - id: check-ast + - id: check-added-large-files + - id: check-merge-conflict + - id: check-shebang-scripts-are-executable + - id: check-executables-have-shebangs + - id: check-symlinks + - id: check-case-conflict + - id: check-vcs-permalinks + - id: mixed-line-ending + args: [--fix=lf] + - id: name-tests-test + args: [--pytest-test-first] + exclude: ^(tests/settings.py) + - id: no-commit-to-branch + - id: requirements-txt-fixer + - id: fix-byte-order-marker + - id: detect-private-key + + - repo: https://github.com/golangci/golangci-lint + rev: v1.60.1 + hooks: + - id: golangci-lint-full + + - repo: https://github.com/asottile/pyupgrade + rev: v3.17.0 + hooks: + - id: pyupgrade + + - repo: https://github.com/PyCQA/isort + rev: 5.13.2 + hooks: + - id: isort + + - repo: https://github.com/psf/black + rev: 24.8.0 + hooks: + - id: black + + - repo: https://github.com/DavidAnson/markdownlint-cli2 + rev: v0.13.0 + hooks: + - id: markdownlint-cli2 + + - repo: https://github.com/adrienverge/yamllint.git + rev: v1.35.1 + hooks: + - id: yamllint + +ci: + skip: [golangci-lint-full] diff --git a/.yamllint.yaml b/.yamllint.yaml new file mode 100644 index 0000000..7d0320c --- /dev/null +++ b/.yamllint.yaml @@ -0,0 +1,22 @@ +--- +yaml-files: + - "*.yaml" + - "*.yml" + +ignore-from-file: .gitignore + +extends: default + +rules: + comments: + min-spaces-from-content: 1 + comments-indentation: enable + document-start: disable + empty-values: enable + line-length: + max: 120 + ignore: | + .goreleaser.yml + .github/ + truthy: + check-keys: false diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000..9934150 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1 @@ +* @nginxinc/kic diff --git a/README.md b/README.md index 6c67f67..307f7dd 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,23 @@ -## KIC Test Containers +# KIC Test Containers This repository contains the Dockerfiles and code for the test containers used in the [Kubernetes Ingress Controller](https://github.com/nginxinc/kubernetes-ingress). -### Building the containers for local testing +## Building the containers for local testing + For each container, run the following command from the root of the repository: -``` + +```console docker build -t -f /Dockerfile . ``` +Alternatively, you can use the `Makefile` to build the containers. For example, to build the `grpc-server` container, +run the following command from the root of the repository: -Alternatively, you can use the `Makefile` to build the containers. For example, to build the `grpc-server` container, run the following command from the root of the repository: -``` +```console make grpc-server ``` -### Publishing the containers -The containers are published to the [NGINX GitHub Container Registry](https://github.com/orgs/nginxinc/packages?repo_name=kic-test-containers) when a new tag is created in this repository. You can see the packages on the right side of this page. +## Publishing the containers + +The containers are published to the [NGINX GitHub Container Registry](https://github.com/orgs/nginxinc/packages?repo_name=kic-test-containers) +when a new tag is created in this repository. You can see the packages on the right side of this page. diff --git a/go.mod b/go.mod index c54002c..f7c245f 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ module github.com/nginxinc/kic-test-containers -go 1.22 +go 1.23.0 diff --git a/grpc/Dockerfile b/grpc/Dockerfile index 9947548..0338e94 100644 --- a/grpc/Dockerfile +++ b/grpc/Dockerfile @@ -1,7 +1,7 @@ -# syntax=docker/dockerfile:1.5 -FROM golang:1.23 as builder +# syntax=docker/dockerfile:1.9 +FROM golang:1.23 AS builder -RUN git clone -b v1.63.0 --depth 1 https://github.com/grpc/grpc-go +RUN git clone -b v1.65.0 --depth 1 https://github.com/grpc/grpc-go WORKDIR /go/grpc-go/examples RUN CGO_ENABLED=0 go build -C helloworld/greeter_server -o /greeter_server diff --git a/grpc/README.md b/grpc/README.md index 060b2d1..2af996f 100644 --- a/grpc/README.md +++ b/grpc/README.md @@ -1,5 +1,5 @@ # gRPC Server -From https://github.com/grpc/grpc-go/tree/master/examples/helloworld/greeter_server +From The server runs on port 50051. diff --git a/nap-dos/Dockerfile b/nap-dos/Dockerfile index 6248bbf..ea8091e 100644 --- a/nap-dos/Dockerfile +++ b/nap-dos/Dockerfile @@ -1,3 +1,4 @@ +# syntax=docker/dockerfile:1.9 FROM python:3.12-alpine COPY nap-dos/flaskserver.py . diff --git a/tcp/Dockerfile b/tcp/Dockerfile index d7aafb1..5789bce 100644 --- a/tcp/Dockerfile +++ b/tcp/Dockerfile @@ -1,12 +1,12 @@ -# syntax=docker/dockerfile:1.5 -FROM golang:1.23-alpine as builder +# syntax=docker/dockerfile:1.9 +FROM golang:1.23-alpine AS builder WORKDIR /go/src/github.com/nginxinc/kic-test-containers/ COPY tcp/main.go ./tcp/ COPY go.mod utils.go ./ RUN CGO_ENABLED=0 GOOS=linux go build -o /main ./tcp/ -FROM scratch as goreleaser +FROM scratch AS goreleaser ARG TARGETARCH COPY dist/tcp_linux_${TARGETARCH}*/main /app/main diff --git a/tcp/README.md b/tcp/README.md index 38a789b..ece5667 100644 --- a/tcp/README.md +++ b/tcp/README.md @@ -1,24 +1,27 @@ -## TCP Server +# TCP Server A Go server that accepts TCP requests and responds with the local address of the connection. -### Description +## Description + If the server is run inside a Docker container, the local address is the IP of the docker container. This is useful for distinguishing between instances of Docker containers. This server is used by the python tests in the [load balancing tests](../suite/test_transport_server_tcp_load_balance.py). -### Config +## Config + The default port the server listens to is `3333`. The server takes a single argument, `port`, to allow the port to be overridden. ## Making changes - * Test the change: - * Use the minikube registry ```$ eval $(minikube docker-env)``` - * Build the docker image from the root of the project ```docker build -t tcp-server .``` - * Update the [service yaml](https://github.com/nginxinc/kubernetes-ingress/blob/main/tests/data/transport-server-tcp-load-balance/standard/service_deployment.yaml) to use the local version ```-> imagePullPolicy: Never``` - * Test the changes - * Publish the tcp-server change - * Open a PR with the changes - * Once the PR is approved merge it to the main branch - * Create a new tag for the commit, this will start the pipeline and publish the new tcp-server image +- Test the change: + - Use the minikube registry ```$ eval $(minikube docker-env)``` + - Build the docker image from the root of the project ```docker build -t tcp-server .``` + - Update the [service yaml](https://github.com/nginxinc/kubernetes-ingress/blob/main/tests/data/transport-server-tcp-load-balance/standard/service_deployment.yaml) + to use the local version ```-> imagePullPolicy: Never``` + - Test the changes +- Publish the tcp-server change + - Open a PR with the changes + - Once the PR is approved merge it to the main branch + - Create a new tag for the commit, this will start the pipeline and publish the new tcp-server image diff --git a/udp/Dockerfile b/udp/Dockerfile index d10941e..7e27dbc 100644 --- a/udp/Dockerfile +++ b/udp/Dockerfile @@ -1,12 +1,12 @@ -# syntax=docker/dockerfile:1.5 -FROM golang:1.23-alpine as builder +# syntax=docker/dockerfile:1.9 +FROM golang:1.23-alpine AS builder WORKDIR /go/src/github.com/nginxinc/kic-test-containers/ COPY udp/main.go ./udp/ COPY go.mod utils.go ./ RUN CGO_ENABLED=0 GOOS=linux go build -o /main ./udp/ -FROM scratch as goreleaser +FROM scratch AS goreleaser ARG TARGETARCH COPY dist/udp_linux_${TARGETARCH}*/main /app/main diff --git a/udp/README.md b/udp/README.md index b376262..e543250 100644 --- a/udp/README.md +++ b/udp/README.md @@ -1,25 +1,27 @@ -## UDP Server +# UDP Server A Go server that accepts UDP requests and responds with the local address of the connection. -### Description +## Description + If the server is run inside a Docker container, the local address is the IP of the docker container. This is useful for distinguishing between instances of Docker containers. This server is used by the python tests in the [load balancing tests](../suite/test_transport_server_udp_load_balance.py). -### Config +## Config + The default port the server listens to is `3334`. The server takes a single argument, `port`, to allow the port to be overridden. - ## Making changes - * Test the change: - * Use the minikube registry ```$ eval $(minikube docker-env)``` - * Build the docker image from the root of the project ```docker build -t udp-server .``` - * Update the [service yaml](https://github.com/nginxinc/kubernetes-ingress/blob/main/tests/data/transport-server-udp-load-balance/standard/service_deployment.yaml) to use the local version ```-> imagePullPolicy: Never``` - * Test the changes - * Publish the upd-server change - * Open a PR with the changes - * Once the PR is approved merge it to the main branch - * Create a new tag for the commit, this will start the pipeline and publish the new udp-server image +- Test the change: + - Use the minikube registry ```$ eval $(minikube docker-env)``` + - Build the docker image from the root of the project ```docker build -t udp-server .``` + - Update the [service yaml](https://github.com/nginxinc/kubernetes-ingress/blob/main/tests/data/transport-server-udp-load-balance/standard/service_deployment.yaml) + to use the local version ```-> imagePullPolicy: Never``` + - Test the changes +- Publish the upd-server change + - Open a PR with the changes + - Once the PR is approved merge it to the main branch + - Create a new tag for the commit, this will start the pipeline and publish the new udp-server image