Skip to content

Latest commit

 

History

History
154 lines (107 loc) · 7.45 KB

CONTRIBUTING.md

File metadata and controls

154 lines (107 loc) · 7.45 KB

Welcome to openshift-python-wrapper contributing guide

Thank you for contributing to our project!
Project maintainers

New contributor guide

To get an overview of the project, read the README.

Issues

Create a new issue

If you find a problem with the code, search if an issue already exists.
If you open a pull request to fix the problem, an issue will be automatically created.
If a related issue doesn't exist, you can open a new issue using a relevant issue form.

Pull requests

To contribute code to the project:

  • Fork the project and work on your forked repository
  • Before submitting a new pull request, make sure you have prek installed
prek install
  • When submitting a pull request, make sure to fill all the required, relevant fields for your PR.
    Make sure the title is descriptive and short.
  • If the fix is needed in a released version, once your pull request is merged, cherry-pick it to the relevant branch(s).
    Add /cherry-pick <target branch to cherry-pick to> to the PR comment.

General

  • Add typing to new code; typing is enforced using mypy

Documentation

The site under docs/ is generated by pi-docsite and published by .github/workflows/docs.yml on every push to main that touches docs/ (https://redhatqe.github.io/openshift-python-wrapper/).

main tracks only the sources:

  • sources: docs/*.md and the sidebar order in docs/nav.json

Never run pi-docsite in a pull request. Its output is not tracked — the Action builds it on main. .github/workflows/docs-guard.yml rejects any PR that adds, modifies, copies or renames a path under docs/ other than **/*.md and nav.json (deletions are allowed).

To build locally for debugging — the output is gitignored, so it never shows up in git status:

uvx pi-docsite@4.18.0 --docs-dir docs \
  --project-name openshift-python-wrapper \
  --repo-url https://github.com/RedHatQE/openshift-python-wrapper \
  --tagline "Manage OpenShift and Kubernetes resources with clean, Pythonic code instead of raw API calls"

The version is pinned to the one .github/workflows/docs.yml publishes with, so a local build matches the site; bump both together after reviewing a release.

--repo-url matters: pi-docsite otherwise derives it from the local origin, so building from a fork rewrites every repository link. The tagline is the description shown in the sidebar and in each page's metadata; the workflow passes both for the same reason.

The build is deterministic (two runs without source changes are byte-identical), but that is now the workflow's property, not something a contributor has to prove.

Links between pages use the built <slug>.html form, because that is what the published site serves.

Publishing prerequisites

Pages must be configured for Actions (one-time repository setting, not per-PR) — this repo is:

gh api repos/RedHatQE/openshift-python-wrapper/pages --jq '{build_type, status}'
# {"build_type":"workflow","status":"built"}

With build_type: legacy the site is served straight from the committed docs/ on main, and removing that output would take the site down. With build_type: workflow the deployed artifact is the only thing Pages serves, and Pages keeps serving the last successful deployment until the next one replaces it — so a merge that stops tracking the output never leaves a missing page; the push that merge produces builds and deploys the replacement. Check the live site, not the artifact — but a status code proves only that something is live, not that it is current: when a deploy fails, Pages keeps serving the last successful one, so a 200 can describe the previous page. Build locally from the merged commit (command above) and compare the served page with it:

curl -s -o /tmp/live-quickstart.html https://redhatqe.github.io/openshift-python-wrapper/quickstart.html
cmp docs/quickstart.html /tmp/live-quickstart.html && echo "live quickstart.html matches this commit"
gh run list --branch main --workflow docs.yml --limit 1   # the run this check belongs to

The first deploy after switching to build_type: workflow needs no manual run here: the workflow does not exist on main until the change merges, and that merge push (docs/** in the path filter) is what triggers the build and deploy. gh workflow run docs.yml (workflow_dispatch) is only for a re-deploy with no new commit.

Adding a page: create docs/<slug>.md and add <slug> to docs/nav.json. A .md missing from nav.json is still built, placed under a fallback group, and reported.

Deleting a page: remove the .md and its slug from docs/nav.json. A slug with no .md behind it is a build error, so the stale entry has to go first.

Branches opened before the generated files were untracked will hit delete/modify conflicts on exactly those paths. Resolve them by deleting (git rm docs/foo.html docs/search-index.json …) and keeping the .md edit from the branch. Never resolve by regenerating — the regenerated output reintroduces the conflict and is what the guard now rejects.

Adding a new module (resource)

Using generator script (REQUIRED)

New resources MUST be added via the class generator — manual creation is not allowed.

Manual code (below # End of generated code only)

Custom helper methods can be added below the end marker. The generated class structure must follow these rules:

  • A new file named as the resource under ocp_resources; If the resource name is composed of multiple words, separate them with an underscore.
  • A class named as the resource kind.
  • Inherit from the relevant class; If the resource is cluster-scoped, inherit from Resource else from NamespacedResource.
  • API group:
    • Under ocp_resources.resource.Resource.ApiGroup
    • Resource's apiGroup (apiVersion prefix) as api_group
  • A link to the resource's API reference.
  • Implement __init__ function;
    Define all the required arguments that are required to instantiate the new resource. Optional parameters may be added as well.
  • Implement to_dict function.

Check ConfigMap and Node for reference.

Generated code markers

Resource files created by class-generator use markers to separate generated from manual code:

  • Start marker (line 1): # Generated using https://github.com/RedHatQE/openshift-python-wrapper/blob/main/class_generator/README.md
  • End marker (inside class): # End of generated code

Code between these markers is auto-generated and must NOT be modified manually. To update generated code, use class-generator --kind <Kind> --overwrite --backup. Custom code (helper methods, overrides) goes below the # End of generated code marker.

No client-side validation on resource creation

When building resource payloads (to_dict()), do NOT validate or block at code level (e.g., mutual exclusivity of fields). If a payload can be sent to the API, send it — let the Kubernetes/OpenShift API server return the error. Helper functions in resource classes (e.g., wait_for_rollout(), restart()) CAN perform validation and guarding as needed.