Skip to content

feat: add OpenShift AI inference provider#388

Merged
jeffmaury merged 3 commits intokortex-hub:mainfrom
jeffmaury:GH-326
Sep 19, 2025
Merged

feat: add OpenShift AI inference provider#388
jeffmaury merged 3 commits intokortex-hub:mainfrom
jeffmaury:GH-326

Conversation

@jeffmaury
Copy link
Contributor

Fixes #326

@jeffmaury jeffmaury requested a review from a team as a code owner September 18, 2025 16:38
@jeffmaury jeffmaury requested review from axel7083 and simonrey1 and removed request for a team September 18, 2025 16:38
Copy link
Contributor

@benoitf benoitf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. not tested but it won't break anything

*/
private async saveConnectionInfo(token: string, baseURL: string): Promise<void> {
// get existing tokens
const tokens = (await this.getConnectionInfos()).map(t => `${t.token}|${t.baseURL}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: introduce intermediate method to avoid doing split then map on the same separator

    private async getTokens(): Promise<string[]> {
    // get raw string from secret storage
    let raw: string | undefined;
    try {
      raw = await this.secrets.get(TOKENS_KEY);
    } catch (err: unknown) {
      console.error('OpenShift AI: something went wrong while trying to get tokens from secret storage', err);
    }
    // if undefined return empty array
    if (!raw) return [];
    // split raw string by token separator
    return raw.split(TOKEN_SEPARATOR)
  }

  /**
   * Get all connection infos from secret storage
   * @private
   */
  private async getConnectionInfos(): Promise<ConnectionInfo[]> {
    return (await this.getTokens()).map(str => {
      const [token, baseURL] = str.split(INFO_SEPARATOR);
      return {
        token,
        baseURL,
      };
    });
  }

  /**
   * Save connection info to secret storage
   * @param token
   * @param baseURL
   * @private
   */
  private async saveConnectionInfo(token: string, baseURL: string): Promise<void> {
    // get existing tokens
    const tokens = await this.getTokens();
    // concat new token with existing tokens
    const raw = [...tokens, `${token}${INFO_SEPARATOR}${baseURL}`].join(TOKEN_SEPARATOR);
    // save to secret storage
    await this.secrets.store(TOKENS_KEY, raw);
  }

  private async removeConnectionInfo(token: string, baseURL: string): Promise<void> {
    const connectionInfos = await this.getConnectionInfos();
    // filter out the token
    const raw = connectionInfos.filter(t => t.token !== token || t.baseURL !== baseURL).join(TOKEN_SEPARATOR);
    // save to secret storage
    await this.secrets.store(TOKENS_KEY, raw);
  }

Fixes kortex-hub#326

Signed-off-by: Jeff MAURY <jmaury@redhat.com>
Signed-off-by: Jeff MAURY <jmaury@redhat.com>
Signed-off-by: Jeff MAURY <jmaury@redhat.com>
Copy link
Contributor

@simonrey1 simonrey1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, not tested

@jeffmaury jeffmaury merged commit 88a2ed7 into kortex-hub:main Sep 19, 2025
7 checks passed
@jeffmaury jeffmaury deleted the GH-326 branch September 19, 2025 09:18
benoitf pushed a commit to benoitf/kortex that referenced this pull request Mar 4, 2026
gastoner pushed a commit to gastoner/kortex that referenced this pull request Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create an OpenShift AI provider

3 participants