-
Notifications
You must be signed in to change notification settings - Fork 119
feat(#4477): add caData, skipTLSVerify to OgxEntityProviderConfig #4574
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
fullsend-ai-coder
wants to merge
7
commits into
main
Choose a base branch
from
agent/4477-ogx-tls-config
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
51201df
feat(#4477): add caData, skipTLSVerify to OgxEntityProviderConfig
fullsend-ai-coder[bot] 879903d
Update workspaces/boost/app-config.yaml
gabemontero 1d2bdb4
Update workspaces/boost/app-config.yaml
gabemontero c8339ff
Update workspaces/boost/app-config.yaml
gabemontero 1483dd1
Update workspaces/boost/app-config.yaml
gabemontero 14be65f
Update workspaces/boost/app-config.yaml
gabemontero e02480b
fix(ogx-entity-provider): address review feedback on PR #4574
fullsend-ai-coder[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@red-hat-developer-hub/backstage-plugin-ogx-entity-provider': minor | ||
| --- | ||
|
|
||
| Add per-provider TLS connection settings (`caData` and `skipTLSVerify`) to `OgxEntityProviderConfig` so `OgxModelEntityProvider` can fetch `/v1/models` from OGX endpoints that use a private CA or self-signed certificates. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| /* | ||
| * Copyright Red Hat, Inc. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| /** | ||
| * Configuration schema for the OGX entity provider module. | ||
| * | ||
| * Declares the config paths read by readOgxEntityProviderConfig so that | ||
| * Backstage validates and enforces visibility on these keys even if | ||
| * the module is loaded independently of boost-backend. | ||
| */ | ||
| export interface Config { | ||
| boost?: { | ||
| /** Entity-provider-specific config (standalone deployment). */ | ||
| entityProviders?: { | ||
| /** OGX entity provider connection. */ | ||
| ogx?: { | ||
| /** | ||
| * Base URL of the OGX API endpoint. | ||
| * @configScope yaml-only | ||
| */ | ||
| baseUrl?: string; | ||
| /** | ||
| * API key for authenticated endpoints. | ||
| * @visibility secret | ||
| */ | ||
| apiKey?: string; | ||
| /** | ||
| * PEM-encoded CA certificate or certificate bundle used to verify the OGX endpoint. | ||
| * @visibility backend | ||
| */ | ||
| caData?: string; | ||
| /** | ||
| * Disable TLS certificate verification. Development use only. | ||
| * @configScope yaml-only | ||
| */ | ||
| skipTLSVerify?: boolean; | ||
| }; | ||
| }; | ||
|
|
||
| /** Provider module config (composed deployment). */ | ||
| providers?: { | ||
| /** OGX provider connection. */ | ||
| ogx?: { | ||
| /** | ||
| * Base URL of the OGX API endpoint. | ||
| * @configScope yaml-only | ||
| */ | ||
| baseUrl?: string; | ||
| /** | ||
| * API key for authenticated endpoints. | ||
| * @visibility secret | ||
| */ | ||
| apiKey?: string; | ||
| /** | ||
| * PEM-encoded CA certificate or certificate bundle used to verify the OGX endpoint. | ||
| * @visibility backend | ||
| */ | ||
| caData?: string; | ||
| /** | ||
| * Disable TLS certificate verification. Development use only. | ||
| * @configScope yaml-only | ||
| */ | ||
| skipTLSVerify?: boolean; | ||
| }; | ||
| }; | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 116 additions & 0 deletions
116
workspaces/boost/plugins/ogx-entity-provider/src/module.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| /* | ||
| * Copyright Red Hat, Inc. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import { ConfigReader } from '@backstage/config'; | ||
|
|
||
| import { readOgxEntityProviderConfig } from './module'; | ||
|
|
||
| describe('readOgxEntityProviderConfig', () => { | ||
| it('reads caData and skipTLSVerify from boost.entityProviders.ogx', () => { | ||
| const config = new ConfigReader({ | ||
| boost: { | ||
| entityProviders: { | ||
| ogx: { | ||
| baseUrl: 'https://ogx.example.com', | ||
| caData: | ||
| '-----BEGIN CERTIFICATE-----\nMIIBxTCC...\n-----END CERTIFICATE-----', | ||
| skipTLSVerify: true, | ||
| }, | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| const result = readOgxEntityProviderConfig(config); | ||
|
|
||
| expect(result.baseUrl).toBe('https://ogx.example.com'); | ||
| expect(result.caData).toBe( | ||
| '-----BEGIN CERTIFICATE-----\nMIIBxTCC...\n-----END CERTIFICATE-----', | ||
| ); | ||
| expect(result.skipTLSVerify).toBe(true); | ||
| }); | ||
|
|
||
| it('reads caData and skipTLSVerify from fallback boost.providers.ogx', () => { | ||
| const config = new ConfigReader({ | ||
| boost: { | ||
| providers: { | ||
| ogx: { | ||
| baseUrl: 'https://ogx-fallback.example.com', | ||
| caData: 'PEM-CERT-DATA', | ||
| skipTLSVerify: false, | ||
| }, | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| const result = readOgxEntityProviderConfig(config); | ||
|
|
||
| expect(result.baseUrl).toBe('https://ogx-fallback.example.com'); | ||
| expect(result.caData).toBe('PEM-CERT-DATA'); | ||
| expect(result.skipTLSVerify).toBe(false); | ||
| }); | ||
|
|
||
| it('returns undefined for caData and skipTLSVerify when not configured', () => { | ||
| const config = new ConfigReader({ | ||
| boost: { | ||
| entityProviders: { | ||
| ogx: { | ||
| baseUrl: 'http://localhost:8321', | ||
| }, | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| const result = readOgxEntityProviderConfig(config); | ||
|
|
||
| expect(result.baseUrl).toBe('http://localhost:8321'); | ||
| expect(result.caData).toBeUndefined(); | ||
| expect(result.skipTLSVerify).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('falls back to localhost when no OGX config is present', () => { | ||
| const config = new ConfigReader({}); | ||
|
|
||
| const result = readOgxEntityProviderConfig(config); | ||
|
|
||
| expect(result.baseUrl).toBe('http://localhost:8321'); | ||
| expect(result.caData).toBeUndefined(); | ||
| expect(result.skipTLSVerify).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('prefers entityProviders.ogx over providers.ogx', () => { | ||
| const config = new ConfigReader({ | ||
| boost: { | ||
| entityProviders: { | ||
| ogx: { | ||
| baseUrl: 'https://primary.example.com', | ||
| caData: 'PRIMARY-CA', | ||
| }, | ||
| }, | ||
| providers: { | ||
| ogx: { | ||
| baseUrl: 'https://fallback.example.com', | ||
| caData: 'FALLBACK-CA', | ||
| }, | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| const result = readOgxEntityProviderConfig(config); | ||
|
|
||
| expect(result.baseUrl).toBe('https://primary.example.com'); | ||
| expect(result.caData).toBe('PRIMARY-CA'); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -114,8 +114,10 @@ export const catalogModuleOgxEntityProvider = createBackendModule({ | |
|
|
||
| /** | ||
| * Read OGX entity provider configuration from app-config.yaml. | ||
| * | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [low] export-scope readOgxEntityProviderConfig exported for testing with @internal annotation. Not re-exported from index.ts, so the public API is unaffected. |
||
| * @internal Exported for testing only. | ||
| */ | ||
| function readOgxEntityProviderConfig( | ||
| export function readOgxEntityProviderConfig( | ||
| config: typeof coreServices.rootConfig extends { T: infer T } ? T : never, | ||
| ): OgxEntityProviderConfig { | ||
| // Try the entity-provider-specific config first | ||
|
|
@@ -134,6 +136,8 @@ function readOgxEntityProviderConfig( | |
| defaultAgent: epConfig.getOptionalString('defaultAgent'), | ||
| maxAgentTurns: epConfig.getOptionalNumber('maxAgentTurns'), | ||
| agents: readAgentConfigs(epConfig), | ||
| caData: epConfig.getOptionalString('caData'), | ||
| skipTLSVerify: epConfig.getOptionalBoolean('skipTLSVerify'), | ||
| }; | ||
| } | ||
|
|
||
|
|
@@ -147,6 +151,8 @@ function readOgxEntityProviderConfig( | |
| defaultAgent: providerConfig.getOptionalString('defaultAgent'), | ||
| maxAgentTurns: providerConfig.getOptionalNumber('maxAgentTurns'), | ||
| agents: readAgentConfigs(providerConfig), | ||
| caData: providerConfig.getOptionalString('caData'), | ||
| skipTLSVerify: providerConfig.getOptionalBoolean('skipTLSVerify'), | ||
| }; | ||
| } | ||
|
|
||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[low] JSDoc-style
@internal Exported for testing only. diverges from existing @internal annotations in this package which use the tag alone.