Skip to content

Commit

Permalink
class-generator: Update and add cluster schema API files (#2037)
Browse files Browse the repository at this point in the history
* class-generator: update cluster schema files

* class-generator: update cluster schema files

* class-generator: update cluster schema files, add schema files

* class-generator: update cluster schema files, add schema files

* class-generator: update cluster schema files, add schema files

* class-generator: update cluster schema files, add schema files

* class-generator: update cluster schema files, add schema files

* class-generator: update cluster schema files, add schema files

* class-generator: update cluster schema files, add schema files

* class-generator: update cluster schema files, add schema files

* class-generator: update cluster schema files, add schema files

* class-generator: update cluster schema files, add schema files

* class-generator: update cluster schema files, add schema files

* class-generator: update cluster schema files, add schema files

* class-generator: update cluster schema files, add schema files

* class-generator: update cluster schema files, add schema files
  • Loading branch information
myakove authored Aug 15, 2024
1 parent 5f855a7 commit 202c2c1
Show file tree
Hide file tree
Showing 1,270 changed files with 376,379 additions and 2,678 deletions.
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,
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,4 @@ package.json
package-lock.json

# class generator script
script/resource/debug/*
class_generator/__ocp-openapi.json
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
exclude: "class_generator/schema/*"

default_language_version:
python: python3

Expand Down Expand Up @@ -30,8 +32,6 @@ repos:
rev: v1.5.0
hooks:
- id: detect-secrets
args:
[--exclude-files=class_generator/tests/manifests/pod/pod_debug.json]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.7
Expand All @@ -54,4 +54,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
Loading

0 comments on commit 202c2c1

Please sign in to comment.