Skip to main content

Openshift cluster login on command line

Project description

logo

OCL (OpenShift Login)

PyPI PyPI platforms PyPI - License Release and Package Application

OCL does an automatic login to an OpenShift cluster. It fetches cluster information from app-interface and performs a login via Selenium.

Installation

You can install this library from PyPI with pip:

$ python3 -m pip install openshift-cluster-login

or install it with pipx:

$ pipx install openshift-cluster-login

You can also use pipx to run the library without installing it:

$ pipx run openshift-cluster-login

Usage

$ ocl

This spawns a new shell with the following environment variables are set:

  • KUBECONFIG - path to kubeconfig file
  • OCL_CLUSTER_NAME - cluster name
  • OCL_CLUSTER_CONSOLE - url to cluster console

Features

OCL currently provides the following features (get help with -h or --help):

  • OpenShift console login (oc login) via GitHub or Red Hat authentication
  • Get cluster information from app-interface or user-defined (OCL_USER_CLUSTERS``) _ Open the OpenShift console in the browser`` (--open-in-browser)
  • Shell completion (--install-completion, --show-completion)
  • Credentials via environment variables or shell command (e.g., 1password CLI)
  • Cache App-Interface queries (via GraphQL) for one week

Environment Variables

Variable Name Description Default
OCL_WAIT OCL_WAIT_COMMAND Selenium webdriver wait timeout 2
OCL_APP_INTERFACE_URL OCL_APP_INTERFACE_URL_COMMAND App-Interface URL
OCL_APP_INT_TOKEN OCL_APP_INT_TOKEN_COMMAND App-Interface authentication token
USER_CLUSTERS USER_CLUSTERS_COMMAND User defined clusters as json format (e.g. [{"name": "local-kind", "serverUrl": "https://localhost:6443", "consoleUrl": "not available}]) "[]"

You can either set a variable, e.g. export OCL_GITHUB_USERNAME="mail@example.com" or retrieve it via a command, e.g. export OCL_GITHUB_USERNAME_COMMAND="op read op://Private/Github/username". If a variable is not set but needed, OCL will ask for it interactively.

App-Interface

OCL retrieves the cluster information from app-interface via GraphQL (OCL_APP_INTERFACE_URL) and caches them in your user cache directory (on MacOS, e.g., ~/Library/Caches/ocl/gql_cache/). Remove this directory to force a refresh.

Limitations

  • Kerberos authentication only
  • Works only with a Red Hat associate account

Development

Code style: black Checked with mypy

Use Conventional Commit messages. The most important prefixes you should have in mind are:

  • fix: which represents bug fixes, and correlates to a SemVer patch.
  • feat: which represents a new feature, and correlates to a SemVer minor.
  • feat!:, or fix!:, refactor!:, etc., which represent a breaking change (indicated by the !) and will result in a SemVer major.
  • chore: release to create a new release

Consider using an empty commit:

git commit --allow-empty -m "chore: release"

When a commit to the main branch has Release-As: x.x.x (case insensitive) in the commit body, Release Please will open a new pull request for the specified version.

git commit --allow-empty -m "chore: release 2.0.0" -m "Release-As: 2.0.0"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openshift_cluster_login-1.0.0.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

openshift_cluster_login-1.0.0-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file openshift_cluster_login-1.0.0.tar.gz.

File metadata

  • Download URL: openshift_cluster_login-1.0.0.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.6 Linux/5.15.0-1040-azure

File hashes

Hashes for openshift_cluster_login-1.0.0.tar.gz
Algorithm Hash digest
SHA256 fe8c224d59884724e7bc1928e5f9ffff8116f62ded6dab77402778781f6bfff7
MD5 b43c315b64cb665334d0ca47c586a569
BLAKE2b-256 eee72410350e11f0f87be507b2d2d1fa4857d2f9b31a9538c27458e70493b32a

See more details on using hashes here.

File details

Details for the file openshift_cluster_login-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for openshift_cluster_login-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a766cf1006a01f39d663afd917bee26df137b67c720c72b24242fef296437414
MD5 5db4bbac336476226a1df1676db55479
BLAKE2b-256 725819477e7a2377a76252bf4a50e6e78f2b727567ab558931b35c98ebe4e448

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page