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
6 changes: 2 additions & 4 deletions .github/ISSUE_TEMPLATE/patch_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ assignees: petruki
A clear and concise description of why the patch is needed.

**Current dependency**
- **Name**:
- **Version**:
- **name@version**:

**Optional - Remediation**
- **Name**:
- **Version**:
- **name@version**:

**Additional context**
Links or documentation to the vulnerability or dependency update.
44 changes: 23 additions & 21 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

steps:
- name: Git checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -25,7 +25,7 @@ jobs:
node-version: 20.x

- name: Start MongoDB
uses: supercharge/mongodb-github-action@1.9.0
uses: supercharge/mongodb-github-action@1.10.0
with:
mongodb-version: 6.0

Expand Down Expand Up @@ -65,20 +65,20 @@ jobs:

steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Login to DockerHub
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v3
uses: docker/build-push-action@v5
with:
push: true
platforms: linux/amd64,linux/arm64
Expand All @@ -91,28 +91,30 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: 'master'

- name: Checkout Kustomize
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
token: ${{ secrets.ARGOCD_PAT }}
repository: switcherapi/switcher-deployment
ref: master

- name: Set Image
uses: stefanprodan/kube-tools@v1
- name: Set up arkade-get
uses: alexellis/arkade-get@master
with:
kubectl: 1.24.0
kustomize: 4.5.4
command: |
cd switcher-resolver-node/base
echo RELEASE_TIME=`date` > environment-properties.env
kustomize edit set image trackerforce/switcher-resolver-node:latest=trackerforce/switcher-resolver-node@${{ needs.docker.outputs.digest }}
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
git config --global user.name "${{ github.actor }}"
git add .
git commit -m "[argocd] switcher-resolver-node: ${{ needs.docker.outputs.digest }}"
git push
kubectl: latest
kustomize: latest

- name: Update GitOps repository
run: |
cd switcher-resolver-node/base
echo RELEASE_TIME=`date` > environment-properties.env
kustomize edit set image trackerforce/switcher-resolver-node:latest=trackerforce/switcher-resolver-node@${{ needs.docker.outputs.digest }}
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
git config --global user.name "${{ github.actor }}"
git add .
git commit -m "[argocd] switcher-resolver-node: ${{ needs.docker.outputs.digest }}"
git push
90 changes: 90 additions & 0 deletions .github/workflows/re-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Re-release CI
run-name: Re-releasing - ${{ github.event.inputs.tag }} by @${{ github.actor }}

on:
workflow_dispatch:
inputs:
tag:
description: 'Tag'
required: true

jobs:
build-test:
name: Build & Test
runs-on: ubuntu-latest

steps:
- name: Git checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.inputs.tag }}

- name: Use Node.js 20.x
uses: actions/setup-node@v3
with:
node-version: 20.x

- name: Start MongoDB
uses: supercharge/mongodb-github-action@1.10.0
with:
mongodb-version: 6.0

- name: Install dependencies
run: npm install

- name: Lint
run: npm run lint

- name: Run tests
run: npm test
env:
MONGODB_URI: mongodb://127.0.0.1:27017/switcher-api-test
JWT_CLIENT_TOKEN_EXP_TIME: 5m
JWT_SECRET: ${{ secrets.JWT_SECRET }}
RELAY_BYPASS_HTTPS: true
RELAY_BYPASS_VERIFICATION: true
METRICS_ACTIVATED: true
MAX_REQUEST_PER_MINUTE: 0
SWITCHER_API_ENABLE: false
SWITCHER_API_LOGGER: false

docker:
name: Publish Docker Image
needs: [ build-test ]
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.inputs.tag }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: trackerforce/switcher-resolver-node
tags: ${{ github.event.inputs.tag }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
18 changes: 10 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ jobs:

steps:
- name: Git checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Use Node.js 20.x
uses: actions/setup-node@v3
with:
node-version: 20.x

- name: Start MongoDB
uses: supercharge/mongodb-github-action@1.9.0
uses: supercharge/mongodb-github-action@1.10.0
with:
mongodb-version: 6.0

Expand Down Expand Up @@ -49,28 +51,28 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: trackerforce/switcher-resolver-node

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Login to DockerHub
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v3
uses: docker/build-push-action@v5
with:
context: .
push: true
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,23 @@
"jsonwebtoken": "^9.0.2",
"moment": "^2.29.4",
"mongodb": "^6.3.0",
"mongoose": "^8.0.2",
"pino": "^8.16.2",
"pino-pretty": "^10.2.3",
"mongoose": "^8.0.3",
"pino": "^8.17.1",
"pino-pretty": "^10.3.0",
"swagger-ui-express": "^5.0.0",
"switcher-client": "^3.2.0",
"validator": "^13.11.0"
},
"devDependencies": {
"@babel/cli": "^7.23.4",
"@babel/core": "^7.23.5",
"@babel/core": "^7.23.6",
"@babel/node": "^7.22.19",
"@babel/preset-env": "^7.23.5",
"@babel/preset-env": "^7.23.6",
"@babel/register": "^7.22.15",
"babel-jest": "^29.7.0",
"babel-polyfill": "^6.26.0",
"env-cmd": "^10.1.0",
"eslint": "^8.55.0",
"eslint": "^8.56.0",
"jest": "^29.7.0",
"jest-sonar-reporter": "^2.0.0",
"node-notifier": "^10.0.1",
Expand Down
14 changes: 7 additions & 7 deletions src/api-docs/paths/path-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ export default {
description: 'Execute criteria query against the API settings',
security: [{ appAuth: [] }],
parameters: [
queryParameter('key', 'string', 'Switcher Key', true),
queryParameter('showReason', 'boolean', 'Show criteria execution reason (default: true)', false),
queryParameter('showStrategy', 'boolean', 'Show criteria execution strategy (default: true)', false),
queryParameter('bypassMetric', 'boolean', 'Bypass metric check (default: true)', false)
queryParameter('key', 'Switcher Key', true, 'string'),
queryParameter('showReason', 'Show criteria execution reason (default: true)', false, 'boolean'),
queryParameter('showStrategy', 'Show criteria execution strategy (default: true)', false, 'boolean'),
queryParameter('bypassMetric', 'Bypass metric check (default: true)', false, 'boolean')
],
requestBody: {
content: {
Expand Down Expand Up @@ -56,7 +56,7 @@ export default {
},
strategies: {
type: 'array',
items: configStrategy
items: configStrategy.ConfigStrategy
}
}
}
Expand All @@ -66,13 +66,13 @@ export default {
}
}
},
'/criteria/snapshot_check/:version': {
'/criteria/snapshot_check/{version}': {
get: {
tags: ['Client API'],
description: 'Check if snapshot version is up to date',
security: [{ appAuth: [] }],
parameters: [
pathParameter('version', 'string', 'Snapshot version', true)
pathParameter('version', 'Snapshot version', true)
],
responses: {
200: {
Expand Down
15 changes: 9 additions & 6 deletions src/api-docs/schemas/config-strategy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { OperationsType, StrategiesType } from '../../models/config-strategy';

export const configStrategy = {
const configStrategy = {
type: 'object',
properties: {
_id: {
Expand All @@ -22,9 +22,12 @@ export const configStrategy = {
type: 'string',
enum: Object.values(StrategiesType)
},
values: [{
type: 'string'
}],
values: {
type: 'array',
items: {
type: 'string'
}
},
operation: {
type: 'string',
enum: Object.values(OperationsType)
Expand All @@ -40,14 +43,14 @@ export const configStrategy = {
format: 'uuid'
},
owner: {
type: 'uuid',
type: 'string',
description: 'The owner id of the config strategy'
},
admin: {
type: 'object',
properties: {
_id: {
type: 'uuid',
type: 'string',
description: 'The unique identifier of the admin'
},
name: {
Expand Down
7 changes: 1 addition & 6 deletions src/api-docs/swagger-document.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pathClient from './paths/path-client';

import { commonSchema } from './schemas/common';
import configStrategySchema from './schemas/config-strategy';
import info from './swagger-info';

export default {
Expand All @@ -17,14 +16,11 @@ export default {
description: 'Cloud API'
}
],
consumes: ['application/json'],
produces: ['application/json'],
components: {
securitySchemes: {
appAuth: {
type: 'http',
scheme: 'bearer',
name: 'JWT'
},
apiKey: {
type: 'apiKey',
Expand All @@ -33,8 +29,7 @@ export default {
}
},
schemas: {
...commonSchema,
...configStrategySchema
...commonSchema
}
},
paths: {
Expand Down