Skip to content

Commit

Permalink
Make linters happy (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
svrnm authored Dec 30, 2024
1 parent 8886056 commit 12ae5d8
Show file tree
Hide file tree
Showing 32 changed files with 655 additions and 581 deletions.
5 changes: 5 additions & 0 deletions .checkov.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
skip-path:
- "/src/databases/mysql/Dockerfile"
- "/src/services/java/Dockerfile"
- "/src/services/nodejs/Dockerfile"
- "/src/loaders/curl/Dockerfile"
7 changes: 3 additions & 4 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
name: Bug Report
description: Report a bug to help us improve.
title: '[Bug]: '
labels: ['bug', 'triage']
title: "[Bug]: "
labels: ["bug", "triage"]
body:
- type: markdown
attributes:
Expand Down Expand Up @@ -55,8 +55,7 @@ body:
label: Checklist
description: By submitting this issue, you agree to the following
options:
- label:
I have read the [contributing
- label: I have read the [contributing
guidelines](/cisco-open/app-simulator/blob/main/CONTRIBUTING.md)
required: true
- label: I have verified this does not duplicate an existing issue
Expand Down
7 changes: 3 additions & 4 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
name: Feature Request
description: Suggest a feature for this project.
title: '[Feature]: '
labels: ['enhancement', 'triage']
title: "[Feature]: "
labels: ["enhancement", "triage"]
body:
- type: markdown
attributes:
Expand Down Expand Up @@ -48,8 +48,7 @@ body:
label: Checklist
description: By submitting this request, you agree to the following
options:
- label:
I have read the [contributing
- label: I have read the [contributing
guidelines](/cisco-open/app-simulator/blob/main/CONTRIBUTING.md)
required: true
- label: |
Expand Down
10 changes: 5 additions & 5 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
version: 2
updates:
- package-ecosystem: 'github-actions'
directory: '/'
- package-ecosystem: "github-actions"
directory: "/"
groups:
github:
patterns:
- 'actions/*'
- 'github/*'
- "actions/*"
- "github/*"
schedule:
interval: 'weekly'
interval: "weekly"
4 changes: 4 additions & 0 deletions .github/workflows/build-images-on-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ on:
- ".github/workflows/reusable-build-container-images.yml"
- ".github/workflows/build-images-on-commit.yml"
workflow_dispatch:

# Declare default permissions as read-only
permissions: read-all

jobs:
build:
uses: ./.github/workflows/reusable-build-container-images.yml
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/build-images-on-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ on:
- "src/databases/**"
- ".github/workflows/reusable-build-container-images.yml"
- ".github/workflows/check.yml"

# Declare default permissions as read-only
permissions: read-all

jobs:
build:
uses: ./.github/workflows/reusable-build-container-images.yml
with:
push: false
release_stream: dev
6 changes: 5 additions & 1 deletion .github/workflows/build-images-on-schedule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
name: Build and publish nightly container images
on:
schedule:
- cron: '0 0 * * *'
- cron: "0 0 * * *"

# Declare default permissions as read-only
permissions: read-all

jobs:
build:
uses: ./.github/workflows/reusable-build-container-images.yml
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/build-images-on-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ name: Build and publish release container images
on:
push:
tags:
- 'v*.*.*'
- "v*.*.*"

# Declare default permissions as read-only
permissions: read-all

jobs:
build:
uses: ./.github/workflows/reusable-build-container-images.yml
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/dependency.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: dependency
on:
# Review dependencies on pull requests to the default branch
pull_request:
branches: ['main']
branches: ["main"]
# Declare default permissions as read-only
permissions: read-all
jobs:
Expand All @@ -21,7 +21,7 @@ jobs:
- name: 🔂 dependency review
uses: actions/dependency-review-action@3b139cfc5fae8b618d3eae3675e383bb1769c019 # v4.5.0
with:
fail-on-severity: 'high'
deny-licenses: 'AGPL-1.0, AGPL-3.0'
fail-on-severity: "high"
deny-licenses: "AGPL-1.0, AGPL-3.0"
comment-summary-in-pr: true
warn-on-openssf-scorecard-level: 3
14 changes: 12 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,19 @@ jobs:
uses: super-linter/super-linter@85f7611e0f7b53c8573cca84aa0ed4344f6f6a4d # v7.2.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LINTER_RULES_PATH: '.'
YAML_CONFIG_FILE: '.yamllint'
LINTER_RULES_PATH: "."
YAML_CONFIG_FILE: ".yamllint"
CHECKOV_FILE_NAME: ".checkov.yaml"
DOCKERFILE_HADOLINT_FILE_NAME: ".hadolint.yaml"
VALIDATE_GIT_COMMITLINT: false
VALIDATE_ALL_CODEBASE: false
# Reenable when java service is modernized
VALIDATE_JAVA: false
# Reenable when Node.JS service is modernized
VALIDATE_JAVASCRIPT_STANDARD: false
# We want to remove the PHP script for the mysql database later, so
# we disable php linting for now
VALIDATE_PHP_PHPCS: false
VALIDATE_PHP_PSALM: false
MULTI_STATUS: false
ENABLE_GITHUB_ACTIONS_STEP_SUMMARY: true
6 changes: 5 additions & 1 deletion .github/workflows/reusable-build-container-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ on:
default: "ghcr.io/cisco-open/app-simulator"
required: false
type: string

# Declare default permissions as read-only
permissions: read-all

jobs:
build:
runs-on: ubuntu-24.04
Expand Down Expand Up @@ -39,7 +43,7 @@ jobs:
# build semver releases on tag
# build edge releases on main branch
tags: |
type=schedule,pattern={{date 'YYYYMMDD'}}
type=schedule,pattern={{date 'YYYYMMDD'}}
type=semver,pattern={{ version }}
type=edge,branch=main
labels: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- main
schedule:
# Run weekly on Saturdays
- cron: '30 1 * * 6'
- cron: "30 1 * * 6"
# Run when branch protection rules change
branch_protection_rule:
# Run the workflow manually
Expand Down
Empty file added .hadolint.yaml
Empty file.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ of the different components that make up an application.

This includes the following use cases:

* Tailored demo environments for observability, e.g. instrumenting all services with OpenTelemetry and visualizing the
- Tailored demo environments for observability, e.g. instrumenting all services with OpenTelemetry and visualizing the
data in your preferred backend.
* Complex simulated environments for in-cluster network experiments, e.g. testing out new features of cilium.
- Complex simulated environments for in-cluster network experiments, e.g. testing out new features of cilium.

## Quick Start

You can use application simulator with your preferred container orchestration, since all components are available as
container images. We provide the best experience for docker compose and kubernetes. Pick one of them for a quick start!

* [kubernetes quick start](./docs/quick-start/kubernetes.md)
* [docker compose quick start](./docs/quick-start/docker-compose.md)
- [kubernetes quick start](./docs/quick-start/kubernetes.md)
- [docker compose quick start](./docs/quick-start/docker-compose.md)

## Tutorial

Expand All @@ -38,7 +38,7 @@ After you have tried out application simulator with the quick start, you can lea

## Configuration specification

Application simulator is driven by configuration files that allow you to easily describe a micro service architecture and
Application simulator is driven by configuration files that allow you to describe a microservice architecture and
then run it with your preferred container orchestration. The configuration file follows a [specification](./docs/specification.md)

## Contribute
Expand All @@ -48,4 +48,4 @@ If you'd like to contribute to this project, check out our [contribution guideli
## Support

If you have any questions or concerns, get in touch with us by [raising an issue](https://github.com/cisco-open/app-simulator/issues).
If you want to report a security issue, please follow our [security policy](./SECURITY.md)
If you want to report a security issue, please follow our [security policy](./SECURITY.md)
2 changes: 1 addition & 1 deletion docs/quick-start/docker-compose.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# docker compose quick start

to be done
to be done
2 changes: 1 addition & 1 deletion docs/quick-start/kubernetes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# kubernetes quick start

to be done
to be done
2 changes: 1 addition & 1 deletion docs/specification.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Application Simulator Configuration Specification

to be done
to be done
2 changes: 1 addition & 1 deletion docs/tutorial/1-two-java-services.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# Tutorial 1: Two java services
# Tutorial 1: Two java services
2 changes: 1 addition & 1 deletion docs/tutorial/2-a-database-and-more-services.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# Tutorial 2: A database and more services
# Tutorial 2: A database and more services
2 changes: 1 addition & 1 deletion docs/tutorial/3-errors-and-randmoness.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Tutorial 3: Errors and randomness

to be done
to be done
11 changes: 5 additions & 6 deletions examples/backend-db.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"type": "mysql",
"name": "backend-db",
"databases": {
"carts": ["id", "name", "total"]
}
"type": "mysql",
"name": "backend-db",
"databases": {
"carts": ["id", "name", "total"]
}
}
3 changes: 2 additions & 1 deletion examples/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
services:
frontend:
image: ghcr.io/cisco-open/app-simulator-services-java:latest
Expand Down Expand Up @@ -47,6 +48,6 @@ services:
ports:
- "3306:3306"
volumes:
- ./database.json:/config.json
- ./database.json:/config.json
networks:
default:
6 changes: 1 addition & 5 deletions examples/ext-payment.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
"type": "java",
"endpoints": {
"http": {
"/pay": [
"sleep,50",
"log,warn,do some logging",
"log,more logging",
]
"/pay": ["sleep,50", "log,warn,do some logging", "log,more logging"]
}
},
"name": "ext-payment"
Expand Down
9 changes: 3 additions & 6 deletions examples/loader.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"sleep" : 5,
"urls" : [
"https://frontend:8080/addtocart",
"http://frontend:8080/checkout"
],
"wait" : 1
"sleep": 5,
"urls": ["https://frontend:8080/addtocart", "http://frontend:8080/checkout"],
"wait": 1
}
1 change: 0 additions & 1 deletion scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,3 @@ for DIR in "${REPO_DIR}/src/loaders"/*; do
docker buildx build --platform "$PLATFORM" -t "$IMAGE_TAG" $PUSH "$DIR" $PUSH
fi
done

2 changes: 1 addition & 1 deletion scripts/bumpversion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ operation=""

for arg in "$@"; do
case "$arg" in
--patch|--minor|--major)
--patch | --minor | --major)
operation="$arg"
;;
--push)
Expand Down
2 changes: 2 additions & 0 deletions src/databases/mysql/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# There is no arm64 version of mysql:5.7, so we use the amd64 version, until we migrate to mariadb.
# hadolint ignore=DL3029
FROM --platform=linux/amd64 mysql:5.7

LABEL org.opencontainers.image.source=https://github.com/cisco-open/app-simulator
Expand Down
2 changes: 1 addition & 1 deletion src/databases/mysql/setup.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
APP_CONFIG="$(</config.json)" php /tmp/setup.php
mysql -uroot -p${MYSQL_ROOT_PASSWORD} < /tmp/create.sql
mysql -uroot -p"${MYSQL_ROOT_PASSWORD}" </tmp/create.sql
4 changes: 4 additions & 0 deletions src/loaders/curl/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ LABEL org.opencontainers.image.source=https://github.com/cisco-open/app-simulato
LABEL org.opencontainers.image.description="curl loader for app-simulator"
LABEL org.opencontainers.image.licenses=BSD-3-Clause

# Pining versions with alpine regularly breaks, disable linting for this line
# until a better solution is found.
# hadolint ignore=DL3018
RUN apk add --no-cache curl util-linux jq

WORKDIR /usr/bin/
COPY entrypoint.sh /usr/bin
RUN chmod +x /usr/bin/entrypoint.sh
Expand Down
19 changes: 9 additions & 10 deletions src/loaders/curl/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,22 @@ LOADER_CONFIG="/config.json"

# Check if the file exists
if [[ ! -f "${LOADER_CONFIG}" ]]; then
echo "Warning: $LOADER_CONFIG not found! Environment variables will be used instead."
echo "Warning: $LOADER_CONFIG not found! Environment variables will be used instead."
else
SLEEP=$(jq -r '.sleep' "$LOADER_CONFIG")
WAIT=$(jq -r '.wait' "$LOADER_CONFIG")
URLS=$(jq -r '.urls | join(" ")' "$LOADER_CONFIG")
SLEEP=$(jq -r '.sleep' "$LOADER_CONFIG")
WAIT=$(jq -r '.wait' "$LOADER_CONFIG")
URLS=$(jq -r '.urls | join(" ")' "$LOADER_CONFIG")
fi


# Check if SLEEP and WAIT are numbers
if ! [[ "${SLEEP}" =~ ^[0-9]+$ ]]; then
echo "Error: SLEEP is not a valid number: $SLEEP"
exit 1
echo "Error: SLEEP is not a valid number: $SLEEP"
exit 1
fi

if ! [[ "${WAIT}" =~ ^[0-9]+$ ]]; then
echo "Error: WAIT is not a valid number: $WAIT"
exit 1
echo "Error: WAIT is not a valid number: $WAIT"
exit 1
fi

echo "Running CURL load in ${WAIT} seconds ..."
Expand All @@ -34,4 +33,4 @@ while true; do
/usr/bin/curl -s "${URL}?unique_session_id=${ID}"
done
sleep "${SLEEP}"
done
done
Loading

0 comments on commit 12ae5d8

Please sign in to comment.