Skip to content

Commit 90f02b1

Browse files
committed
Merge branch 'main' into cira
2 parents e0d68de + e16421f commit 90f02b1

File tree

144 files changed

+7555
-3370
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+7555
-3370
lines changed

.devcontainer/devcontainer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
{
44
"name": "Go",
55
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6-
"image": "mcr.microsoft.com/devcontainers/go:1-1.23-bullseye",
6+
"image": "mcr.microsoft.com/devcontainers/go:dev-1-bullseye",
77
// Features to add to the dev container. More info: https://containers.dev/features.
88
// "features": {},
99
// Use 'forwardPorts' to make a list of ports inside the container available locally.
1010
"forwardPorts": [
1111
8181
1212
],
1313
// Use 'postCreateCommand' to run commands after the container is created.
14-
"postCreateCommand": "go install github.com/cosmtrek/air@latest"
14+
"postCreateCommand": "go install github.com/air-verse/air@v1.62.0"
1515
// Configure tool-specific properties.
1616
// "customizations": {},
1717
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.

.env.example

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,46 @@
1-
DISABLE_SWAGGER_HTTP_HANDLER=true
2-
GIN_MODE=release
1+
# Application
2+
APP_NAME=console
3+
APP_REPO=device-management-toolkit/console
4+
APP_ENCRYPTION_KEY=
5+
APP_ALLOW_INSECURE_CIPHERS=false
6+
7+
# HTTP Server
8+
HTTP_HOST=localhost
9+
HTTP_PORT=8181
10+
WS_COMPRESSION=false
11+
HTTP_ALLOWED_ORIGINS=*
12+
HTTP_ALLOWED_HEADERS=*
13+
14+
# TLS
15+
# Enable TLS in release if the app terminates TLS itself. If behind an API gateway or LB that provides TLS, set to false.
16+
HTTP_TLS_ENABLED=true
17+
# If both are empty and HTTP_TLS_ENABLED=true, the server will generate a self-signed certificate at startup.
18+
HTTP_TLS_CERT_FILE=
19+
HTTP_TLS_KEY_FILE=
20+
21+
# Logger
22+
LOG_LEVEL=info
23+
24+
# Database
25+
DB_POOL_MAX=2
26+
DB_URL=
27+
28+
# EA
29+
EA_URL=http://localhost:8000
30+
EA_USERNAME=
31+
EA_PASSWORD=
32+
33+
# Auth
34+
AUTH_DISABLED=false
35+
AUTH_ADMIN_USERNAME=standalone
36+
AUTH_ADMIN_PASSWORD=G@ppm0ym
37+
AUTH_JWT_KEY=your_secret_jwt_key
38+
AUTH_JWT_EXPIRATION=24h
39+
AUTH_REDIRECTION_JWT_EXPIRATION=5m
40+
AUTH_CLIENT_ID=
41+
AUTH_ISSUER=GIN_MODE=release
342
# DB_URL=postgres://postgresadmin:admin123@localhost:5432/rpsdb
443
# OAUTH CONFIGURATION
5-
AUTH_CLIENT_ID=""
44+
AUTH_CLIENT_ID=
645
# ex. "https://login.microsoftonline.com/<tenant-id>/v2.0 for Azure Entra -- used for discovery
7-
AUTH_ISSUER=""
46+
AUTH_ISSUER=

.github/.golangci.yml

Lines changed: 0 additions & 138 deletions
This file was deleted.

.github/CODEOWNERS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# This file defines the code owners for the console repository
2+
# See https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
3+
4+
# Default owners for the entire repository
5+
* @device-management-toolkit/owner-open-amt-cloud-toolkit

.github/workflows/ci.yml

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,10 @@ jobs:
3535
- name: Check out code into the Go module directory
3636
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
3737
- name: golangci-lint
38-
uses: reviewdog/action-golangci-lint@3dfdce20f5ca12d264c214abb993dbb40834da90 # v2.7.2
38+
uses: reviewdog/action-golangci-lint@f9bba13753278f6a73b27a56a3ffb1bfda90ed71 # v2.7.2
3939
with:
4040
fail_level: error
41-
golangci_lint_version: v1.64.8 # pin golangci-lint version
42-
golangci_lint_flags: "--config=.github/.golangci.yml ./..."
41+
golangci_lint_flags: "--config=./.golangci.yml ./..."
4342

4443
yamllint:
4544
name: runner / yamllint
@@ -93,14 +92,43 @@ jobs:
9392
base-ref: ${{ github.event.pull_request.base.sha || 'main' }}
9493
head-ref: ${{ github.event.pull_request.head.sha || github.ref }}
9594

95+
devcontainer:
96+
name: runner / devcontainer
97+
runs-on: ubuntu-latest
98+
steps:
99+
- name: Harden Runner
100+
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
101+
with:
102+
egress-policy: audit
103+
104+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
105+
- name: Install Dev Container CLI
106+
run: npm install -g @devcontainers/cli@0.67.0
107+
- name: Build dev container definition
108+
run: devcontainer build --workspace-folder .
109+
- name: Start dev container
110+
run: devcontainer up --workspace-folder . --remove-existing-container
111+
- name: Verify dev container command execution
112+
run: devcontainer exec --workspace-folder . -- bash -lc "go version && air -v"
113+
- name: Cleanup dev container
114+
if: always()
115+
run: |
116+
CONTAINER_IDS=$(docker ps -aq --filter "label=devcontainer.local_folder=$(pwd)")
117+
if [ -n "$CONTAINER_IDS" ]; then
118+
docker rm -f $CONTAINER_IDS
119+
fi
120+
VOLUME_IDS=$(docker volume ls -q --filter "label=devcontainer.local_folder=$(pwd)")
121+
if [ -n "$VOLUME_IDS" ]; then
122+
docker volume rm $VOLUME_IDS
123+
fi
124+
96125
tests:
97126
name: runner / build and tests
98127
runs-on: ubuntu-latest
99128
strategy:
100129
matrix:
101130
go-version: [1.23.x, 1.24.x]
102-
os:
103-
[windows-2019, windows-2022, ubuntu-22.04, ubuntu-24.04]
131+
os: [windows-2019, windows-2022, ubuntu-22.04, ubuntu-24.04]
104132
steps:
105133
- name: Harden Runner
106134
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2

.github/workflows/release.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,54 @@ jobs:
173173
path: dist/windows
174174
key: windows-${{ env.sha_short }}
175175
enableCrossOsArchive: true
176+
177+
# Generate licenses.zip
178+
- name: Use Node.js 22.x
179+
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
180+
with:
181+
node-version: 22.x
182+
183+
# Pin Go only for license generation
184+
- name: Use Go 1.25.1 for license scan
185+
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
186+
with:
187+
go-version: "1.25.1"
188+
check-latest: true
189+
- name: Pin toolchain for this step
190+
run: |
191+
go version
192+
go env -w GOTOOLCHAIN=local
193+
194+
- name: Checkout Sample Web UI for license scan
195+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
196+
with:
197+
repository: device-management-toolkit/sample-web-ui
198+
ref: main
199+
path: ./temp
176200

201+
- name: Generate Go Licenses
202+
run: |
203+
go install github.com/google/go-licenses/v2@v2.0.1
204+
mkdir -p licenses
205+
if ! "$(go env GOPATH)"/bin/go-licenses save ./... --save_path=./licenses/consoledependencies; then
206+
echo "Failed to generate Go licenses"
207+
exit 1
208+
fi
209+
210+
- name: Generate Web UI Licenses
211+
working-directory: ./temp
212+
run: |
213+
npm ci
214+
npm install -g license-checker-rseidelsohn@4.4.2
215+
mkdir -p ../licenses/webuidependencies
216+
if ! license-checker-rseidelsohn --plainVertical --out ../licenses/webuidependencies/webui_dependencies.txt; then
217+
echo "Failed to generate Web UI licenses"
218+
exit 1
219+
fi
220+
221+
- name: Create licenses.zip
222+
run: zip -r licenses.zip licenses
223+
177224
- name: Docker Login
178225
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
179226
with:
@@ -183,6 +230,7 @@ jobs:
183230
logout: true
184231

185232
- name: Semantic Release
233+
id: semantic-release
186234
uses: cycjimmy/semantic-release-action@b1b432f13acb7768e0c8efdec416d363a57546f2 # v4.1.1
187235
if: steps.cache.outputs.cache-hit != 'true' # do not run if cache hit
188236
with:
@@ -194,3 +242,40 @@ jobs:
194242
@semantic-release/exec@6.0.3
195243
env:
196244
GITHUB_TOKEN: ${{ secrets.ROSIE_TOKEN }}
245+
246+
- name: Check if OpenAPI files changed
247+
id: check-openapi-changes
248+
run: |
249+
git fetch origin main:main
250+
if git diff --name-only main HEAD | grep -q '^internal/controller/openapi/'; then
251+
echo "changed=true" >> $GITHUB_OUTPUT
252+
else
253+
echo "changed=false" >> $GITHUB_OUTPUT
254+
fi
255+
256+
- name: Generate OpenAPI specification
257+
if: steps.semantic-release.outputs.new_release_published == 'true' && steps.check-openapi-changes.outputs.changed == 'true'
258+
run: |
259+
GIN_MODE=debug go run ./cmd/app/main.go
260+
261+
- name: Verify OpenAPI spec was generated
262+
run: |
263+
if [ ! -f "doc/openapi.json" ]; then
264+
exit 1
265+
fi
266+
head -20 doc/openapi.json
267+
268+
- name: Push to SwaggerHub
269+
if: vars.SWAGGERHUB_OWNER != '' && vars.SWAGGERHUB_API_NAME != ''
270+
env:
271+
SWAGGERHUB_API_KEY: ${{ secrets.SWAGGERHUB_API_KEY }}
272+
SWAGGERHUB_OWNER: ${{ vars.SWAGGERHUB_OWNER }}
273+
API_NAME: ${{ vars.SWAGGERHUB_API_NAME }}
274+
API_VERSION: ${{ steps.semantic-release.outputs.new_release_version }}
275+
run: |
276+
echo "Pushing OpenAPI spec to SwaggerHub with version ${{ steps.semantic-release.outputs.new_release_version }}..."
277+
curl -X POST "https://api.swaggerhub.com/apis/${SWAGGERHUB_OWNER}/${API_NAME}/${API_VERSION}" \
278+
-H "Authorization: ${SWAGGERHUB_API_KEY}" \
279+
-H "Content-Type: application/json" \
280+
--data-binary @doc/openapi.json \
281+
--fail

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,6 @@ vendor/
3434
# ...ignore the ui folder
3535
**/ui/*
3636
# ...but keep the folder
37-
!**/ui/.gitkeep
37+
!**/ui/.gitkeep
38+
# Documentation files
39+
doc/openapi.json

0 commit comments

Comments
 (0)