Skip to content

Commit aa52b3d

Browse files
Merge branch 'develop' into createAttachments
2 parents a748b56 + f9c2b3f commit aa52b3d

17 files changed

Lines changed: 475 additions & 861 deletions

.github/workflows/integration_test.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,19 @@ on:
77
description: 'Specify the Cloud Foundry space to run integration tests on'
88
required: true
99

10+
branch_name:
11+
description: 'Specify the branch to use for integration tests'
12+
required: true
13+
1014
jobs:
1115
integration-test:
1216
runs-on: ubuntu-latest
1317

1418
steps:
1519
- name: Checkout repository
1620
uses: actions/checkout@v2
21+
with:
22+
ref: ${{ github.event.inputs.branch_name }}
1723

1824
- name: Set up Java 17
1925
uses: actions/setup-java@v3
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Multi Tenancy Deployment
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
cf_space:
7+
description: 'Specify the Cloud Foundry space to deploy to'
8+
required: true
9+
default: 'developcap'
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout this repository
17+
uses: actions/checkout@v2
18+
19+
- name: Set up JDK 21
20+
uses: actions/setup-java@v3
21+
with:
22+
distribution: 'temurin'
23+
java-version: '21'
24+
25+
- name: Build and package
26+
run: |
27+
mvn clean install -P unit-tests -DskipIntegrationTests
28+
29+
- name: Setup Node.js
30+
uses: actions/setup-node@v3
31+
with:
32+
node-version: '18' # Change this to at least version 18
33+
34+
- name: Install MBT
35+
run: npm install -g mbt
36+
37+
- name: Clone the cloud-cap-samples-java repo
38+
run: git clone --depth 1 --branch mtTests https://github.com/vibhutikumar07/cloud-cap-samples-java.git
39+
40+
- name: Change directory to cloud-cap-samples-java
41+
working-directory: cloud-cap-samples-java
42+
run: pwd # Verifies that we're in the correct directory
43+
44+
- name: Run mbt build
45+
working-directory: cloud-cap-samples-java
46+
run: |
47+
echo "java version"
48+
java --version
49+
mbt build
50+
51+
- name: Deploy to Cloud Foundry
52+
working-directory: cloud-cap-samples-java
53+
run: |
54+
echo "Deploying to ${{ github.event.inputs.cf_space }}......"
55+
56+
# Install cf CLI plugin
57+
58+
wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo tee /etc/apt/trusted.gpg.d/cloudfoundry.asc
59+
echo "deb https://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list
60+
sudo apt update
61+
sudo apt install cf-cli
62+
63+
cf install-plugin multiapps -f
64+
65+
# Login to Cloud Foundry again to ensure session is active
66+
cf login -a ${{ secrets.CF_API }} -u ${{ secrets.CF_USER }} -p ${{ secrets.CF_PASSWORD }} -o ${{ secrets.CF_ORG }} -s ${{ github.event.inputs.cf_space }}
67+
68+
# Deploy the application
69+
echo "Current directory.."
70+
pwd
71+
ls -lrth
72+
echo "Running cf deploy"
73+
cf deploy mta_archives/bookshop-mt_1.0.0.mtar -f
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Multi Tenancy Deploy
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches:
7+
- develop
8+
workflow_dispatch:
9+
10+
permissions:
11+
pull-requests: read
12+
packages: read # Added permission to read packages
13+
14+
jobs:
15+
deploy:
16+
if: github.event.pull_request.merged == true
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
21+
- name: Wait for 5 minutes # Added a 5-minute delay to ensure the snapshot is deployed successfully before initiating the deployment job.
22+
run: sleep 300
23+
24+
- name: Checkout this repository
25+
uses: actions/checkout@v2
26+
27+
- name: Set up JDK 21
28+
uses: actions/setup-java@v3
29+
with:
30+
distribution: 'temurin'
31+
java-version: '21'
32+
33+
- name: Build and package
34+
run: |
35+
mvn clean install -P unit-tests -DskipIntegrationTests
36+
37+
- name: Setup Node.js
38+
uses: actions/setup-node@v3
39+
with:
40+
node-version: '18' # Change this to at least version 18
41+
42+
- name: Install MBT
43+
run: npm install -g mbt
44+
45+
- name: Clone the cloud-cap-samples-java repo
46+
run: git clone --depth 1 --branch mtTests https://github.com/vibhutikumar07/cloud-cap-samples-java.git
47+
48+
- name: Change directory to cloud-cap-samples-java
49+
working-directory: cloud-cap-samples-java
50+
run: pwd # Verifies that we're in the correct directory
51+
52+
- name: Run mbt build
53+
working-directory: cloud-cap-samples-java
54+
run: |
55+
echo "java version"
56+
java --version
57+
mbt build
58+
59+
- name: Deploy to Cloud Foundry
60+
working-directory: cloud-cap-samples-java
61+
run: |
62+
echo "Deploying to ${{ secrets.CF_SPACE }}......"
63+
64+
# Install cf CLI plugin
65+
66+
wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo tee /etc/apt/trusted.gpg.d/cloudfoundry.asc
67+
echo "deb https://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list
68+
sudo apt update
69+
sudo apt install cf-cli
70+
71+
cf install-plugin multiapps -f
72+
73+
# Login to Cloud Foundry again to ensure session is active
74+
cf login -a ${{ secrets.CF_API }} -u ${{ secrets.CF_USER }} -p ${{ secrets.CF_PASSWORD }} -o ${{ secrets.CF_ORG }} -s ${{ secrets.CF_SPACE }}
75+
76+
# Deploy the application
77+
echo "Current directory.."
78+
pwd
79+
ls -lrth
80+
echo "Running cf deploy"
81+
cf deploy mta_archives/bookshop-mt_1.0.0.mtar -f

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44
This project adheres to [Semantic Versioning](http://semver.org/).
55
The format is based on [Keep a Changelog](http://keepachangelog.com/).
66

7+
## Version 1.4.1
8+
9+
### Fixed
10+
11+
- An issue related to IAS token fetch. Now plugin works with IAS flow as well.
12+
713
## Version 1.4.0
814

915
### Added

README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,36 @@ Follow these steps if you want to integrate the SDM CAP Plugin with your own CAP
314314

315315
## Support for Multitenancy
316316

317-
This plugin provides APIs for onboarding and offboarding of repositories for multitenant CAP SaaS applications. Refer the below example where onboarding and offboarding APIs are used on tenant subscription and tenant unsubscription events of SaaS application.
317+
318+
This plugin provides APIs for onboarding and offboarding of repositories for multitenant CAP SaaS applications.
319+
320+
GetDependencies,subscribe and unsubscribe are the mandatory steps to be performed to support multitenancy.
321+
322+
Refer the below example to pass the SDM Service dependencies to SaaSRegistry so that SDM credentials are passed to subscribing tenant.
323+
```java
324+
//Set the SDM xsappname to SaaS Registry Dependency.
325+
@On(event = DeploymentService.EVENT_DEPENDENCIES)
326+
public void onGetDependencies(DependenciesEventContext context) {
327+
328+
List<SaasRegistryDependency> dependencies = new ArrayList<>();
329+
Map<String, Object> uaa = (Map<String, Object>) getSDMCredentials().get("uaa");
330+
dependencies.add(SaasRegistryDependency.create(uaa.get("xsappname").toString()));
331+
context.setResult(dependencies);
332+
}
333+
//Fetch the SDM service credentials
334+
private Map<String, Object> getSDMCredentials() {
335+
List<ServiceBinding> allServiceBindings =
336+
DefaultServiceBindingAccessor.getInstance().getServiceBindings();
337+
ServiceBinding sdmBinding =
338+
allServiceBindings.stream()
339+
.filter(binding -> "sdm".equalsIgnoreCase(binding.getServiceName().orElse(null)))
340+
.findFirst()
341+
.get();
342+
return sdmBinding.getCredentials();
343+
344+
}
345+
```
346+
Refer the below example where onboarding and offboarding APIs are used on tenant subscription and tenant unsubscription events of SaaS application.
318347

319348
```java
320349
@After(event = DeploymentService.EVENT_SUBSCRIBE)

0 commit comments

Comments
 (0)