-
Notifications
You must be signed in to change notification settings - Fork 60
feat: Extend add-new-model generator to support external services for CF projects #4523
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
Merged
Merged
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
7ec0e84
feat: Extend add-new-model generator to support external services for…
mmilko01 72da9ea
fix: various fixes
mmilko01 3b4fc46
fix: add additional message for annotation URI prompt
mmilko01 9998d2a
chore: resolve conflicts
mmilko01 d35a6fa
Linting auto fix commit
github-actions[bot] f52d6c3
fix: remove install and build steps from generator
mmilko01 abe6ca5
Merge branch 'feat/add-external-service-cf' of https://github.com/SAP…
mmilko01 e9b501a
refactor: remove unneeded code
mmilko01 bc623f6
chore: create changeset
mmilko01 e360a3e
chore: fix changeset
mmilko01 08469db
test: fix tests for windows
mmilko01 f984760
test: fix tests for windows
mmilko01 1e569e2
test: fix api tests file format
mmilko01 fb18f4d
refactor: move btp related api call to /btp
mmilko01 236a9c4
fix: sonar issues
mmilko01 21be925
Linting auto fix commit
github-actions[bot] 53a3786
fix: address comments
mmilko01 2bf588e
Merge
mmilko01 75df0e2
fix: address text comments
mmilko01 88ad967
fix: sonar issue
mmilko01 c0990ea
Linting auto fix commit
github-actions[bot] 0123c19
fix: expected texts in tests
mmilko01 4c75522
Merge branch 'feat/add-external-service-cf' of https://github.com/SAP…
mmilko01 010704a
fix: for HTTP service type use different change type
mmilko01 f5056bf
fix: address comments
mmilko01 26509c2
Merge branch 'main' into feat/add-external-service-cf
mmilko01 d11c3cb
chore: address text comments
mmilko01 ba12478
Merge branch 'main' into feat/add-external-service-cf
mmilko01 d513390
fix: translations json
mmilko01 39106d6
fix: lint issue
mmilko01 c278645
Merge branch 'main' into feat/add-external-service-cf
mmilko01 5374259
chore: simplify code
mmilko01 b2c143f
Merge branch 'feat/add-external-service-cf' of https://github.com/SAP…
mmilko01 54a699d
fix: address comments
mmilko01 0b97b86
test: update changed text
mmilko01 9d6ee47
fix: validation for duplicate change
mmilko01 87a8d3f
fix: add check for org/space mismatch
mmilko01 c9597aa
fix: remove leading slash in CF scenario for change uri
mmilko01 67f96f6
Linting auto fix commit
github-actions[bot] b9183e5
Merge branch 'main' into feat/add-external-service-cf
mmilko01 7c21623
Merge branch 'main' into feat/add-external-service-cf
nikmace 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,7 @@ | ||
| --- | ||
| "@sap-ux/adp-tooling": patch | ||
| "@sap-ux/generator-adp": patch | ||
| "@sap-ux/create": patch | ||
| --- | ||
|
|
||
| feat: Extend add-new-model generator to support external services for CF projects |
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
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
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,49 @@ | ||
| import * as path from 'node:path'; | ||
|
|
||
| import type { Destinations } from '@sap-ux/btp-utils'; | ||
|
|
||
| import { getOrCreateServiceInstanceKeys } from './api'; | ||
| import { listBtpDestinations } from '../../btp/api'; | ||
| import { getYamlContent } from '../project/yaml-loader'; | ||
| import { t } from '../../i18n'; | ||
| import type { CfDestinationServiceCredentials, MtaYaml } from '../../types'; | ||
|
|
||
| /** | ||
| * Finds the name of the destination service instance declared in the MTA project's mta.yaml. | ||
| * | ||
| * @param {string} projectPath - The root path of the app project. | ||
| * @returns {string} The CF service instance name. | ||
| * @throws {Error} When the destination service instance is not found or mta.yaml cannot be read. | ||
| */ | ||
| function getDestinationServiceName(projectPath: string): string { | ||
| try { | ||
| const yamlContent = getYamlContent<MtaYaml>(path.join(path.dirname(projectPath), 'mta.yaml')); | ||
| const name = yamlContent?.resources?.find((r) => r.parameters?.service === 'destination')?.name; | ||
| if (!name) { | ||
| throw new Error(t('error.destinationServiceNotFoundInMtaYaml')); | ||
| } | ||
| return name; | ||
| } catch (e) { | ||
| throw e instanceof Error ? e : new Error(t('error.destinationServiceNotFoundInMtaYaml')); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Returns the list of available BTP destinations from the logged-in CF subaccount. | ||
| * Reads the destination service credentials from the CF project's service keys | ||
| * and calls the BTP Destination Configuration API directly. | ||
| * | ||
| * @param {string} projectPath - The root path of the CF app project. | ||
| * @returns {Promise<Destinations>} Map of destination name to Destination object. | ||
| */ | ||
| export async function getBtpDestinations(projectPath: string): Promise<Destinations> { | ||
| const destinationServiceName = getDestinationServiceName(projectPath); | ||
|
|
||
| const serviceInfo = await getOrCreateServiceInstanceKeys({ names: [destinationServiceName] }); | ||
| if (!serviceInfo?.serviceKeys?.length) { | ||
| throw new Error(t('error.noServiceKeysFoundForDestination', { serviceInstanceName: destinationServiceName })); | ||
| } | ||
|
|
||
| const credentials = serviceInfo.serviceKeys[0].credentials as CfDestinationServiceCredentials; | ||
| return listBtpDestinations(credentials); | ||
| } |
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 |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| export * from './api'; | ||
| export * from './ssh'; | ||
| export * from './cli'; | ||
| export * from './destinations'; | ||
| export * from './manifest'; |
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.
Uh oh!
There was an error while loading. Please reload this page.