Skip to content

Commit 6d21903

Browse files
borislavrnookyo
andauthored
feat: AM generation command and GitHub action to use AM CLI in workflows. (#4)
* Initial commit * fix * fix * rename folder * add zip for gitignore * fix * fix * feat: added `generate` command * feat: add metadata dependencies and enhance generate command functionality * Refactor metadata handling and add support for standalone runnable components - Updated metadata-deps-new.yaml to use 'mimeType' instead of 'mime-type' for consistency. - Renamed function get_boom_ref to get_bom_ref for clarity. - Enhanced create.py and generate.py to utilize the updated get_bom_ref function. - Implemented logic in generate.py to handle standalone runnable components and their dependencies. - Added default handler to return structured response in default.py. - Registered default handler for standalone runnable components in registry.py. - Refactored component addition logic in components.py to use the updated get_bom_ref function. - Introduced helm_discovery.py for handling helm chart metadata extraction. - Created standalone_runnable.py to populate data for components with mime-type application/vnd.qubership.standalone-runnable. * feat: enhance helm chart handling and add PURL conversion functions * feat: add sandbox configuration and enhance purl handling functions * refactoring * feat: add configuration files for qubership and sandbox, enhance purl handling in services * feat: update helm chart handling and enhance PURL processing, including version extraction * fix: remove unused import of sys in generate.py * feat: added handlers/standalone_runnable_handler.py * feat: changed helm_discovery * feat: enhance helm discovery with concurrent processing for chart discovery * fixed input parameters and config structure * chore: removed unused files * chore: fixed example * feat: added docker-hub registry config * feat: added PyYAML to project dependencies * chore: added debug information * fixed url parsing * fix: fixed url_2_purl for helm * feat: added output * feat: add application manifest generation action * fix: update environment variable handling to append path to .env file * fix: update environment variable handling to use am.env for application manifest path * fix: streamline library type handling in chart properties * docs: update README to include installation and usage instructions for the generate command * feat: add example JSON files for Jaeger integration and update README usage instructions * chore update action.yaml * docs: translated README.md --------- Co-authored-by: Pavel Anikin <snwteam5@gmail.com>
1 parent 8427168 commit 6d21903

34 files changed

+1649
-1
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: "Application manifest generation"
2+
3+
inputs:
4+
configuration:
5+
description: "The configuration file for the application manifest generation"
6+
required: true
7+
type: string
8+
output:
9+
description: "The output file path for the generated application manifest"
10+
required: false
11+
type: string
12+
version:
13+
description: "The version to set in the application manifest"
14+
required: false
15+
type: string
16+
name:
17+
description: "The name to set in the application manifest"
18+
required: false
19+
type: string
20+
meta-data-files:
21+
description: "Additional metadata files to include in the application manifest"
22+
required: false
23+
type: string
24+
cli-version:
25+
description: "The version of the qubership-app-manifest-cli to use"
26+
required: false
27+
type: string
28+
default: "main"
29+
30+
outputs:
31+
app-manifest-path:
32+
description: "The path to the generated application manifest file"
33+
value: ${{ steps.generate_app_manifest.outputs.PATH_APP_MANIFEST }}
34+
runs:
35+
using: "composite"
36+
steps:
37+
- name: "Checkout repository"
38+
uses: "actions/checkout@v5"
39+
with:
40+
repository: netcracker/qubership-app-manifest-cli
41+
ref: "${{ inputs.cli-version }}"
42+
path: "app-manifest-cli"
43+
- name: Configure Python
44+
uses: actions/setup-python@v4
45+
with:
46+
python-version: '3.12'
47+
- name: Install dependencies
48+
shell: bash
49+
working-directory: app-manifest-cli
50+
run: |
51+
python -m venv venv
52+
source venv/bin/activate
53+
python -m pip install --upgrade pip
54+
pip install .
55+
- name: "Generate application manifest"
56+
shell: bash
57+
working-directory: ${{ github.workspace }}
58+
id: generate_app_manifest
59+
run: |
60+
source ./app-manifest-cli/venv/bin/activate
61+
pip list
62+
app-manifest generate \
63+
--config "${{ inputs.configuration }}" \
64+
$([[ -n "${{ inputs.output }}" ]] && echo "--output ${{ inputs.output }}") \
65+
$([[ -n "${{ inputs.version }}" ]] && echo "--version ${{ inputs.version }}") \
66+
$([[ -n "${{ inputs.name }}" ]] && echo "--name ${{ inputs.name }}") \
67+
$([[ -n "${{ inputs.meta-data-files }}" ]] && echo "${{ inputs.meta-data-files }}")
68+
if [[ -f "am.env" ]]; then
69+
echo "Sourcing am.env file"
70+
source am.env
71+
else
72+
echo "am.env file not found"
73+
fi
74+
echo "Generated application manifest path: $PATH_APP_MANIFEST"
75+
# echo "PATH_APP_MANIFEST=$([[ -n '${{ inputs.output }}' ]] && echo '${{ inputs.output }}' || echo ${PATH_APP_MANIFEST})"
76+
echo "PATH_APP_MANIFEST=${PATH_APP_MANIFEST}" >> $GITHUB_OUTPUT
77+
- name: "Upload application manifest"
78+
if: ${{ always() && steps.generate_app_manifest.outputs.PATH_APP_MANIFEST }}
79+
uses: actions/upload-artifact@v4
80+
with:
81+
name: application-manifest
82+
path: ${{ steps.generate_app_manifest.outputs.PATH_APP_MANIFEST }}

.gitignore

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Python
2+
__pycache__/
3+
*.py[cod]
4+
*.pyo
5+
*.pyd
6+
*.so
7+
8+
# Virtual environment
9+
.venv/
10+
venv/
11+
ENV/
12+
env/
13+
14+
# IDE
15+
.vscode/
16+
.idea/
17+
18+
# Build & packaging
19+
dist/
20+
build/
21+
*.egg-info/
22+
.eggs/
23+
24+
# OS
25+
.DS_Store
26+
Thumbs.db
27+
28+
# Logs
29+
*.log
30+
31+
*.zip

README.md

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,77 @@
1-
# qubership-app-manifest-cli
1+
# Documentation: `generate` Command for `app_manifest_cli`
2+
3+
## Installation
4+
5+
1. **Clone the repository:**
6+
```bash
7+
git clone https://github.com/borislavr/qubership-app-manifest-cli.git
8+
cd qubership-app-manifest-cli
9+
```
10+
11+
2. **Create venv**
12+
```bash
13+
python -m venv venv
14+
source venv/bin/activate
15+
```
16+
17+
3. **Install dependencies:**
18+
```bash
19+
pip install -r pyproject.toml
20+
```
21+
22+
4. **Install the package:**
23+
```bash
24+
pip install .
25+
```
26+
27+
## Using the `generate` Command
28+
29+
The `generate` command creates an application manifest based on a [configuration file](./example/jaeger/qubership-jaeger-am-build.yaml) and, if needed, [additional component files](./example/jaeger/).
30+
31+
### Синтаксис
32+
33+
```bash
34+
python -m venv venv
35+
source venv/bin/activate
36+
app-manifest generate --config CONFIG_PATH [--name NAME] [--version VERSION] [--out OUT_FILE] [COMPONENTS_FILES ...]
37+
```
38+
39+
- `--config`, `-c` — path to a YAML/JSON configuration file (required).
40+
- `--name`, `-n` — application name (defaults to value from config).
41+
- `--version`, `-v` — application version (defaults to value from config).
42+
- `--out`, `-o` — output file name (generated automatically by default).
43+
- `[COMPONENTS_FILES ...]` — (optional) list of paths to JSON component files.
44+
45+
### Examples
46+
47+
**Minimal example:**
48+
```bash
49+
python -m app_manifest_cli generate --config ./myapp-config.yaml
50+
```
51+
52+
**With name, version, and output file:**
53+
```bash
54+
python -m app_manifest_cli generate --config ./myapp-config.yaml --name my-app --version 2.0.1 --out manifest.json
55+
```
56+
57+
**With additional component files:**
58+
```bash
59+
python -m app_manifest_cli generate --config ./myapp-config.yaml comp1.json comp2.json
60+
```
61+
62+
### Notes
63+
64+
- Working with Helm charts requires [Helm](https://helm.sh/) to be installed.
65+
- If name and version are not specified, they will be taken from the configuration file.
66+
- If output file is not specified, it will be created automatically using the template `<name>-<version>.json`.
67+
68+
---
69+
70+
**For help on all commands:**
71+
```bash
72+
python -m app_manifest_cli --help
73+
```
74+
**For help on generate:**
75+
```bash
76+
python -m app_manifest_cli generate --help
77+
```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
version: "2.0"
2+
name: docker-hub
3+
dockerConfig:
4+
groupUri: docker.io
5+
groupName: dockerhub
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: "2.0"
2+
name: qubership
3+
dockerConfig:
4+
groupUri: ghcr.io
5+
groupName: netcracker
6+
githubReleaseConfig:
7+
repositoryDomainName: https://github.com
8+
owner: Netcracker
9+
repository: qubership-jaeger
10+
helmAppConfig:
11+
repositoryDomainName: oci://ghcr.io
12+
helmGroupRepoName: qubership-jaeger

configuration/RegDefs/sandbox.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
version: "2.0"
2+
name: sandbox
3+
authConfig:
4+
aws:
5+
authType: shortLived
6+
provider: aws
7+
authMethod: assume-role
8+
credentialId: role-aws
9+
helm:
10+
authType: longLived
11+
credentialId: cred-nexus
12+
mavenConfig:
13+
authConfig: aws
14+
repositoryDomainName: https://codeartifact.eu-west-1.amazonaws.com/maven/app
15+
targetSnapshot: snapshots
16+
targetStaging: staging
17+
targetRelease: releases
18+
snapshotGroup: org.qubership.app
19+
releaseGroup: org.qubership.app
20+
dockerConfig:
21+
authConfig: aws
22+
repositoryDomainName: https://123456789.dkr.ecr.eu-west-1.amazonaws.com
23+
snapshotUri: docker/snapshots
24+
stagingUri: docker/staging
25+
releaseUri: docker/releases
26+
groupUri: docker
27+
snapshotRepoName: docker-snapshots
28+
stagingRepoName: docker-staging
29+
releaseRepoName: docker-releases
30+
groupName: docker
31+
helmConfig:
32+
authConfig: helm
33+
repositoryDomainName: https://nexus.mycompany.internal/repository/helm-charts
34+
helmTargetStaging: helm-staging
35+
helmTargetRelease: helm-releases
36+
helmAppConfig:
37+
authConfig: helm
38+
repositoryDomainName: https://nexus.mycompany.internal/repository/helm-charts
39+
helmStagingRepoName: helm-staging
40+
helmReleaseRepoName: helm-releases
41+
helmGroupRepoName: helm-group
42+
helmDevRepoName: helm-dev
43+
goConfig:
44+
goTargetSnapshot: go-snapshots
45+
goTargetRelease: go-releases
46+
goProxyRepository: https://goproxy.internal/go/
47+
rawConfig:
48+
rawTargetSnapshot: raw/snapshots
49+
rawTargetRelease: raw/releases
50+
rawTargetStaging: raw/staging
51+
rawTargetProxy: https://proxy.raw.local/
52+
npmConfig:
53+
npmTargetSnapshot: npm-snapshots
54+
npmTargetRelease: npm-releases
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: "2.0"
2+
name: qubership
3+
dockerConfig:
4+
groupUri: ghcr.io
5+
groupName: netcracker
6+
githubReleaseConfig:
7+
repositoryDomainName: https://github.com
8+
owner: Netcracker
9+
repository: qubership-jaeger
10+
helmAppConfig:
11+
repositoryDomainName: oci://ghcr.io
12+
helmGroupRepoName: helm-group
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
version: "2.0"
2+
name: sandbox
3+
authConfig:
4+
aws:
5+
authType: shortLived
6+
provider: aws
7+
authMethod: assume-role
8+
credentialId: role-aws
9+
helm:
10+
authType: longLived
11+
credentialId: cred-nexus
12+
mavenConfig:
13+
authConfig: aws
14+
repositoryDomainName: https://codeartifact.eu-west-1.amazonaws.com/maven/app
15+
targetSnapshot: snapshots
16+
targetStaging: staging
17+
targetRelease: releases
18+
snapshotGroup: org.qubership.app
19+
releaseGroup: org.qubership.app
20+
dockerConfig:
21+
authConfig: aws
22+
repositoryDomainName: https://123456789.dkr.ecr.eu-west-1.amazonaws.com
23+
snapshotUri: docker/snapshots
24+
stagingUri: docker/staging
25+
releaseUri: docker/releases
26+
groupUri: docker
27+
snapshotRepoName: docker-snapshots
28+
stagingRepoName: docker-staging
29+
releaseRepoName: docker-releases
30+
groupName: docker
31+
helmConfig:
32+
authConfig: helm
33+
repositoryDomainName: https://nexus.mycompany.internal/repository/helm-charts
34+
helmTargetStaging: helm-staging
35+
helmTargetRelease: helm-releases
36+
helmAppConfig:
37+
authConfig: helm
38+
repositoryDomainName: https://nexus.mycompany.internal/repository/helm-charts
39+
helmStagingRepoName: helm-staging
40+
helmReleaseRepoName: helm-releases
41+
helmGroupRepoName: helm-group
42+
helmDevRepoName: helm-dev
43+
goConfig:
44+
goTargetSnapshot: go-snapshots
45+
goTargetRelease: go-releases
46+
goProxyRepository: https://goproxy.internal/go/
47+
rawConfig:
48+
rawTargetSnapshot: raw/snapshots
49+
rawTargetRelease: raw/releases
50+
rawTargetStaging: raw/staging
51+
rawTargetProxy: https://proxy.raw.local/
52+
npmConfig:
53+
npmTargetSnapshot: npm-snapshots
54+
npmTargetRelease: npm-releases
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"type": "container",
3+
"mime-type": "application/vnd.docker.image",
4+
"name": "jaeger-integration-tests",
5+
"group": "",
6+
"version": "0.0.8",
7+
"hashes":[
8+
{
9+
"alg": "sha256",
10+
"content": "495c453e945612f748399a944ab783fea11e33a292a48b10d5e42869c75736ac"
11+
}],
12+
"reference": "ghcr.io/borislavr/jaeger-integration-tests:0.0.8"
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"type": "container",
3+
"mime-type": "application/vnd.docker.image",
4+
"name": "jaeger-readiness-probe",
5+
"group": "",
6+
"version": "0.0.8",
7+
"hashes":[
8+
{
9+
"alg": "sha256",
10+
"content": "26a021a1b6f60fd612ff2025be4f705d23715355799159f281aaa7a93e5b6e71"
11+
}],
12+
"reference": "ghcr.io/borislavr/jaeger-readiness-probe:0.0.8"
13+
}

0 commit comments

Comments
 (0)