Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

class-generator: Update and add cluster schema API files #2037

Merged
merged 16 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ fcn_exclude_functions =
tmp_path_factory,
tmpdir_factory,
Path,
writelines,
submit,

enable-extensions =
FCN,
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,4 @@ package-lock.json

# class generator script
script/resource/debug/*
class_generator/ocp-openapi.json
7 changes: 5 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ repos:
hooks:
- id: detect-secrets
args:
[--exclude-files=class_generator/tests/manifests/pod/pod_debug.json]
[
--exclude-files=class_generator/schema/*,
--exclude-files=class_generator/__ocp-openapi.json,
]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.7
Expand All @@ -54,4 +57,4 @@ repos:
hooks:
- id: mypy
exclude: ^(tests/|examples/|docs/)
additional_dependencies: ["types-PyYAML"]
additional_dependencies: ["types-PyYAML", "types-requests"]
53 changes: 40 additions & 13 deletions class_generator/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
# Resource class generator

## prerequisites

- [poetry](https://python-poetry.org/)
- [oc](https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/ocp/stable/) or [kubectl](https://kubernetes.io/docs/tasks/tools/) (latest version)
- Kubernetes/Openshift cluster

## Usage

###### Install poetry environment
###### Installation

- Using [pipx](https://github.com/pypa/pipx) (recommended)

Expand All @@ -25,6 +19,7 @@ python3 -m pip install openshift-python-wrapper
- Using [poetry](https://python-poetry.org/) (For development)

```bash
pipx install poetry
poetry install
```

Expand Down Expand Up @@ -54,12 +49,6 @@ class-generator --kind <kind>
- `OATH` -> `oath`
- `CDIConfig` -> `cdi_config`

Run in interactive mode:

```bash
class-generator --interactive
```

#### Adding tests

- Add a new test for the provided `kind` by passing `--add-tests` flag
Expand All @@ -69,6 +58,44 @@ class-generator --interactive
class-generator --kind Pod --add-tests
```

#### Update schema files

- Dependencies
- Kubernetes/Openshift cluster
- [oc](https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/ocp/stable/) or [kubectl](https://kubernetes.io/docs/tasks/tools/) (latest version)
- [openapi2jsonschema](https://github.com/instrumenta/openapi2jsonschema)
- [poetry](https://python-poetry.org/)

```bash
pipx install poetry
pipx install --python python3.9 openapi2jsonschema
```

- Clone this repository

```bash
got clone https://github.com/RedHatQE/openshift-python-wrapper.git
cd openshift-python-wrapper
```

- Install dependencies

```bash
poetry install
```

- Login to the cluster use admin user and password.

```bash
oc login <clster api URL> -u <username> -p <password>
```

- Execute the command:

```bash
poetry run python class_generator/class-generator --update-schema
```

## Reporting an issue

- Running with debug mode and `--debug` flag:
Expand Down
1 change: 1 addition & 0 deletions class_generator/__ocp-openapi.json

Large diffs are not rendered by default.

Loading