Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

oc-auth

БесплатноЗапускает вложенные скриптыНе проверен

Helper skill to retrieve OAuth tokens from the correct OpenShift cluster context when multiple clusters are configured

openshift-engот openshift-eng★ 123 звезды на GitHub16 установок в других каталогах

Об этом скилле

OC Authentication Helper

This skill provides a centralized way to retrieve OAuth tokens from specific OpenShift clusters when multiple cluster contexts are configured in the user's kubeconfig.

When to Use This Skill

Use this skill whenever you need to:

  • Get an OAuth token for API authentication from a specific OpenShift cluster
  • Verify authentication to a specific cluster
  • Work with multiple OpenShift cluster contexts simultaneously

This skill is used by all commands that need to authenticate with OpenShift clusters:

  • trigger-periodic, trigger-postsubmit, trigger-presubmit commands (app.ci cluster)
  • query-job-status command (app.ci cluster)

The skill provides a single curl_with_token.sh script that wraps curl and automatically handles OAuth token retrieval and injection, preventing accidental token exposure.

Due to a known Claude Code bug with git-installed marketplace plugins:

When referencing files from this skill (scripts, configuration files, etc.), you MUST:

  1. Always use the "Base directory" path provided at the top of this skill prompt
  2. Never assume skills are located in ~/.claude/plugins/
  3. Construct full absolute paths by combining the base directory with the relative file path

Example:

  • ❌ WRONG: ~/.claude/plugins/ci/skills/oc-auth/curl_with_token.sh
  • ✅ CORRECT: Use the base directory shown above + /curl_with_token.sh

If you see "no such file or directory" errors, verify you're using the base directory path, not the assumed marketplace cache location.

Prerequisites

  1. oc CLI Installation

  2. User Authentication

    • User must be logged in to the target cluster via browser-based authentication
    • Each oc login creates a new context in the kubeconfig

How It Works

The oc CLI maintains multiple cluster contexts in ~/.kube/config. When a user runs oc login to different clusters, each login creates a separate context. This skill:

  1. Lists all available contexts
  2. Searches for the context matching the target cluster by API server URL
  3. Retrieves the OAuth token from that specific context
  4. Returns the token for use in API calls

Common Clusters

Here are commonly used OpenShift clusters:

1. app.ci - OpenShift CI Cluster

2. dpcr - DPCR Cluster

Note: The skill supports any OpenShift cluster - simply provide the cluster's API server URL.

Usage

Script: curl_with_token.sh

A curl wrapper that automatically retrieves the OAuth token and adds it to the request, preventing token exposure.

curl_with_token.sh <cluster_api_url> [curl arguments...]

Parameters:

  • <cluster_api_url>: Full cluster API server URL (e.g., https://api.ci.l2s4.p1.openshiftapps.com:6443)
  • [curl arguments...]: All standard curl arguments (URL, headers, data, etc.)

How it works:

  1. Finds the oc context matching the specified cluster API URL
  2. Retrieves OAuth token from that cluster context
  3. Adds Authorization: Bearer <token> header automatically
  4. Executes curl with all provided arguments
  5. Token never appears in output or command history

Exit Codes:

  • 0: Success
  • 1: Invalid cluster_id or missing arguments
  • 2: No context found for the specified cluster
  • 3: Failed to retrieve token from context
  • Other: curl exit codes

Example Usage in Commands

Use the curl wrapper instead of regular curl for authenticated requests:

# Query app.ci API
curl_with_token.sh https://api.ci.l2s4.p1.openshiftapps.com:6443 -X POST \
  -d '{"job_name": "my-job", "job_execution_type": "1"}' \
  https://gangway-ci.apps.ci.l2s4.p1.openshiftapps.com/v1/executions

# Query any other OpenShift cluster API
curl_with_token.sh https://api.your-cluster.example.com:6443 -X GET \
  https://your-api.example.com/endpoint

Benefits:

  • Token never exposed in logs or output
  • Automatic authentication error handling
  • Same curl arguments you're already familiar with
  • Works with any curl flags (-v, -s, -X, -H, -d, etc.)

Error Handling

The script provides clear error messages for common scenarios:

  1. Missing or invalid arguments

    • Error: "Usage: curl_with_token.sh [curl arguments...]"
    • Shows example usage
  2. No context found

    • Error: "No oc context found for cluster with API server: {url}"
    • Provides authentication
Полный SKILL.md на GitHub

Установить oc-auth в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

README.mdcurl_with_token.sh

FAQ

Что делает скилл oc-auth?

Helper skill to retrieve OAuth tokens from the correct OpenShift cluster context when multiple clusters are configured

Как установить скилл oc-auth?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл oc-auth запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить oc-auth с