├── .github
├── labels-manage.yml
├── settings.xml
└── workflows
│ ├── build-snapshot-worker.yml
│ ├── ci-pr.yml
│ ├── ci.yml
│ ├── issue-handler.yml
│ ├── label-manage.yml
│ ├── milestone-worker.yml
│ ├── next-dev-version-worker.yml
│ └── release-worker.yml
├── .gitignore
├── .jdk8
├── .mvn
├── jvm.config
├── maven.config
└── wrapper
│ ├── maven-wrapper.jar
│ └── maven-wrapper.properties
├── .vscode
└── settings.json
├── CODE_OF_CONDUCT.adoc
├── CONTRIBUTING.adoc
├── LICENSE
├── NOTICE
├── README.md
├── mvnw
├── mvnw.cmd
├── pom.xml
└── src
├── main
├── java
│ └── org
│ │ └── springframework
│ │ └── cloud
│ │ └── deployer
│ │ └── spi
│ │ ├── cloudfoundry
│ │ ├── AbstractCloudFoundryDeployer.java
│ │ ├── AbstractCloudFoundryTaskLauncher.java
│ │ ├── AppNameGenerator.java
│ │ ├── CfEnvAwareAppDeploymentRequest.java
│ │ ├── CfEnvAwareResource.java
│ │ ├── CfEnvConfigurer.java
│ │ ├── CloudFoundryActuatorTemplate.java
│ │ ├── CloudFoundryAppDeployer.java
│ │ ├── CloudFoundryAppInstanceStatus.java
│ │ ├── CloudFoundryAppNameGenerator.java
│ │ ├── CloudFoundryConnectionProperties.java
│ │ ├── CloudFoundryDeployerAutoConfiguration.java
│ │ ├── CloudFoundryDeploymentProperties.java
│ │ ├── CloudFoundryPlatformSpecificInfo.java
│ │ ├── CloudFoundryTaskLauncher.java
│ │ ├── DurationConverter.java
│ │ ├── ServiceParser.java
│ │ └── UnsupportedVersionTaskLauncher.java
│ │ └── scheduler
│ │ └── cloudfoundry
│ │ ├── CloudFoundryAppScheduler.java
│ │ ├── CloudFoundryScheduleSSLException.java
│ │ ├── CloudFoundrySchedulerProperties.java
│ │ └── expression
│ │ └── QuartzCronExpression.java
└── resources
│ └── META-INF
│ ├── additional-spring-configuration-metadata.json
│ ├── spring.factories
│ └── spring
│ └── org.springframework.boot.autoconfigure.AutoConfiguration.imports
├── scripts
├── next-minor-parent-snapshot-version
├── next-minor-snapshot-version
├── next-parent-snapshot-version
└── next-snapshot-version
└── test
├── java
└── org
│ └── springframework
│ └── cloud
│ └── deployer
│ └── spi
│ ├── cloudfoundry
│ ├── AbstractAppDeployerTestSupport.java
│ ├── CfEnvAwareResourceTests.java
│ ├── CfEnvConfigurerTests.java
│ ├── CloudFoundryActuatorTemplateTests.java
│ ├── CloudFoundryAppDeployerIntegrationIT.java
│ ├── CloudFoundryAppDeployerTests.java
│ ├── CloudFoundryAppNameGeneratorTest.java
│ ├── CloudFoundryConnectionPropertiesTests.java
│ ├── CloudFoundryDeployerTests.java
│ ├── CloudFoundryTaskLauncherCachingTests.java
│ ├── CloudFoundryTaskLauncherIntegrationIT.java
│ ├── CloudFoundryTaskLauncherTests.java
│ └── ServiceParserTests.java
│ └── scheduler
│ └── cloudfoundry
│ ├── CloudFoundryAppSchedulerTests.java
│ ├── CloudFoundryScheduleSSLExceptionTests.java
│ ├── CloudFoundrySchedulerPropertiesTest.java
│ ├── SpringCloudSchedulerIntegrationIT.java
│ └── expression
│ └── QuartzCronExpressionTests.java
└── resources
├── actuator-binding-input.json
├── actuator-bindings.json
├── actuator-info.json
├── batch-job-1.0.0.BUILD-SNAPSHOT.jar
├── demo-0.0.1-SNAPSHOT.jar
├── http-source-rabbit-2.1.5.RELEASE.jar
├── log-sink-rabbit-3.0.0.BUILD-SNAPSHOT.jar
├── logback-test.xml
├── long-running-task-1.0.0.BUILD-SNAPSHOT.jar
├── test-application.zip
├── timestamp-task-1.0.0.BUILD-SNAPSHOT-exec-2.jar
├── timestamp-task-1.0.0.BUILD-SNAPSHOT-exec-3.jar
└── timestamp-task-1.0.0.BUILD-SNAPSHOT-exec.jar
/.github/labels-manage.yml:
--------------------------------------------------------------------------------
1 | - name: area/dependencies
2 | color: F9D0C4
3 | description: Belongs project dependencies
4 | - name: area/documentation
5 | color: F9D0C4
6 | description: Belongs to documentation
7 | - name: area/tests
8 | color: F9D0C4
9 | description: Belongs to tests
10 |
11 | - name: automation/rlnotes-header
12 | color: EDEDED
13 | description: Belongs to release notes automation
14 | - name: automation/rlnotes-footer
15 | color: EDEDED
16 | description: Belongs to release notes automation
17 |
18 | - name: for/backport
19 | color: E99695
20 | description: For backporting
21 | - name: for/blocker
22 | color: E99695
23 | description: For blocking
24 | - name: for/marketing
25 | color: E99695
26 | description: For marketing
27 | - name: for/spike
28 | color: E99695
29 | description: For spike
30 | - name: for/team-attention
31 | color: E99695
32 | description: For team attention
33 |
34 | - name: status/complete
35 | color: FEF2C0
36 | description: Issue is now complete
37 | - name: status/declined
38 | color: FEF2C0
39 | description: Issue has been declined
40 | - name: status/duplicate
41 | color: FEF2C0
42 | description: There were an existing issue
43 | - name: status/in-progress
44 | color: FEF2C0
45 | description: Something is happening
46 | - name: status/invalid
47 | color: FEF2C0
48 | description: Mistake, bogus, old, bye bye
49 | - name: status/need-design
50 | color: FEF2C0
51 | description: Vague so need some proper design
52 | - name: status/need-feedback
53 | color: FEF2C0
54 | description: Calling participant to provide feedback
55 | - name: status/need-investigation
56 | color: FEF2C0
57 | description: Oh need to look under a hood
58 | - name: status/need-triage
59 | color: FEF2C0
60 | description: Team needs to triage and take a first look
61 | - name: status/on-hold
62 | color: FEF2C0
63 | description: For various reasons is on hold
64 | - name: status/stale
65 | color: FEF2C0
66 | description: Marked as stale
67 | - name: status/closed-as-stale
68 | color: FEF2C0
69 | description: Closed as has been stale
70 |
71 | - name: type/automated-pr
72 | color: D4C5F9
73 | description: Is an automated pr
74 | - name: type/backport
75 | color: D4C5F9
76 | description: Is a issue to track backport, use with branch/xxx
77 | - name: type/bug
78 | color: D4C5F9
79 | description: Is a bug report
80 | - name: type/enhancement
81 | color: D4C5F9
82 | description: Is an enhancement request
83 | - name: type/epic
84 | color: D4C5F9
85 | description: Collection of issues
86 | - name: type/feature
87 | color: D4C5F9
88 | description: Is a feature request
89 | - name: type/help-needed
90 | color: D4C5F9
91 | description: Calling help
92 | - name: type/idea
93 | color: D4C5F9
94 | description: Is just an idea
95 | - name: type/task
96 | color: D4C5F9
97 | description: Something needs to get done
98 | - name: type/technical-debt
99 | color: D4C5F9
100 | description: Techical Dept
101 | - name: type/question
102 | color: D4C5F9
103 | description: Is a question
104 |
105 | - name: branch/1.0.x
106 | color: BFDADC
107 | description: Issue for a branch
108 | - name: branch/1.1.x
109 | color: BFDADC
110 | description: Issue for a branch
111 | - name: branch/1.3.x
112 | color: BFDADC
113 | description: Issue for a branch
114 | - name: branch/1.4.x
115 | color: BFDADC
116 | description: Issue for a branch
117 | - name: branch/2.0.x
118 | color: BFDADC
119 | description: Issue for a branch
120 | - name: branch/2.1.x
121 | color: BFDADC
122 | description: Issue for a branch
123 | - name: branch/2.2.x
124 | color: BFDADC
125 | description: Issue for a branch
126 | - name: branch/2.3.x
127 | color: BFDADC
128 | description: Issue for a branch
129 | - name: branch/2.4.x
130 | color: BFDADC
131 | description: Issue for a branch
132 | - name: branch/2.5.x
133 | color: BFDADC
134 | description: Issue for a branch
135 | - name: branch/2.6.x
136 | color: BFDADC
137 | description: Issue for a branch
138 | - name: branch/2.7.x
139 | color: BFDADC
140 | description: Issue for a branch
141 |
--------------------------------------------------------------------------------
/.github/settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | stagingmilestone
5 |
6 |
7 | spring-staging
8 | Spring Staging
9 | https://repo.spring.io/staging
10 |
11 | false
12 |
13 |
14 |
15 | spring-milestones
16 | Spring Milestones
17 | https://repo.spring.io/milestone
18 |
19 | false
20 |
21 |
22 |
23 | maven-central
24 | Maven Central
25 | https://repo.maven.apache.org/maven2
26 |
27 | false
28 |
29 |
30 |
31 |
32 | maven-central-spring-milestones
33 | Maven Central Spring Milestones
34 | https://repo.spring.io/libs-milestone
35 |
36 | true
37 |
38 |
39 |
40 |
41 |
42 | spring-staging
43 | Spring Staging
44 | https://repo.spring.io/staging
45 |
46 | false
47 |
48 |
49 |
50 | spring-milestones
51 | Spring Milestones
52 | https://repo.spring.io/milestone
53 |
54 | false
55 |
56 |
57 |
58 | maven-central
59 | Maven Central
60 | https://repo.maven.apache.org/maven2
61 |
62 | false
63 |
64 |
65 |
66 |
67 |
68 | stagingrelease
69 |
70 |
71 | spring-staging
72 | Spring Staging
73 | https://repo.spring.io/staging
74 |
75 | false
76 |
77 |
78 |
79 | maven-central
80 | Maven Central
81 | https://repo.maven.apache.org/maven2
82 |
83 | false
84 |
85 |
86 |
87 |
88 | maven-central-spring-milestones
89 | Maven Central Spring Milestones
90 | https://repo.spring.io/libs-milestone
91 |
92 | true
93 |
94 |
95 |
96 |
97 |
98 | spring-staging
99 | Spring Staging
100 | https://repo.spring.io/staging
101 |
102 | false
103 |
104 |
105 |
106 | maven-central
107 | Maven Central
108 | https://repo.maven.apache.org/maven2
109 |
110 | false
111 |
112 |
113 |
114 |
115 |
116 |
117 |
--------------------------------------------------------------------------------
/.github/workflows/build-snapshot-worker.yml:
--------------------------------------------------------------------------------
1 | # Worker which is dispatched from build-snapshot-controller workflow.
2 | name: Build Snapshot Worker
3 |
4 | on:
5 | workflow_dispatch:
6 | inputs:
7 | build-zoo-handler:
8 | description: 'Build Zoo Handler Payload'
9 | required: true
10 |
11 | jobs:
12 | build:
13 | runs-on: ubuntu-latest
14 | steps:
15 |
16 | - uses: actions/checkout@v2
17 | - uses: actions/setup-java@v1
18 | with:
19 | java-version: 1.8
20 | - uses: jvalkeal/setup-maven@v1
21 | with:
22 | maven-version: 3.6.3
23 | - uses: jfrog/setup-jfrog-cli@v1
24 | with:
25 | version: 1.46.4
26 | env:
27 | JF_ARTIFACTORY_SPRING: ${{ secrets.JF_ARTIFACTORY_SPRING }}
28 |
29 | # cache maven .m2
30 | - uses: actions/cache@v2
31 | with:
32 | path: ~/.m2/repository
33 | key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
34 | restore-keys: |
35 | ${{ runner.os }}-m2-
36 |
37 | # target deploy repos
38 | - name: Configure JFrog Cli
39 | run: |
40 | jfrog rt mvnc \
41 | --server-id-resolve=repo.spring.io \
42 | --server-id-deploy=repo.spring.io \
43 | --repo-resolve-releases=libs-milestone \
44 | --repo-resolve-snapshots=libs-snapshot \
45 | --repo-deploy-releases=libs-release-local \
46 | --repo-deploy-snapshots=libs-snapshot-local
47 | echo JFROG_CLI_BUILD_NAME=spring-cloud-deployer-cloudfoundry-main >> $GITHUB_ENV
48 | echo JFROG_CLI_BUILD_NUMBER=$GITHUB_RUN_NUMBER >> $GITHUB_ENV
49 |
50 | # zoo extract and ensure
51 | - name: Extract Zoo Context Properties
52 | uses: jvalkeal/build-zoo-handler@v0.0.4
53 | with:
54 | dispatch-handler-extract-context-properties: true
55 |
56 | # build and publish to configured target
57 | - name: Build and Publish
58 | run: |
59 | jfrog rt mvn -U -B clean install
60 | jfrog rt build-publish
61 | echo BUILD_ZOO_HANDLER_spring_cloud_deployer_cloudfoundry_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) >> $GITHUB_ENV
62 | echo BUILD_ZOO_HANDLER_spring_cloud_deployer_cloudfoundry_buildname=spring-cloud-deployer-cloudfoundry-main >> $GITHUB_ENV
63 | echo BUILD_ZOO_HANDLER_spring_cloud_deployer_cloudfoundry_buildnumber=$GITHUB_RUN_NUMBER >> $GITHUB_ENV
64 |
65 | # zoo success
66 | - name: Notify Build Success Zoo Handler Controller
67 | uses: jvalkeal/build-zoo-handler@v0.0.4
68 | with:
69 | dispatch-handler-token: ${{ secrets.SCDF_ACCESS_TOKEN }}
70 | dispatch-handler-client-payload-data: >
71 | {
72 | "event": "build-succeed"
73 | }
74 |
75 | # zoo failure
76 | - name: Notify Build Failure Zoo Handler Controller
77 | if: ${{ failure() }}
78 | uses: jvalkeal/build-zoo-handler@v0.0.4
79 | with:
80 | dispatch-handler-token: ${{ secrets.SCDF_ACCESS_TOKEN }}
81 | dispatch-handler-client-payload-data: >
82 | {
83 | "event": "build-failed",
84 | "message": "spring-cloud-deployer-cloudfoundry failed"
85 | }
86 | # clean m2 cache
87 | - name: Clean cache
88 | run: |
89 | find ~/.m2/repository -type d -name '*SNAPSHOT' | xargs rm -fr
90 |
--------------------------------------------------------------------------------
/.github/workflows/ci-pr.yml:
--------------------------------------------------------------------------------
1 | name: CI PRs
2 |
3 | on:
4 | pull_request:
5 |
6 | jobs:
7 | build:
8 | runs-on: ubuntu-latest
9 | steps:
10 | - uses: actions/checkout@v2
11 | # cache maven repo
12 | - uses: actions/cache@v2
13 | with:
14 | path: ~/.m2/repository
15 | key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
16 | restore-keys: |
17 | ${{ runner.os }}-m2-
18 | # jdk8
19 | - uses: actions/setup-java@v1
20 | with:
21 | java-version: 1.8
22 | # maven version
23 | - uses: jvalkeal/setup-maven@v1
24 | with:
25 | maven-version: 3.6.2
26 | # build
27 | - name: Build
28 | run: |
29 | mvn -U -B clean package
30 | # clean m2 cache
31 | - name: Clean cache
32 | run: |
33 | find ~/.m2/repository -type d -name '*SNAPSHOT' | xargs rm -fr
34 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 |
3 | on:
4 | workflow_dispatch:
5 | push:
6 | paths-ignore:
7 | - '.github/**'
8 |
9 | jobs:
10 | build:
11 | if: github.repository_owner == 'spring-cloud'
12 | runs-on: ubuntu-latest
13 | steps:
14 | - uses: actions/checkout@v2
15 | # cache maven repo
16 | - uses: actions/cache@v2
17 | with:
18 | path: ~/.m2/repository
19 | key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
20 | restore-keys: |
21 | ${{ runner.os }}-m2-
22 | # jdk8
23 | - uses: actions/setup-java@v1
24 | with:
25 | java-version: 1.8
26 | # maven version
27 | - uses: jvalkeal/setup-maven@v1
28 | with:
29 | maven-version: 3.6.2
30 | # jfrog cli
31 | - uses: jfrog/setup-jfrog-cli@v1
32 | with:
33 | version: 1.46.4
34 | env:
35 | JF_ARTIFACTORY_SPRING: ${{ secrets.JF_ARTIFACTORY_SPRING }}
36 | # setup frog cli
37 | - name: Configure JFrog Cli
38 | run: |
39 | jfrog rt mvnc \
40 | --server-id-resolve=repo.spring.io \
41 | --server-id-deploy=repo.spring.io \
42 | --repo-resolve-releases=libs-milestone \
43 | --repo-resolve-snapshots=libs-snapshot \
44 | --repo-deploy-releases=libs-release-local \
45 | --repo-deploy-snapshots=libs-snapshot-local
46 | echo JFROG_CLI_BUILD_NAME=spring-cloud-deployer-cloudfoundry-main >> $GITHUB_ENV
47 | echo JFROG_CLI_BUILD_NUMBER=$GITHUB_RUN_NUMBER >> $GITHUB_ENV
48 | # build and publish
49 | - name: Build and Publish
50 | run: |
51 | jfrog rt mvn -U -B clean install
52 | jfrog rt build-publish
53 | # clean m2 cache
54 | - name: Clean cache
55 | run: |
56 | find ~/.m2/repository -type d -name '*SNAPSHOT' | xargs rm -fr
57 |
--------------------------------------------------------------------------------
/.github/workflows/issue-handler.yml:
--------------------------------------------------------------------------------
1 | name: Issue Handler
2 |
3 | on:
4 | workflow_dispatch:
5 | issues:
6 | types: [opened, labeled, unlabeled]
7 | issue_comment:
8 | types: [created]
9 |
10 | jobs:
11 | labeler:
12 | runs-on: ubuntu-latest
13 | steps:
14 |
15 | - name: Handle Issues
16 | uses: jvalkeal/issue-handler@v0.0.4
17 | with:
18 | token: ${{ secrets.GITHUB_TOKEN }}
19 | config: >
20 | {
21 | "data": {
22 | "team": [
23 | "jvalkeal",
24 | "oodamien",
25 | "ilayaperumalg",
26 | "sabbyanandan",
27 | "tzolov",
28 | "chrisjs",
29 | "cppwfs",
30 | "mminella",
31 | "dturanski",
32 | "onobc",
33 | "claudiahub",
34 | "sobychacko"
35 | ]
36 | },
37 | "recipes": [
38 | {
39 | "name": "Mark new issue to get triaged",
40 | "type": "ifThen",
41 | "if": "isAction('opened') && !dataInArray('team', actor)",
42 | "then": "labelIssue(['status/need-triage'])"
43 | },
44 | {
45 | "name": "Switch to team if user comments",
46 | "type": "ifThen",
47 | "if": "isEvent('issue_comment') && isAction('created') && actor == context.payload.issue.user.login && labelsContainsAny('status/need-feedback')",
48 | "then": "[labelIssue('for/team-attention'), removeLabel('status/need-feedback')]"
49 | },
50 | {
51 | "name": "Switch to user if team comments",
52 | "type": "ifThen",
53 | "if": "isEvent('issue_comment') && isAction('created') && dataInArray('team', actor) && labelsContainsAny('for/team-attention') ",
54 | "then": "[labelIssue('status/need-feedback', removeLabel('for/team-attention'))]"
55 | },
56 | {
57 | "name": "Manage backport issues",
58 | "type": "manageBackportIssues",
59 | "whenLabeled": "labeledStartsWith(['branch/'])",
60 | "whenUnlabeled": "labeledStartsWith(['branch/'])",
61 | "whenLabels": "labelsContainsAny(['for/backport'])",
62 | "fromLabels": "labeledStartsWith(['branch/'])",
63 | "additionalLabels": "'type/backport'",
64 | "body": "'Backport #' + number"
65 | }
66 | ]
67 | }
68 |
--------------------------------------------------------------------------------
/.github/workflows/label-manage.yml:
--------------------------------------------------------------------------------
1 | name: Labels Manage
2 |
3 | on:
4 | push:
5 | branches:
6 | - 'main'
7 | paths:
8 | - '.github/labels-manage.yml'
9 | - '.github/workflows/label-manage.yml'
10 | workflow_dispatch:
11 |
12 | jobs:
13 | labeler:
14 | runs-on: ubuntu-latest
15 | steps:
16 | - uses: actions/checkout@v2
17 | - name: Mangle Labels
18 | uses: crazy-max/ghaction-github-labeler@v3
19 | with:
20 | github-token: ${{ secrets.GITHUB_TOKEN }}
21 | yaml-file: .github/labels-manage.yml
22 | dry-run: false
23 | skip-delete: true
24 |
--------------------------------------------------------------------------------
/.github/workflows/milestone-worker.yml:
--------------------------------------------------------------------------------
1 | name: Milestone Worker
2 |
3 | on:
4 | workflow_dispatch:
5 | inputs:
6 | build-zoo-handler:
7 | description: 'Build Zoo Handler Payload'
8 | required: true
9 |
10 | jobs:
11 | build:
12 | runs-on: ubuntu-latest
13 | steps:
14 |
15 | - uses: actions/checkout@v2
16 | - uses: actions/setup-java@v1
17 | with:
18 | java-version: 1.8
19 | - uses: jvalkeal/setup-maven@v1
20 | with:
21 | maven-version: 3.6.3
22 | - uses: jfrog/setup-jfrog-cli@v1
23 | with:
24 | version: 1.46.4
25 | env:
26 | JF_ARTIFACTORY_SPRING: ${{ secrets.JF_ARTIFACTORY_SPRING }}
27 | - uses: actions/cache@v2
28 | with:
29 | path: ~/.m2/repository
30 | key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
31 | restore-keys: |
32 | ${{ runner.os }}-m2-
33 |
34 | # target deploy repos
35 | - name: Configure JFrog Cli
36 | run: |
37 | jfrog rt mvnc \
38 | --server-id-resolve=repo.spring.io \
39 | --server-id-deploy=repo.spring.io \
40 | --repo-resolve-releases=libs-milestone \
41 | --repo-resolve-snapshots=libs-snapshot \
42 | --repo-deploy-releases=libs-release-local \
43 | --repo-deploy-snapshots=libs-snapshot-local
44 | echo JFROG_CLI_BUILD_NAME=spring-cloud-deployer-cloudfoundry-main-milestone >> $GITHUB_ENV
45 | echo JFROG_CLI_BUILD_NUMBER=$GITHUB_RUN_NUMBER >> $GITHUB_ENV
46 |
47 | # zoo extract and ensure
48 | - name: Extract Zoo Context Properties
49 | uses: jvalkeal/build-zoo-handler@v0.0.4
50 | with:
51 | dispatch-handler-extract-context-properties: true
52 | ensure-env: |
53 | BUILD_ZOO_HANDLER_milestone_version
54 | BUILD_ZOO_HANDLER_spring_cloud_dataflow_build_version
55 | BUILD_ZOO_HANDLER_spring_cloud_deployer_version
56 |
57 | # build and publish to configured target
58 | - name: Build and Publish
59 | run: |
60 | jfrog rt mvn build-helper:parse-version versions:set \
61 | -gs .github/settings.xml \
62 | -Pstagingmilestone \
63 | -DprocessAllModules=true \
64 | -DgenerateBackupPoms=false \
65 | -Dartifactory.publish.artifacts=false \
66 | -DnewVersion='${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}-'${BUILD_ZOO_HANDLER_milestone_version} \
67 | -B
68 | echo BUILD_ZOO_HANDLER_spring_cloud_deployer_cloudfoundry_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) >> $GITHUB_ENV
69 | jfrog rt mvn versions:update-parent \
70 | -gs .github/settings.xml \
71 | -Pstagingmilestone \
72 | -DgenerateBackupPoms=false \
73 | -DparentVersion='['${BUILD_ZOO_HANDLER_spring_cloud_deployer_version}']' \
74 | -B
75 | jfrog rt mvn versions:set-property \
76 | -gs .github/settings.xml \
77 | -Pstagingmilestone \
78 | -DgenerateBackupPoms=false \
79 | -Dproperty=spring-cloud-deployer.version \
80 | -DnewVersion=${BUILD_ZOO_HANDLER_spring_cloud_deployer_version} \
81 | -B
82 | jfrog rt build-clean
83 | jfrog rt mvn clean install \
84 | -gs .github/settings.xml \
85 | -P-spring,stagingmilestone \
86 | -DskipTests -U -B
87 | jfrog rt build-publish
88 | echo BUILD_ZOO_HANDLER_spring_cloud_deployer_cloudfoundry_buildname=spring-cloud-deployer-cloudfoundry-main-milestone >> $GITHUB_ENV
89 | echo BUILD_ZOO_HANDLER_spring_cloud_deployer_cloudfoundry_buildnumber=$GITHUB_RUN_NUMBER >> $GITHUB_ENV
90 |
91 | # zoo tag
92 | - name: Tag Release
93 | uses: jvalkeal/build-zoo-handler@v0.0.4
94 | with:
95 | tag-release-branch: ${{ env.BUILD_ZOO_HANDLER_spring_cloud_deployer_cloudfoundry_version }}
96 | tag-release-tag: ${{ env.BUILD_ZOO_HANDLER_spring_cloud_deployer_cloudfoundry_version }}
97 | tag-release-tag-prefix: v
98 |
99 | # zoo success
100 | - name: Notify Build Success Zoo Handler Controller
101 | uses: jvalkeal/build-zoo-handler@v0.0.4
102 | with:
103 | dispatch-handler-token: ${{ secrets.SCDF_ACCESS_TOKEN }}
104 | dispatch-handler-client-payload-data: >
105 | {
106 | "event": "build-succeed"
107 | }
108 |
109 | # zoo failure
110 | - name: Notify Build Failure Zoo Handler Controller
111 | if: ${{ failure() }}
112 | uses: jvalkeal/build-zoo-handler@v0.0.4
113 | with:
114 | dispatch-handler-token: ${{ secrets.SCDF_ACCESS_TOKEN }}
115 | dispatch-handler-client-payload-data: >
116 | {
117 | "event": "build-failed",
118 | "message": "spring-cloud-deployer-cloudfoundry failed"
119 | }
120 | # clean m2 cache
121 | - name: Clean cache
122 | run: |
123 | find ~/.m2/repository -type d -name '*SNAPSHOT' | xargs rm -fr
124 |
--------------------------------------------------------------------------------
/.github/workflows/next-dev-version-worker.yml:
--------------------------------------------------------------------------------
1 | name: Next Dev Version Worker
2 |
3 | on:
4 | workflow_dispatch:
5 | inputs:
6 | build-zoo-handler:
7 | description: 'Build Zoo Handler Payload'
8 | required: true
9 |
10 | jobs:
11 | build:
12 | runs-on: ubuntu-latest
13 | steps:
14 |
15 | - uses: actions/checkout@v2
16 | - uses: actions/setup-java@v1
17 | with:
18 | java-version: 1.8
19 | - uses: jvalkeal/setup-maven@v1
20 | with:
21 | maven-version: 3.6.3
22 | - uses: jfrog/setup-jfrog-cli@v1
23 | with:
24 | version: 1.46.4
25 | env:
26 | JF_ARTIFACTORY_SPRING: ${{ secrets.JF_ARTIFACTORY_SPRING }}
27 |
28 | # cache maven .m2
29 | - uses: actions/cache@v2
30 | with:
31 | path: ~/.m2/repository
32 | key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
33 | restore-keys: |
34 | ${{ runner.os }}-m2-
35 |
36 | # target deploy repos
37 | - name: Configure JFrog Cli
38 | run: |
39 | jfrog rt mvnc \
40 | --server-id-resolve=repo.spring.io \
41 | --server-id-deploy=repo.spring.io \
42 | --repo-resolve-releases=libs-milestone \
43 | --repo-resolve-snapshots=libs-snapshot \
44 | --repo-deploy-releases=libs-release-local \
45 | --repo-deploy-snapshots=libs-snapshot-local
46 | echo JFROG_CLI_BUILD_NAME=spring-cloud-deployer-cloudfoundry-main-ndv >> $GITHUB_ENV
47 | echo JFROG_CLI_BUILD_NUMBER=$GITHUB_RUN_NUMBER >> $GITHUB_ENV
48 |
49 | # zoo extract and ensure
50 | - name: Extract Zoo Context Properties
51 | uses: jvalkeal/build-zoo-handler@v0.0.4
52 | with:
53 | dispatch-handler-extract-context-properties: true
54 |
55 | # build and publish to configured target
56 | - name: Build and Publish
57 | run: |
58 | jfrog rt mvn build-helper:parse-version versions:set \
59 | -DprocessAllModules=true \
60 | -DgenerateBackupPoms=false \
61 | -Dartifactory.publish.artifacts=false \
62 | -DnewVersion='${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.nextIncrementalVersion}-SNAPSHOT' \
63 | -B
64 | echo BUILD_ZOO_HANDLER_spring_cloud_deployer_cloudfoundry_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) >> $GITHUB_ENV
65 | jfrog rt mvn versions:update-parent \
66 | -DallowSnapshots=true \
67 | -DgenerateBackupPoms=false \
68 | -DparentVersion='['${BUILD_ZOO_HANDLER_spring_cloud_deployer_version}']' \
69 | -B
70 | jfrog rt mvn versions:set-property \
71 | -DgenerateBackupPoms=false \
72 | -Dproperty=spring-cloud-deployer.version \
73 | -DnewVersion=${BUILD_ZOO_HANDLER_spring_cloud_deployer_version} \
74 | -B
75 | jfrog rt build-clean
76 | jfrog rt mvn clean install -DskipTests -B
77 | jfrog rt build-publish
78 | echo BUILD_ZOO_HANDLER_spring_cloud_deployer_cloudfoundry_buildname=spring-cloud-deployer-cloudfoundry-main-ndv >> $GITHUB_ENV
79 | echo BUILD_ZOO_HANDLER_spring_cloud_deployer_cloudfoundry_buildnumber=$GITHUB_RUN_NUMBER >> $GITHUB_ENV
80 |
81 | # zoo commit
82 | - name: Commit Next Dev Changes
83 | uses: jvalkeal/build-zoo-handler@v0.0.4
84 | with:
85 | commit-changes-branch: main
86 | commit-changes-message: Next development version
87 |
88 | # zoo success
89 | - name: Notify Build Success Zoo Handler Controller
90 | uses: jvalkeal/build-zoo-handler@v0.0.4
91 | with:
92 | dispatch-handler-token: ${{ secrets.SCDF_ACCESS_TOKEN }}
93 | dispatch-handler-client-payload-data: >
94 | {
95 | "event": "next-dev-version-succeed"
96 | }
97 |
98 | # zoo failure
99 | - name: Notify Build Failure Zoo Handler Controller
100 | if: ${{ failure() }}
101 | uses: jvalkeal/build-zoo-handler@v0.0.4
102 | with:
103 | dispatch-handler-token: ${{ secrets.SCDF_ACCESS_TOKEN }}
104 | dispatch-handler-client-payload-data: >
105 | {
106 | "event": "next-dev-version-failed",
107 | "message": "spring-cloud-dataflow-build next version failed"
108 | }
109 |
110 | # clean m2 cache
111 | - name: Clean cache
112 | run: |
113 | find ~/.m2/repository -type d -name '*SNAPSHOT' | xargs rm -fr
114 |
--------------------------------------------------------------------------------
/.github/workflows/release-worker.yml:
--------------------------------------------------------------------------------
1 | name: Release Worker
2 |
3 | on:
4 | workflow_dispatch:
5 | inputs:
6 | build-zoo-handler:
7 | description: 'Build Zoo Handler Payload'
8 | required: true
9 |
10 | jobs:
11 | build:
12 | runs-on: ubuntu-latest
13 | steps:
14 |
15 | - uses: actions/checkout@v2
16 | - uses: actions/setup-java@v1
17 | with:
18 | java-version: 1.8
19 | - uses: jvalkeal/setup-maven@v1
20 | with:
21 | maven-version: 3.6.3
22 | - uses: jfrog/setup-jfrog-cli@v1
23 | with:
24 | version: 1.46.4
25 | env:
26 | JF_ARTIFACTORY_SPRING: ${{ secrets.JF_ARTIFACTORY_SPRING }}
27 | - uses: actions/cache@v2
28 | with:
29 | path: ~/.m2/repository
30 | key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
31 | restore-keys: |
32 | ${{ runner.os }}-m2-
33 |
34 | # target deploy repos
35 | - name: Configure JFrog Cli
36 | run: |
37 | jfrog rt mvnc \
38 | --server-id-resolve=repo.spring.io \
39 | --server-id-deploy=repo.spring.io \
40 | --repo-resolve-releases=libs-spring-dataflow-private-staging-release \
41 | --repo-resolve-snapshots=libs-snapshot \
42 | --repo-deploy-releases=libs-staging-local \
43 | --repo-deploy-snapshots=libs-snapshot-local
44 | echo JFROG_CLI_BUILD_NAME=spring-cloud-deployer-cloudfoundry-main-release >> $GITHUB_ENV
45 | echo JFROG_CLI_BUILD_NUMBER=$GITHUB_RUN_NUMBER >> $GITHUB_ENV
46 |
47 | # zoo extract and ensure
48 | - name: Extract Zoo Context Properties
49 | uses: jvalkeal/build-zoo-handler@v0.0.4
50 | with:
51 | dispatch-handler-extract-context-properties: true
52 | ensure-env: |
53 | BUILD_ZOO_HANDLER_spring_cloud_dataflow_build_version
54 | BUILD_ZOO_HANDLER_spring_cloud_deployer_version
55 |
56 | # build and publish to configured target
57 | - name: Build and Publish
58 | run: |
59 | jfrog rt mvn build-helper:parse-version versions:set \
60 | -gs .github/settings.xml \
61 | -Pstagingrelease \
62 | -DprocessAllModules=true \
63 | -DgenerateBackupPoms=false \
64 | -Dartifactory.publish.artifacts=false \
65 | -DnewVersion='${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}' \
66 | -B
67 | echo BUILD_ZOO_HANDLER_spring_cloud_deployer_cloudfoundry_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) >> $GITHUB_ENV
68 | jfrog rt mvn versions:update-parent \
69 | -gs .github/settings.xml \
70 | -Pstagingrelease \
71 | -DgenerateBackupPoms=false \
72 | -DparentVersion='['${BUILD_ZOO_HANDLER_spring_cloud_deployer_version}']' \
73 | -B
74 | jfrog rt mvn versions:set-property \
75 | -gs .github/settings.xml \
76 | -Pstagingrelease \
77 | -DgenerateBackupPoms=false \
78 | -Dproperty=spring-cloud-deployer.version \
79 | -DnewVersion=${BUILD_ZOO_HANDLER_spring_cloud_deployer_version} \
80 | -B
81 | jfrog rt build-clean
82 | jfrog rt mvn clean install \
83 | -gs .github/settings.xml \
84 | -P-spring,stagingrelease \
85 | -DskipTests -U -B
86 | jfrog rt build-publish
87 | echo BUILD_ZOO_HANDLER_spring_cloud_deployer_cloudfoundry_buildname=spring-cloud-deployer-cloudfoundry-main-release >> $GITHUB_ENV
88 | echo BUILD_ZOO_HANDLER_spring_cloud_deployer_cloudfoundry_buildnumber=$GITHUB_RUN_NUMBER >> $GITHUB_ENV
89 |
90 | # zoo tag
91 | - name: Tag Release
92 | uses: jvalkeal/build-zoo-handler@v0.0.4
93 | with:
94 | tag-release-branch: ${{ env.BUILD_ZOO_HANDLER_spring_cloud_deployer_cloudfoundry_version }}
95 | tag-release-tag: ${{ env.BUILD_ZOO_HANDLER_spring_cloud_deployer_cloudfoundry_version }}
96 | tag-release-tag-prefix: v
97 |
98 | # zoo success
99 | - name: Notify Build Success Zoo Handler Controller
100 | uses: jvalkeal/build-zoo-handler@v0.0.4
101 | with:
102 | dispatch-handler-token: ${{ secrets.SCDF_ACCESS_TOKEN }}
103 | dispatch-handler-client-payload-data: >
104 | {
105 | "event": "build-succeed"
106 | }
107 |
108 | # zoo failure
109 | - name: Notify Build Failure Zoo Handler Controller
110 | if: ${{ failure() }}
111 | uses: jvalkeal/build-zoo-handler@v0.0.4
112 | with:
113 | dispatch-handler-token: ${{ secrets.SCDF_ACCESS_TOKEN }}
114 | dispatch-handler-client-payload-data: >
115 | {
116 | "event": "build-failed",
117 | "message": "spring-cloud-deployer-cloudfoundry failed"
118 | }
119 | # clean m2 cache
120 | - name: Clean cache
121 | run: |
122 | find ~/.m2/repository -type d -name '*SNAPSHOT' | xargs rm -fr
123 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | # Created by https://www.gitignore.io/api/java,maven,intellij,eclipse
3 |
4 | ### Java ###
5 | *.class
6 |
7 | # Mobile Tools for Java (J2ME)
8 | .mtj.tmp/
9 |
10 | # Package Files #
11 |
12 | # virtual machine crash logs, see https://www.java.com/en/download/help/error_hotspot.xml
13 | hs_err_pid*
14 |
15 |
16 | ### Maven ###
17 | target/
18 | pom.xml.tag
19 | pom.xml.releaseBackup
20 | pom.xml.versionsBackup
21 | pom.xml.next
22 | release.properties
23 | dependency-reduced-pom.xml
24 | buildNumber.properties
25 |
26 |
27 | ### Intellij ###
28 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
29 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
30 |
31 | # User-specific stuff:
32 | .idea/*
33 | !.idea/codeStyleSettings.xml
34 |
35 | ## File-based project format:
36 | *.iws
37 | *.iml
38 | *.ipr
39 |
40 | ## Plugin-specific files:
41 |
42 | # IntelliJ
43 | /out/
44 | .idea
45 |
46 | # mpeltonen/sbt-idea plugin
47 | .idea_modules/
48 |
49 | # JIRA plugin
50 | atlassian-ide-plugin.xml
51 |
52 | # Crashlytics plugin (for Android Studio and IntelliJ)
53 | com_crashlytics_export_strings.xml
54 | crashlytics.properties
55 | crashlytics-build.properties
56 | fabric.properties
57 |
58 |
59 | ### Eclipse ###
60 |
61 | .metadata
62 | bin/
63 | tmp/
64 | *.tmp
65 | *.bak
66 | *.swp
67 | *~.nib
68 | local.properties
69 | .settings/
70 | .loadpath
71 |
72 | # Eclipse Core
73 | .project
74 |
75 | # External tool builders
76 | .externalToolBuilders/
77 |
78 | # Locally stored "Eclipse launch configurations"
79 | *.launch
80 |
81 | # PyDev specific (Python IDE for Eclipse)
82 | *.pydevproject
83 |
84 | # CDT-specific (C/C++ Development Tooling)
85 | .cproject
86 |
87 | # JDT-specific (Eclipse Java Development Tools)
88 | .classpath
89 |
90 | # Java annotation processor (APT)
91 | .factorypath
92 |
93 | # PDT-specific (PHP Development Tools)
94 | .buildpath
95 |
96 | # sbteclipse plugin
97 | .target
98 |
99 | # Tern plugin
100 | .tern-project
101 |
102 | # TeXlipse plugin
103 | .texlipse
104 |
105 | # STS (Spring Tool Suite)
106 | .springBeans
107 |
108 | # Code Recommenders
109 | .recommenders/
110 |
111 | .DS_Store
112 | .jfrog/
113 |
114 | # Visual Studio Code
115 | .vscode/*
116 | !.vscode/settings.json
117 | !.vscode/tasks.json
118 | !.vscode/launch.json
119 | !.vscode/extensions.json
120 |
121 |
--------------------------------------------------------------------------------
/.jdk8:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spring-attic/spring-cloud-deployer-cloudfoundry/720b866b2783f2edfd1759761c48ae4eebe12929/.jdk8
--------------------------------------------------------------------------------
/.mvn/jvm.config:
--------------------------------------------------------------------------------
1 | -Xmx1024m -XX:CICompilerCount=1 -XX:TieredStopAtLevel=1 -Djava.security.egd=file:/dev/./urandom
--------------------------------------------------------------------------------
/.mvn/maven.config:
--------------------------------------------------------------------------------
1 | -DaltSnapshotDeploymentRepository=repo.spring.io::default::https://repo.spring.io/libs-snapshot-local -P spring
2 |
--------------------------------------------------------------------------------
/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spring-attic/spring-cloud-deployer-cloudfoundry/720b866b2783f2edfd1759761c48ae4eebe12929/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.2/apache-maven-3.6.2-bin.zip
2 |
3 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "java.completion.importOrder": [
3 | "java",
4 | "javax",
5 | "",
6 | "org.springframework",
7 | "#"
8 | ],
9 | "java.checkstyle.configuration": "https://raw.githubusercontent.com/spring-cloud/spring-cloud-dataflow-build/main/spring-cloud-dataflow-build-tools/src/main/resources/checkstyle.xml",
10 | "java.checkstyle.properties": {
11 | "checkstyle.suppressions.file": "https://raw.githubusercontent.com/spring-cloud/spring-cloud-dataflow-build/main/spring-cloud-dataflow-build-tools/src/checkstyle/checkstyle-suppressions.xml",
12 | "checkstyle.additional.suppressions.file": "https://raw.githubusercontent.com/spring-cloud/spring-cloud-dataflow-build/main/spring-cloud-dataflow-build-tools/src/checkstyle/checkstyle-suppressions-empty.xml",
13 | "checkstyle.header.file": "https://raw.githubusercontent.com/spring-cloud/spring-cloud-dataflow-build/main/spring-cloud-dataflow-build-tools/src/main/resources/checkstyle-header.txt"
14 | },
15 | "java.checkstyle.version": "8.29"
16 | }
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.adoc:
--------------------------------------------------------------------------------
1 | = Contributor Code of Conduct
2 |
3 | As contributors and maintainers of this project, and in the interest of fostering an open
4 | and welcoming community, we pledge to respect all people who contribute through reporting
5 | issues, posting feature requests, updating documentation, submitting pull requests or
6 | patches, and other activities.
7 |
8 | We are committed to making participation in this project a harassment-free experience for
9 | everyone, regardless of level of experience, gender, gender identity and expression,
10 | sexual orientation, disability, personal appearance, body size, race, ethnicity, age,
11 | religion, or nationality.
12 |
13 | Examples of unacceptable behavior by participants include:
14 |
15 | * The use of sexualized language or imagery
16 | * Personal attacks
17 | * Trolling or insulting/derogatory comments
18 | * Public or private harassment
19 | * Publishing other's private information, such as physical or electronic addresses,
20 | without explicit permission
21 | * Other unethical or unprofessional conduct
22 |
23 | Project maintainers have the right and responsibility to remove, edit, or reject comments,
24 | commits, code, wiki edits, issues, and other contributions that are not aligned to this
25 | Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors
26 | that they deem inappropriate, threatening, offensive, or harmful.
27 |
28 | By adopting this Code of Conduct, project maintainers commit themselves to fairly and
29 | consistently applying these principles to every aspect of managing this project. Project
30 | maintainers who do not follow or enforce the Code of Conduct may be permanently removed
31 | from the project team.
32 |
33 | This Code of Conduct applies both within project spaces and in public spaces when an
34 | individual is representing the project or its community.
35 |
36 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by
37 | contacting a project maintainer at spring-code-of-conduct@pivotal.io . All complaints will
38 | be reviewed and investigated and will result in a response that is deemed necessary and
39 | appropriate to the circumstances. Maintainers are obligated to maintain confidentiality
40 | with regard to the reporter of an incident.
41 |
42 | This Code of Conduct is adapted from the
43 | https://contributor-covenant.org[Contributor Covenant], version 1.3.0, available at
44 | https://contributor-covenant.org/version/1/3/0/[contributor-covenant.org/version/1/3/0/]
--------------------------------------------------------------------------------
/CONTRIBUTING.adoc:
--------------------------------------------------------------------------------
1 | = Contributing to Spring Cloud - Cloud Foundry Deployer
2 |
3 | Spring Cloud - Cloud Foundry Deployer is released under the Apache 2.0 license. If you would like to contribute
4 | something, or simply want to hack on the code this document should help you get started.
5 |
6 | == Code of Conduct
7 | This project adheres to the Contributor Covenant link:CODE_OF_CONDUCT.adoc[code of
8 | conduct]. By participating, you are expected to uphold this code. Please report
9 | unacceptable behavior to spring-code-of-conduct@pivotal.io.
10 |
11 | == Using github issues
12 | We use github issues to track bugs and enhancements. If you have a general usage question
13 | please ask on https://stackoverflow.com[Stack Overflow]. The Sprig Cloud team and the
14 | broader community monitor the https://stackoverflow.com/tags/spring-cloud[`spring-cloud`]
15 | tag.
16 |
17 | If you are reporting a bug, please help to speed up problem diagnosis by providing as much
18 | information as possible. Submitting a github-hosted sample project replicating the problem helps.
19 |
20 | == Sign the Contributor License Agreement
21 | Before we accept a non-trivial patch or pull request we will need you to sign the
22 | https://support.springsource.com/spring_committer_signup[contributor's agreement].
23 | Signing the contributor's agreement does not grant anyone commit rights to the main
24 | repository, but it does mean that we can accept your contributions, and you will get an
25 | author credit if we do. Active contributors might be asked to join the core team, and
26 | given the ability to merge pull requests. Use '`Phillip Webb`' or '`Dave Syer`' in the
27 | project lead field when you complete the form.
28 |
29 | == Code Conventions and Housekeeping
30 | None of these are essential for a pull request, but they help. They can also be
31 | added after the original pull request but before a merge.
32 |
33 | * Use the Spring Framework code format conventions.
34 | * Make sure all new `.java` files to have a simple Javadoc class comment with at least an
35 | `@author` tag identifying you, and preferably at least a paragraph on what the class is
36 | for.
37 | * Add the ASF license header comment to all new `.java` files (copy from existing files
38 | in the project)
39 | * Add yourself as an `@author` to the `.java` files that you modify substantially (more
40 | than cosmetic changes).
41 | * Add some Javadocs.
42 | * A few unit tests would help a lot as well -- someone has to do it.
43 | * If no-one else is using your branch, please rebase it against the current master (or
44 | other target branch in the main project).
45 | * When writing a commit message please follow https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html[these conventions].
46 |
47 | === Building from source
48 | This project includes the maven wrapper, meaning you don't have to install any CLI tools to compile. Simply clone it and do this:
49 |
50 | ==== Default build
51 | The project can be built from the root directory using the standard maven wrapper command:
52 |
53 | ----
54 | $ ./mvnw clean package
55 | ----
56 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | https://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | https://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
203 |
--------------------------------------------------------------------------------
/NOTICE:
--------------------------------------------------------------------------------
1 | spring-cloud-deployer-cloudfoundry
2 |
3 | Copyright (c) 2016-Present Pivotal Software, Inc. All Rights Reserved.
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | https://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # :no_entry: Spring Cloud Deployer has moved to a monorepo.
2 | ## This repo is archived and now exists as the [spring-cloud-deployer-cloudfoundry](https://github.com/spring-cloud/spring-cloud-deployer/tree/main/spring-cloud-deployer-cloudfoundry) module in the Deployer monorepo.
3 | ### Please file any issues/PRs in the [Deployer](https://github.com/spring-cloud/spring-cloud-deployer) repo.
4 |
--------------------------------------------------------------------------------
/mvnw:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # ----------------------------------------------------------------------------
3 | # Licensed to the Apache Software Foundation (ASF) under one
4 | # or more contributor license agreements. See the NOTICE file
5 | # distributed with this work for additional information
6 | # regarding copyright ownership. The ASF licenses this file
7 | # to you under the Apache License, Version 2.0 (the
8 | # "License"); you may not use this file except in compliance
9 | # with the License. You may obtain a copy of the License at
10 | #
11 | # https://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing,
14 | # software distributed under the License is distributed on an
15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | # KIND, either express or implied. See the License for the
17 | # specific language governing permissions and limitations
18 | # under the License.
19 | # ----------------------------------------------------------------------------
20 |
21 | # ----------------------------------------------------------------------------
22 | # Maven2 Start Up Batch script
23 | #
24 | # Required ENV vars:
25 | # ------------------
26 | # JAVA_HOME - location of a JDK home dir
27 | #
28 | # Optional ENV vars
29 | # -----------------
30 | # M2_HOME - location of maven2's installed home dir
31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven
32 | # e.g. to debug Maven itself, use
33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files
35 | # ----------------------------------------------------------------------------
36 |
37 | if [ -z "$MAVEN_SKIP_RC" ] ; then
38 |
39 | if [ -f /etc/mavenrc ] ; then
40 | . /etc/mavenrc
41 | fi
42 |
43 | if [ -f "$HOME/.mavenrc" ] ; then
44 | . "$HOME/.mavenrc"
45 | fi
46 |
47 | fi
48 |
49 | # OS specific support. $var _must_ be set to either true or false.
50 | cygwin=false;
51 | darwin=false;
52 | mingw=false
53 | case "`uname`" in
54 | CYGWIN*) cygwin=true ;;
55 | MINGW*) mingw=true;;
56 | Darwin*) darwin=true
57 | #
58 | # Look for the Apple JDKs first to preserve the existing behaviour, and then look
59 | # for the new JDKs provided by Oracle.
60 | #
61 | if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then
62 | #
63 | # Apple JDKs
64 | #
65 | export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
66 | fi
67 |
68 | if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then
69 | #
70 | # Apple JDKs
71 | #
72 | export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
73 | fi
74 |
75 | if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then
76 | #
77 | # Oracle JDKs
78 | #
79 | export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
80 | fi
81 |
82 | if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then
83 | #
84 | # Apple JDKs
85 | #
86 | export JAVA_HOME=`/usr/libexec/java_home`
87 | fi
88 | ;;
89 | esac
90 |
91 | if [ -z "$JAVA_HOME" ] ; then
92 | if [ -r /etc/gentoo-release ] ; then
93 | JAVA_HOME=`java-config --jre-home`
94 | fi
95 | fi
96 |
97 | if [ -z "$M2_HOME" ] ; then
98 | ## resolve links - $0 may be a link to maven's home
99 | PRG="$0"
100 |
101 | # need this for relative symlinks
102 | while [ -h "$PRG" ] ; do
103 | ls=`ls -ld "$PRG"`
104 | link=`expr "$ls" : '.*-> \(.*\)$'`
105 | if expr "$link" : '/.*' > /dev/null; then
106 | PRG="$link"
107 | else
108 | PRG="`dirname "$PRG"`/$link"
109 | fi
110 | done
111 |
112 | saveddir=`pwd`
113 |
114 | M2_HOME=`dirname "$PRG"`/..
115 |
116 | # make it fully qualified
117 | M2_HOME=`cd "$M2_HOME" && pwd`
118 |
119 | cd "$saveddir"
120 | # echo Using m2 at $M2_HOME
121 | fi
122 |
123 | # For Cygwin, ensure paths are in UNIX format before anything is touched
124 | if $cygwin ; then
125 | [ -n "$M2_HOME" ] &&
126 | M2_HOME=`cygpath --unix "$M2_HOME"`
127 | [ -n "$JAVA_HOME" ] &&
128 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
129 | [ -n "$CLASSPATH" ] &&
130 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
131 | fi
132 |
133 | # For Migwn, ensure paths are in UNIX format before anything is touched
134 | if $mingw ; then
135 | [ -n "$M2_HOME" ] &&
136 | M2_HOME="`(cd "$M2_HOME"; pwd)`"
137 | [ -n "$JAVA_HOME" ] &&
138 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
139 | # TODO classpath?
140 | fi
141 |
142 | if [ -z "$JAVA_HOME" ]; then
143 | javaExecutable="`which javac`"
144 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
145 | # readlink(1) is not available as standard on Solaris 10.
146 | readLink=`which readlink`
147 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
148 | if $darwin ; then
149 | javaHome="`dirname \"$javaExecutable\"`"
150 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
151 | else
152 | javaExecutable="`readlink -f \"$javaExecutable\"`"
153 | fi
154 | javaHome="`dirname \"$javaExecutable\"`"
155 | javaHome=`expr "$javaHome" : '\(.*\)/bin'`
156 | JAVA_HOME="$javaHome"
157 | export JAVA_HOME
158 | fi
159 | fi
160 | fi
161 |
162 | if [ -z "$JAVACMD" ] ; then
163 | if [ -n "$JAVA_HOME" ] ; then
164 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
165 | # IBM's JDK on AIX uses strange locations for the executables
166 | JAVACMD="$JAVA_HOME/jre/sh/java"
167 | else
168 | JAVACMD="$JAVA_HOME/bin/java"
169 | fi
170 | else
171 | JAVACMD="`which java`"
172 | fi
173 | fi
174 |
175 | if [ ! -x "$JAVACMD" ] ; then
176 | echo "Error: JAVA_HOME is not defined correctly." >&2
177 | echo " We cannot execute $JAVACMD" >&2
178 | exit 1
179 | fi
180 |
181 | if [ -z "$JAVA_HOME" ] ; then
182 | echo "Warning: JAVA_HOME environment variable is not set."
183 | fi
184 |
185 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
186 |
187 | # For Cygwin, switch paths to Windows format before running java
188 | if $cygwin; then
189 | [ -n "$M2_HOME" ] &&
190 | M2_HOME=`cygpath --path --windows "$M2_HOME"`
191 | [ -n "$JAVA_HOME" ] &&
192 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
193 | [ -n "$CLASSPATH" ] &&
194 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
195 | fi
196 |
197 | # traverses directory structure from process work directory to filesystem root
198 | # first directory with .mvn subdirectory is considered project base directory
199 | find_maven_basedir() {
200 | local basedir=$(pwd)
201 | local wdir=$(pwd)
202 | while [ "$wdir" != '/' ] ; do
203 | if [ -d "$wdir"/.mvn ] ; then
204 | basedir=$wdir
205 | break
206 | fi
207 | wdir=$(cd "$wdir/.."; pwd)
208 | done
209 | echo "${basedir}"
210 | }
211 |
212 | # concatenates all lines of a file
213 | concat_lines() {
214 | if [ -f "$1" ]; then
215 | echo "$(tr -s '\n' ' ' < "$1")"
216 | fi
217 | }
218 |
219 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)}
220 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
221 |
222 | # Provide a "standardized" way to retrieve the CLI args that will
223 | # work with both Windows and non-Windows executions.
224 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
225 | export MAVEN_CMD_LINE_ARGS
226 |
227 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
228 |
229 | exec "$JAVACMD" \
230 | $MAVEN_OPTS \
231 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
232 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
233 | ${WRAPPER_LAUNCHER} "$@"
234 |
--------------------------------------------------------------------------------
/mvnw.cmd:
--------------------------------------------------------------------------------
1 | @REM ----------------------------------------------------------------------------
2 | @REM Licensed to the Apache Software Foundation (ASF) under one
3 | @REM or more contributor license agreements. See the NOTICE file
4 | @REM distributed with this work for additional information
5 | @REM regarding copyright ownership. The ASF licenses this file
6 | @REM to you under the Apache License, Version 2.0 (the
7 | @REM "License"); you may not use this file except in compliance
8 | @REM with the License. You may obtain a copy of the License at
9 | @REM
10 | @REM https://www.apache.org/licenses/LICENSE-2.0
11 | @REM
12 | @REM Unless required by applicable law or agreed to in writing,
13 | @REM software distributed under the License is distributed on an
14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | @REM KIND, either express or implied. See the License for the
16 | @REM specific language governing permissions and limitations
17 | @REM under the License.
18 | @REM ----------------------------------------------------------------------------
19 |
20 | @REM ----------------------------------------------------------------------------
21 | @REM Maven2 Start Up Batch script
22 | @REM
23 | @REM Required ENV vars:
24 | @REM JAVA_HOME - location of a JDK home dir
25 | @REM
26 | @REM Optional ENV vars
27 | @REM M2_HOME - location of maven2's installed home dir
28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
31 | @REM e.g. to debug Maven itself, use
32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
34 | @REM ----------------------------------------------------------------------------
35 |
36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
37 | @echo off
38 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
40 |
41 | @REM set %HOME% to equivalent of $HOME
42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
43 |
44 | @REM Execute a user defined script before this one
45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending
47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
49 | :skipRcPre
50 |
51 | @setlocal
52 |
53 | set ERROR_CODE=0
54 |
55 | @REM To isolate internal variables from possible post scripts, we use another setlocal
56 | @setlocal
57 |
58 | @REM ==== START VALIDATION ====
59 | if not "%JAVA_HOME%" == "" goto OkJHome
60 |
61 | echo.
62 | echo Error: JAVA_HOME not found in your environment. >&2
63 | echo Please set the JAVA_HOME variable in your environment to match the >&2
64 | echo location of your Java installation. >&2
65 | echo.
66 | goto error
67 |
68 | :OkJHome
69 | if exist "%JAVA_HOME%\bin\java.exe" goto init
70 |
71 | echo.
72 | echo Error: JAVA_HOME is set to an invalid directory. >&2
73 | echo JAVA_HOME = "%JAVA_HOME%" >&2
74 | echo Please set the JAVA_HOME variable in your environment to match the >&2
75 | echo location of your Java installation. >&2
76 | echo.
77 | goto error
78 |
79 | @REM ==== END VALIDATION ====
80 |
81 | :init
82 |
83 | set MAVEN_CMD_LINE_ARGS=%*
84 |
85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
86 | @REM Fallback to current working directory if not found.
87 |
88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
90 |
91 | set EXEC_DIR=%CD%
92 | set WDIR=%EXEC_DIR%
93 | :findBaseDir
94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound
95 | cd ..
96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound
97 | set WDIR=%CD%
98 | goto findBaseDir
99 |
100 | :baseDirFound
101 | set MAVEN_PROJECTBASEDIR=%WDIR%
102 | cd "%EXEC_DIR%"
103 | goto endDetectBaseDir
104 |
105 | :baseDirNotFound
106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
107 | cd "%EXEC_DIR%"
108 |
109 | :endDetectBaseDir
110 |
111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
112 |
113 | @setlocal EnableExtensions EnableDelayedExpansion
114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
116 |
117 | :endReadAdditionalConfig
118 |
119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
120 |
121 | set WRAPPER_JAR="".\.mvn\wrapper\maven-wrapper.jar""
122 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
123 |
124 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS%
125 | if ERRORLEVEL 1 goto error
126 | goto end
127 |
128 | :error
129 | set ERROR_CODE=1
130 |
131 | :end
132 | @endlocal & set ERROR_CODE=%ERROR_CODE%
133 |
134 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
135 | @REM check for post script, once with legacy .bat ending and once with .cmd ending
136 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
137 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
138 | :skipRcPost
139 |
140 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
141 | if "%MAVEN_BATCH_PAUSE%" == "on" pause
142 |
143 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
144 |
145 | exit /B %ERROR_CODE%
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 | spring-cloud-deployer-cloudfoundry
6 | 2.8.4-SNAPSHOT
7 | org.springframework.cloud
8 | jar
9 |
10 | Spring Cloud - Cloud Foundry Deployer
11 |
12 |
13 | org.springframework.cloud
14 | spring-cloud-deployer-parent
15 | 2.8.2-SNAPSHOT
16 |
17 |
18 |
19 |
20 | 1.8
21 | 2.8.4-SNAPSHOT
22 | 4.16.0.RELEASE
23 | 2.2.0.RELEASE
24 | 3.14.9
25 |
26 |
27 |
28 |
29 | org.springframework.cloud
30 | spring-cloud-deployer-spi
31 | ${spring-cloud-deployer.version}
32 |
33 |
34 | org.springframework.boot
35 | spring-boot-loader
36 |
37 |
38 | org.springframework.boot
39 | spring-boot-starter-validation
40 |
41 |
42 | org.springframework.boot
43 | spring-boot-configuration-processor
44 | true
45 |
46 |
47 | org.cloudfoundry
48 | cloudfoundry-client-reactor
49 | ${cloudfoundry-java-lib.version}
50 |
51 |
52 | org.cloudfoundry
53 | cloudfoundry-operations
54 | ${cloudfoundry-java-lib.version}
55 |
56 |
57 | com.github.ben-manes.caffeine
58 | caffeine
59 |
60 |
61 | io.projectreactor.addons
62 | reactor-extra
63 |
64 |
65 | org.yaml
66 | snakeyaml
67 |
68 |
69 | io.pivotal
70 | pivotal-cloudfoundry-client-reactor
71 | ${pivotal-cf-client-reactor.version}
72 |
73 |
74 | org.springframework.retry
75 | spring-retry
76 |
77 |
78 | org.springframework.boot
79 | spring-boot-starter-test
80 | test
81 |
82 |
83 | org.springframework.cloud
84 | spring-cloud-deployer-spi-test
85 | ${spring-cloud-deployer.version}
86 | test
87 |
88 |
89 | org.springframework.cloud
90 | spring-cloud-deployer-resource-docker
91 | ${spring-cloud-deployer.version}
92 | test
93 |
94 |
95 | org.springframework.cloud
96 | spring-cloud-deployer-resource-support
97 | ${spring-cloud-deployer.version}
98 | test
99 |
100 |
101 | org.springframework.cloud
102 | spring-cloud-deployer-autoconfigure
103 | ${spring-cloud-deployer.version}
104 | test
105 |
106 |
107 | com.squareup.okhttp3
108 | okhttp
109 | ${okhttp.version}
110 | test
111 |
112 |
113 | com.squareup.okhttp3
114 | mockwebserver
115 | ${okhttp.version}
116 | test
117 |
118 |
119 |
120 |
121 |
122 | spring
123 | true
124 |
125 |
126 | spring-snapshots
127 | Spring Snapshots
128 | https://repo.spring.io/snapshot
129 |
130 | true
131 |
132 |
133 |
134 | spring-milestones
135 | Spring Milestones
136 | https://repo.spring.io/milestone
137 |
138 | false
139 |
140 |
141 |
142 | maven-central
143 | Maven Central
144 | https://repo.maven.apache.org/maven2
145 |
146 | false
147 |
148 |
149 |
150 |
151 |
152 | spring-snapshots
153 | Spring Snapshots
154 | https://repo.spring.io/snapshot
155 |
156 | true
157 |
158 |
159 |
160 | spring-milestones
161 | Spring Milestones
162 | https://repo.spring.io/milestone
163 |
164 | false
165 |
166 |
167 |
168 | maven-central
169 | Maven Central
170 | https://repo.maven.apache.org/maven2
171 |
172 | false
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/cloud/deployer/spi/cloudfoundry/AbstractCloudFoundryTaskLauncher.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.deployer.spi.cloudfoundry;
18 |
19 | import java.time.Duration;
20 |
21 | import io.jsonwebtoken.lang.Assert;
22 | import org.cloudfoundry.client.CloudFoundryClient;
23 | import org.cloudfoundry.client.v2.organizations.ListOrganizationsRequest;
24 | import org.cloudfoundry.client.v2.spaces.ListSpacesRequest;
25 | import org.cloudfoundry.client.v3.tasks.CancelTaskRequest;
26 | import org.cloudfoundry.client.v3.tasks.CancelTaskResponse;
27 | import org.cloudfoundry.client.v3.tasks.GetTaskRequest;
28 | import org.cloudfoundry.client.v3.tasks.GetTaskResponse;
29 | import org.cloudfoundry.client.v3.tasks.ListTasksRequest;
30 | import org.cloudfoundry.client.v3.tasks.TaskState;
31 | import org.slf4j.Logger;
32 | import org.slf4j.LoggerFactory;
33 | import reactor.core.publisher.Mono;
34 | import reactor.util.function.Tuple2;
35 |
36 | import org.springframework.cloud.deployer.spi.core.AppDeploymentRequest;
37 | import org.springframework.cloud.deployer.spi.core.RuntimeEnvironmentInfo;
38 | import org.springframework.cloud.deployer.spi.task.LaunchState;
39 | import org.springframework.cloud.deployer.spi.task.TaskLauncher;
40 | import org.springframework.cloud.deployer.spi.task.TaskStatus;
41 |
42 | /**
43 | * Abstract class to provide base functionality for launching Tasks on Cloud Foundry. This
44 | * class provides the base SPI for the {@link CloudFoundryTaskLauncher}.
45 | *
46 | * Does not override the default no-op implementation for
47 | * {@link TaskLauncher#cleanup(String)} and {@link TaskLauncher#destroy(String)}.
48 | */
49 | abstract class AbstractCloudFoundryTaskLauncher extends AbstractCloudFoundryDeployer implements TaskLauncher {
50 |
51 | private static final Logger logger = LoggerFactory.getLogger(AbstractCloudFoundryTaskLauncher.class);
52 |
53 | private final CloudFoundryClient client;
54 |
55 | private final Mono organizationId;
56 |
57 | private final Mono spaceId;
58 |
59 | AbstractCloudFoundryTaskLauncher(CloudFoundryClient client,
60 | CloudFoundryDeploymentProperties deploymentProperties,
61 | RuntimeEnvironmentInfo runtimeEnvironmentInfo) {
62 | super(deploymentProperties, runtimeEnvironmentInfo);
63 | this.client = client;
64 | organizationId = organizationId();
65 | spaceId = spaceId();
66 | }
67 |
68 | /**
69 | * Setup a reactor flow to cancel a running task. This implementation opts to be
70 | * asynchronous.
71 | *
72 | * @param id the task's id to be canceled as returned from the
73 | * {@link TaskLauncher#launch(AppDeploymentRequest)}
74 | */
75 | @Override
76 | public void cancel(String id) {
77 | requestCancelTask(id)
78 | .timeout(Duration.ofSeconds(this.deploymentProperties.getApiTimeout()))
79 | .doOnSuccess(r -> logger.info("Task {} cancellation successful", id))
80 | .doOnError(logError(String.format("Task %s cancellation failed", id)))
81 | .subscribe();
82 | }
83 |
84 | /**
85 | * Lookup the current status based on task id.
86 | *
87 | * @param id taskId as returned from the {@link TaskLauncher#launch(AppDeploymentRequest)}
88 | * @return the current task status
89 | */
90 | @Override
91 | public TaskStatus status(String id) {
92 | try {
93 | return getStatus(id)
94 | .doOnSuccess(v -> logger.info("Successfully computed status [{}] for id={}", v, id))
95 | .doOnError(logError(String.format("Failed to compute status for %s", id)))
96 | .block(Duration.ofMillis(this.deploymentProperties.getStatusTimeout()));
97 | }
98 | catch (Exception timeoutDueToBlock) {
99 | logger.error("Caught exception while querying for status of id={}", id, timeoutDueToBlock);
100 | return createErrorTaskStatus(id);
101 | }
102 | }
103 |
104 | @Override
105 | public int getRunningTaskExecutionCount() {
106 |
107 | Mono> orgAndSpace = Mono.zip(organizationId, spaceId);
108 |
109 | Mono listTasksRequest = orgAndSpace.map(tuple->
110 | ListTasksRequest.builder()
111 | .state(TaskState.RUNNING)
112 | .organizationId(tuple.getT1())
113 | .spaceId(tuple.getT2())
114 | .build());
115 |
116 | return listTasksRequest.flatMap(request-> this.client.tasks().list(request))
117 | .map(listTasksResponse -> listTasksResponse.getPagination().getTotalResults())
118 | .doOnError(logError("Failed to list running tasks"))
119 | .doOnSuccess(count -> logger.info(String.format("There are %d running tasks", count)))
120 | .block(Duration.ofMillis(this.deploymentProperties.getStatusTimeout()));
121 | }
122 |
123 | @Override
124 | public int getMaximumConcurrentTasks() {
125 | return this.deploymentProperties.getMaximumConcurrentTasks();
126 | }
127 |
128 | protected boolean maxConcurrentExecutionsReached() {
129 | return this.getRunningTaskExecutionCount() >= this.getMaximumConcurrentTasks();
130 | }
131 |
132 | private Mono getStatus(String id) {
133 | return requestGetTask(id)
134 | .map(this::toTaskStatus)
135 | .onErrorResume(isNotFoundError(), t -> {
136 | logger.debug("Task for id={} does not exist", id);
137 | return Mono.just(new TaskStatus(id, LaunchState.unknown, null));
138 | })
139 | .transform(statusRetry(id))
140 | .onErrorReturn(createErrorTaskStatus(id));
141 | }
142 |
143 | private TaskStatus createErrorTaskStatus(String id) {
144 | return new TaskStatus(id, LaunchState.error, null);
145 | }
146 |
147 | protected TaskStatus toTaskStatus(GetTaskResponse response) {
148 | switch (response.getState()) {
149 | case SUCCEEDED:
150 | return new TaskStatus(response.getId(), LaunchState.complete, null);
151 | case RUNNING:
152 | return new TaskStatus(response.getId(), LaunchState.running, null);
153 | case PENDING:
154 | return new TaskStatus(response.getId(), LaunchState.launching, null);
155 | case CANCELING:
156 | return new TaskStatus(response.getId(), LaunchState.cancelled, null);
157 | case FAILED:
158 | return new TaskStatus(response.getId(), LaunchState.failed, null);
159 | default:
160 | throw new IllegalStateException(String.format("Unsupported CF task state %s", response.getState()));
161 | }
162 | }
163 |
164 | private Mono requestCancelTask(String taskId) {
165 | return this.client.tasks()
166 | .cancel(CancelTaskRequest.builder()
167 | .taskId(taskId)
168 | .build());
169 | }
170 |
171 | private Mono requestGetTask(String taskId) {
172 | return this.client.tasks()
173 | .get(GetTaskRequest.builder()
174 | .taskId(taskId)
175 | .build());
176 | }
177 |
178 | private Mono organizationId() {
179 | String org = this.runtimeEnvironmentInfo.getPlatformSpecificInfo().get(CloudFoundryPlatformSpecificInfo.ORG);
180 | Assert.hasText(org,"Missing runtimeEnvironmentInfo : 'org' required.");
181 | ListOrganizationsRequest listOrganizationsRequest = ListOrganizationsRequest.builder()
182 | .name(org).build();
183 | return this.client.organizations().list(listOrganizationsRequest)
184 | .doOnError(logError("Failed to list organizations"))
185 | .map(listOrganizationsResponse -> listOrganizationsResponse.getResources().get(0).getMetadata().getId())
186 | .cache(aValue -> Duration.ofMillis(Long.MAX_VALUE), aValue -> Duration.ZERO, () -> Duration.ZERO);
187 | }
188 |
189 | private Mono spaceId() {
190 | String space = this.runtimeEnvironmentInfo.getPlatformSpecificInfo().get(CloudFoundryPlatformSpecificInfo.SPACE);
191 | Assert.hasText(space,"Missing runtimeEnvironmentInfo : 'space' required.");
192 | ListSpacesRequest listSpacesRequest = ListSpacesRequest.builder()
193 | .name(space).build();
194 | return this.client.spaces().list(listSpacesRequest)
195 | .doOnError(logError("Failed to list spaces"))
196 | .map(listSpacesResponse -> listSpacesResponse.getResources().get(0).getMetadata().getId())
197 | .cache(aValue -> Duration.ofMillis(Long.MAX_VALUE), aValue -> Duration.ZERO, () -> Duration.ZERO);
198 | }
199 |
200 | @Override
201 | public void cleanup(String id) {
202 |
203 | }
204 |
205 | @Override
206 | public void destroy(String appName) {
207 |
208 | }
209 | }
210 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/cloud/deployer/spi/cloudfoundry/AppNameGenerator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.deployer.spi.cloudfoundry;
18 |
19 | /**
20 | * Strategy interface for generating the names of deployed applications. *
21 | *
22 | * @author Soby Chacko
23 | */
24 | public interface AppNameGenerator {
25 |
26 | /**
27 | * Generate an application name given a base name as the starting point.
28 | *
29 | * @param appName base application name
30 | * @return the generated app name
31 | */
32 | String generateAppName(String appName);
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/cloud/deployer/spi/cloudfoundry/CfEnvAwareAppDeploymentRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.deployer.spi.cloudfoundry;
18 |
19 | import org.springframework.cloud.deployer.spi.core.AppDeploymentRequest;
20 |
21 | /**
22 | * Copies an {@link AppDeploymentRequest} using a {@link CfEnvAwareResource}.
23 | *
24 | * @author David Turanski
25 | * @since 2.4
26 | */
27 | class CfEnvAwareAppDeploymentRequest extends AppDeploymentRequest {
28 |
29 | static CfEnvAwareAppDeploymentRequest of(AppDeploymentRequest appDeploymentRequest) {
30 | return new CfEnvAwareAppDeploymentRequest(appDeploymentRequest);
31 | }
32 |
33 | private CfEnvAwareAppDeploymentRequest(AppDeploymentRequest appDeploymentRequest) {
34 | super(appDeploymentRequest.getDefinition(),
35 | CfEnvAwareResource.of(appDeploymentRequest.getResource()),
36 | appDeploymentRequest.getDeploymentProperties(),
37 | appDeploymentRequest.getCommandlineArguments());
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/cloud/deployer/spi/cloudfoundry/CfEnvAwareResource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.deployer.spi.cloudfoundry;
18 |
19 | import java.io.File;
20 | import java.io.IOException;
21 | import java.io.InputStream;
22 | import java.net.MalformedURLException;
23 | import java.net.URI;
24 | import java.net.URL;
25 | import java.net.URLClassLoader;
26 | import java.util.ArrayList;
27 | import java.util.List;
28 | import java.util.Optional;
29 |
30 | import org.apache.commons.logging.Log;
31 | import org.apache.commons.logging.LogFactory;
32 |
33 | import org.springframework.boot.loader.archive.JarFileArchive;
34 | import org.springframework.core.io.Resource;
35 |
36 | /**
37 | * A {@link Resource} implementation that delegates to a resource and keeps the state of a CfEnv dependency
38 | * as an {@link Optional} which may be empty, true, or false.
39 | *
40 | * @author David Turanski
41 | * @since 2.4
42 | */
43 | class CfEnvAwareResource implements Resource {
44 | private final Resource resource;
45 |
46 | private final boolean hasCfEnv;
47 |
48 | static CfEnvAwareResource of(Resource resource) {
49 | return new CfEnvAwareResource(resource);
50 | }
51 | private CfEnvAwareResource(Resource resource) {
52 | this.resource = resource;
53 | this.hasCfEnv = CfEnvResolver.hasCfEnv(this);
54 | }
55 |
56 | @Override
57 | public boolean exists() {
58 | return resource.exists();
59 | }
60 |
61 | @Override
62 | public URL getURL() throws IOException {
63 | return resource.getURL();
64 | }
65 |
66 | @Override
67 | public URI getURI() throws IOException {
68 | return resource.getURI();
69 | }
70 |
71 | @Override
72 | public File getFile() throws IOException {
73 | return resource.getFile();
74 | }
75 |
76 | @Override
77 | public long contentLength() throws IOException {
78 | return resource.contentLength();
79 | }
80 |
81 | @Override
82 | public long lastModified() throws IOException {
83 | return resource.lastModified();
84 | }
85 |
86 | @Override
87 | public Resource createRelative(String s) throws IOException {
88 | return resource.createRelative(s);
89 | }
90 |
91 | @Override
92 | public String getFilename() {
93 | return resource.getFilename();
94 | }
95 |
96 | @Override
97 | public String getDescription() {
98 | return resource.getDescription();
99 | }
100 |
101 | @Override
102 | public InputStream getInputStream() throws IOException {
103 | return resource.getInputStream();
104 | }
105 |
106 | boolean hasCfEnv() {
107 | return this.hasCfEnv;
108 | }
109 |
110 | /**
111 | * Inspect the {@link CfEnvAwareResource} to determine if it contains a dependency on io.pivotal.cfenv.core.CfEnv.
112 | * Cache the result in the resource.
113 | */
114 | static class CfEnvResolver {
115 |
116 | private static Log logger = LogFactory.getLog(CfEnvResolver.class);
117 |
118 | private static final String CF_ENV = "io.pivotal.cfenv.core.CfEnv";
119 |
120 | static boolean hasCfEnv(CfEnvAwareResource app
121 | ) {
122 | try {
123 | String scheme = app.getURI().getScheme().toLowerCase();
124 | if (scheme.equals("docker")) {
125 | return false;
126 | }
127 | }
128 | catch (IOException e) {
129 | throw new IllegalArgumentException(e.getMessage(), e);
130 | }
131 |
132 | try {
133 | JarFileArchive archive = new JarFileArchive(app.getFile());
134 | List urls = new ArrayList<>();
135 | archive.getNestedArchives(entry -> entry.getName().endsWith(".jar"), null).forEachRemaining(a -> {
136 | try {
137 | urls.add(a.getUrl());
138 | }
139 | catch (MalformedURLException e) {
140 | logger.error("Unable to process nested archive " + e.getMessage());
141 | }
142 | });
143 | URLClassLoader classLoader = new URLClassLoader(urls.toArray(new URL[urls.size()]), null);
144 | try {
145 | Class.forName(CF_ENV, false, classLoader);
146 | return true;
147 | }
148 | catch (ClassNotFoundException e) {
149 | logger.debug(app.getFilename() + " does not contain " + CF_ENV);
150 | return false;
151 | }
152 | }
153 | catch (Exception e) {
154 | logger.warn("Unable to determine dependencies for " + app.getFilename());
155 | }
156 | return false;
157 | }
158 | }
159 | }
160 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/cloud/deployer/spi/cloudfoundry/CfEnvConfigurer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.deployer.spi.cloudfoundry;
18 |
19 | import java.util.HashMap;
20 | import java.util.Map;
21 | import java.util.stream.Stream;
22 |
23 | import org.apache.commons.logging.Log;
24 | import org.apache.commons.logging.LogFactory;
25 |
26 | import org.springframework.util.StringUtils;
27 |
28 | /**
29 | * Provides methods to configure environment, application properties, and command line
30 | * args if the deployed artifact uses java-cfenv.
31 | *
32 | * @author David Turanski
33 | * @since 2.4
34 | */
35 | class CfEnvConfigurer {
36 |
37 | private static final Log log = LogFactory.getLog(CfEnvConfigurer.class);
38 |
39 | static final String SPRING_PROFILES_ACTIVE = "SPRING_PROFILES_ACTIVE";
40 |
41 | static final String SPRING_PROFILES_ACTIVE_FQN = "spring.profiles.active";
42 |
43 | static final String SPRING_PROFILES_ACTIVE_HYPHENATED = "spring-profiles-active";
44 |
45 | static final String CLOUD_PROFILE_NAME = "cloud";
46 |
47 | static final String JBP_CONFIG_SPRING_AUTO_RECONFIGURATION = "JBP_CONFIG_SPRING_AUTO_RECONFIGURATION";
48 |
49 | static final String ENABLED_FALSE = "{ enabled: false }";
50 |
51 | /**
52 | * Disable Java Buildpack Spring Auto-reconfiguration.
53 | *
54 | * @param environment a map containing environment variables
55 | * @return an copy of the map setting the environment variable needed to disable
56 | * auto-reconfiguration
57 | */
58 | static Map disableJavaBuildPackAutoReconfiguration(Map environment) {
59 | log.debug("Disabling 'JBP_CONFIG_SPRING_AUTO_RECONFIGURATION'");
60 | Map updatedEnvironment = new HashMap<>(environment);
61 | updatedEnvironment.putIfAbsent(JBP_CONFIG_SPRING_AUTO_RECONFIGURATION, ENABLED_FALSE);
62 | return updatedEnvironment;
63 | }
64 |
65 | /**
66 | * Activate the cloud profile. Add to a key that binds to
67 | * spring.profiles.active if one exists.
68 | * @param environment a map containing environment variables or application properties
69 | * @param keyToCreate create a new entry using a preferred key if none exists.
70 | * @return the updated map
71 | */
72 | static Map activateCloudProfile(Map environment, String keyToCreate) {
73 | log.debug("Activating cloud profile");
74 | Map updatedEnvironment = new HashMap<>(environment);
75 |
76 | if (appendToExistingEntry(updatedEnvironment, SPRING_PROFILES_ACTIVE, CLOUD_PROFILE_NAME)) {
77 | return updatedEnvironment;
78 | }
79 | else if (appendToExistingEntry(updatedEnvironment, SPRING_PROFILES_ACTIVE_FQN, CLOUD_PROFILE_NAME)) {
80 | return updatedEnvironment;
81 | }
82 | else if (appendToExistingEntry(updatedEnvironment, SPRING_PROFILES_ACTIVE_HYPHENATED, CLOUD_PROFILE_NAME)) {
83 | return updatedEnvironment;
84 | }
85 | // If Key provided, create new spring profiles active entry.
86 | if (StringUtils.hasText(keyToCreate)) {
87 | updatedEnvironment.put(keyToCreate, CLOUD_PROFILE_NAME);
88 | }
89 |
90 | return updatedEnvironment;
91 | }
92 |
93 | /**
94 | * Process a command line argument to append the cloud profile if it binds to
95 | * spring.profiles.active.
96 | *
97 | * @param arg the current value
98 | * @return the updated value
99 | */
100 | static String appendCloudProfileToSpringProfilesActiveArg(String arg) {
101 | if ((arg.contains(SPRING_PROFILES_ACTIVE_FQN) ||
102 | arg.contains(SPRING_PROFILES_ACTIVE_HYPHENATED) ||
103 | arg.contains(SPRING_PROFILES_ACTIVE)) && arg.contains("=")) {
104 | String[] tokens = arg.split("=");
105 | arg = String.join("=", tokens[0], appendToValueIfPresent(tokens[1], CLOUD_PROFILE_NAME));
106 | }
107 | return arg;
108 | }
109 |
110 | private static boolean appendToExistingEntry(Map environment, String key, String value) {
111 | if (environment.containsKey(key)) {
112 | String current = environment.get(key);
113 | environment.put(key, appendToValueIfPresent(current, value));
114 | return true;
115 | }
116 | return false;
117 | }
118 |
119 | private static String appendToValueIfPresent(String current, String value) {
120 | if (StringUtils.hasText(current)) {
121 | if (!Stream.of(current.split(",")).filter(s -> s.trim().equals(value)).findFirst().isPresent()) {
122 | return current.join(",", current, value);
123 | }
124 | return current;
125 | }
126 | return value;
127 | }
128 | }
129 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/cloud/deployer/spi/cloudfoundry/CloudFoundryActuatorTemplate.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.deployer.spi.cloudfoundry;
18 |
19 | import java.util.Optional;
20 |
21 | import org.springframework.cloud.deployer.spi.app.AbstractActuatorTemplate;
22 | import org.springframework.cloud.deployer.spi.app.AppAdmin;
23 | import org.springframework.cloud.deployer.spi.app.AppDeployer;
24 | import org.springframework.cloud.deployer.spi.app.AppInstanceStatus;
25 | import org.springframework.http.HttpHeaders;
26 | import org.springframework.web.client.RestTemplate;
27 | import org.springframework.web.util.UriComponentsBuilder;
28 |
29 | /**
30 | * Access the actuator endpoint for an app instance deployed to Cloud Foundry.
31 | *
32 | * @author David Turanski
33 | */
34 | public class CloudFoundryActuatorTemplate extends AbstractActuatorTemplate {
35 |
36 | public CloudFoundryActuatorTemplate(RestTemplate restTemplate, AppDeployer appDeployer, AppAdmin appAdmin) {
37 | super(restTemplate, appDeployer, appAdmin);
38 | }
39 |
40 | @Override
41 | protected String actuatorUrlForInstance(AppInstanceStatus appInstanceStatus) {
42 | return UriComponentsBuilder.fromHttpUrl(appInstanceStatus.getAttributes().get("url"))
43 | .path("/actuator").toUriString();
44 | }
45 |
46 | @Override
47 | public Optional httpHeadersForInstance(AppInstanceStatus appInstanceStatus) {
48 | HttpHeaders headers = new HttpHeaders();
49 | headers.add("X-Cf-App-Instance", String.format("%s:%d", appInstanceStatus.getAttributes()
50 | .get(CloudFoundryAppInstanceStatus.CF_GUID),
51 | Integer.valueOf(appInstanceStatus.getAttributes().get(CloudFoundryAppInstanceStatus.INDEX))));
52 | return Optional.of(headers);
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/cloud/deployer/spi/cloudfoundry/CloudFoundryAppInstanceStatus.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016-2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.deployer.spi.cloudfoundry;
18 |
19 | import java.util.List;
20 | import java.util.Map;
21 | import java.util.TreeMap;
22 |
23 | import org.cloudfoundry.operations.applications.ApplicationDetail;
24 | import org.cloudfoundry.operations.applications.InstanceDetail;
25 |
26 | import org.springframework.cloud.deployer.spi.app.AppInstanceStatus;
27 | import org.springframework.cloud.deployer.spi.app.DeploymentState;
28 |
29 | /**
30 | * Maps status returned by the Cloud Foundry API to {@link AppInstanceStatus}.
31 | *
32 | * @author Eric Bottard
33 | * @author David Turanski
34 | */
35 | public class CloudFoundryAppInstanceStatus implements AppInstanceStatus {
36 |
37 | private final InstanceDetail instanceDetail;
38 |
39 | private final ApplicationDetail applicationDetail;
40 |
41 | private final int index;
42 |
43 | private final Map attributes = new TreeMap<>();
44 |
45 | /**
46 | * The deployer assigned unique id for each app instance.
47 | */
48 | static final String GUID = "guid";
49 |
50 | /**
51 | * The platform assigned guid - common among app instances with replicas
52 | */
53 | static final String CF_GUID = "cf-guid";
54 |
55 | /**
56 | * The app index.
57 | */
58 | static final String INDEX = "index";
59 |
60 | public CloudFoundryAppInstanceStatus(ApplicationDetail applicationDetail, InstanceDetail instanceDetail, int index) {
61 | this.applicationDetail = applicationDetail;
62 | this.instanceDetail = instanceDetail;
63 | this.index = index;
64 | }
65 |
66 | @Override
67 | public String getId() {
68 | return applicationDetail.getName() + "-" + index;
69 | }
70 |
71 | @Override
72 | public DeploymentState getState() {
73 | if (instanceDetail == null) {
74 | return DeploymentState.failed;
75 | }
76 | switch (instanceDetail.getState()) {
77 | case "STARTING":
78 | case "DOWN":
79 | return DeploymentState.deploying;
80 | case "CRASHED":
81 | return DeploymentState.failed;
82 | // Seems the client incorrectly reports apps as FLAPPING when they are
83 | // obviously fine. Mapping as RUNNING for now
84 | case "FLAPPING":
85 | case "RUNNING":
86 | return DeploymentState.deployed;
87 | case "UNKNOWN":
88 | return DeploymentState.unknown;
89 | default:
90 | throw new IllegalStateException("Unsupported CF state: " + instanceDetail.getState());
91 | }
92 | }
93 |
94 | @Override
95 | public Map getAttributes() {
96 | if (instanceDetail != null) {
97 | if (instanceDetail.getCpu() != null) {
98 | attributes.put("metrics.machine.cpu", String.format("%.1f%%", instanceDetail.getCpu() * 100d));
99 | }
100 | if (instanceDetail.getDiskQuota() != null && instanceDetail.getDiskUsage() != null) {
101 | attributes.put("metrics.machine.disk", String.format("%.1f%%", 100d * instanceDetail.getDiskUsage() / instanceDetail.getDiskQuota()));
102 | }
103 | if (instanceDetail.getMemoryQuota() != null && instanceDetail.getMemoryUsage() != null) {
104 | attributes.put("metrics.machine.memory", String.format("%.1f%%", 100d * instanceDetail.getMemoryUsage() / instanceDetail.getMemoryQuota()));
105 | }
106 | }
107 | List urls = applicationDetail.getUrls();
108 | if (!urls.isEmpty()) {
109 | attributes.put("url", "http://" + urls.get(0));
110 | for (int i = 0; i < urls.size() ; i++) {
111 | attributes.put("url." + i, "http://" + urls.get(i));
112 | }
113 | }
114 | // TODO cf-java-client versions > 2.8 will have an index formally added ot InstanceDetail
115 | /*
116 | The deployer GUID must be unique for each app instance, the CloudFoundry GUID is common to all instances of
117 | the same app.
118 | */
119 | attributes.put(GUID, applicationDetail.getName() + ":" + index);
120 | attributes.put(CF_GUID, applicationDetail.getId());
121 | attributes.put(INDEX, String.valueOf(index));
122 | return attributes;
123 | }
124 |
125 | @Override
126 | public String toString() {
127 | return String.format("%s[%s : %s]" , getClass().getSimpleName(), getId(), getState());
128 | }
129 | }
130 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/cloud/deployer/spi/cloudfoundry/CloudFoundryAppNameGenerator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.deployer.spi.cloudfoundry;
18 |
19 | import java.util.Random;
20 |
21 | import org.apache.commons.logging.Log;
22 | import org.apache.commons.logging.LogFactory;
23 |
24 | import org.springframework.beans.factory.InitializingBean;
25 | import org.springframework.util.StringUtils;
26 |
27 | /**
28 | * CloudFoundry specific implementation of {@link AppNameGenerator}. This takes into account the
29 | * configuration properties {@code enableRandomAppNamePrefix} and {@code appNamePrefix}.
30 | *
31 | * If {@code enableRandomAppNamePrefix} a random short string is prefixed to the base name.
32 | * It is true by default. If {@code appNamePrefix} is set, it is also prefixed before the random string.
33 | * By default the {@code appNamePrefix} is the value of {@code spring.application.name} if available,
34 | * otherwise the empty string.
35 | *
36 | * As an example, if {@code enableRandomAppNamePrefix=true}, {@code spring.application.name=server},
37 | * and we are deploying an application whose base name is {@code time}, then the deployed name on Cloud Foundry
38 | * may be {@code server-ug54dh5-time}
39 | *
40 | * @author Soby Chacko
41 | * @author Mark Pollack
42 | */
43 | public class CloudFoundryAppNameGenerator implements AppNameGenerator, InitializingBean {
44 |
45 | private static final Log logger = LogFactory.getLog(CloudFoundryAppNameGenerator.class);
46 |
47 | /* Given that appnames are by default part of a hostname, limit to 63 chars max. */
48 | private static final int MAX_APPNAME_LENGTH = 63;
49 |
50 | private String prefixToUse = "";
51 |
52 | private final CloudFoundryDeploymentProperties properties;
53 |
54 | public CloudFoundryAppNameGenerator(CloudFoundryDeploymentProperties cloudFoundryDeploymentProperties) {
55 | this.properties = cloudFoundryDeploymentProperties;
56 | }
57 |
58 | @Override
59 | public void afterPropertiesSet() throws Exception {
60 | if (properties.isEnableRandomAppNamePrefix()) {
61 | prefixToUse = createUniquePrefix();
62 | if (!StringUtils.isEmpty(properties.getAppNamePrefix())) {
63 | prefixToUse = String.format("%s-%s", properties.getAppNamePrefix(), prefixToUse);
64 | }
65 | } else {
66 | if (!StringUtils.isEmpty(properties.getAppNamePrefix())) {
67 | prefixToUse = properties.getAppNamePrefix();
68 | }
69 | }
70 | logger.info(String.format("Prefix to be used for deploying apps: %s", prefixToUse));
71 | }
72 |
73 |
74 | @Override
75 | public String generateAppName(String appName) {
76 | if (StringUtils.isEmpty(prefixToUse)) {
77 | return appName.substring(0, Math.min(MAX_APPNAME_LENGTH, appName.length()));
78 | } else {
79 | String string = String.format("%s-%s", prefixToUse, appName);
80 | return string.substring(0, Math.min(MAX_APPNAME_LENGTH, string.length()));
81 | }
82 | }
83 |
84 | private String createUniquePrefix() {
85 | String alphabet = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
86 | char[] result = new char[7];
87 | Random random = new Random();
88 | for (int i = 0 ; i < result.length ; i++) {
89 | result[i] = alphabet.charAt(random.nextInt(alphabet.length()));
90 | }
91 | return new String(result);
92 | }
93 |
94 |
95 | }
96 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/cloud/deployer/spi/cloudfoundry/CloudFoundryConnectionProperties.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016-2020 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.deployer.spi.cloudfoundry;
18 |
19 | import java.net.URL;
20 |
21 | import javax.validation.constraints.NotNull;
22 |
23 | import org.springframework.validation.annotation.Validated;
24 |
25 | /**
26 | * Holds configuration properties for connecting to a Cloud Foundry runtime.
27 | *
28 | * @author Eric Bottard
29 | * @author Greg Turnquist
30 | */
31 | @Validated
32 | public class CloudFoundryConnectionProperties {
33 |
34 | /**
35 | * Top level prefix for Cloud Foundry related configuration properties.
36 | */
37 | public static final String CLOUDFOUNDRY_PROPERTIES = "spring.cloud.deployer.cloudfoundry";
38 |
39 | /**
40 | * The organization to use when registering new applications.
41 | */
42 | @NotNull
43 | private String org;
44 |
45 | /**
46 | * The space to use when registering new applications.
47 | */
48 | @NotNull
49 | private String space;
50 |
51 | /**
52 | * Location of the CloudFoundry REST API endpoint to use.
53 | */
54 | @NotNull
55 | private URL url;
56 |
57 | /**
58 | * Username to use to authenticate against the Cloud Foundry API.
59 | */
60 | @NotNull
61 | private String username;
62 |
63 | /**
64 | * Password to use to authenticate against the Cloud Foundry API.
65 | */
66 | @NotNull
67 | private String password;
68 |
69 | /**
70 | * ClientId to use with token providers, effectively defaults to "cf" in
71 | * cloudfroundry client.
72 | */
73 | private String clientId;
74 |
75 | /**
76 | * ClientSecret to use with token providers, effectively defaults to empty in
77 | * cloudfroundry client.
78 | */
79 | private String clientSecret;
80 |
81 | /**
82 | * Indicates the identity provider to be used when accessing the Cloud Foundry API.
83 | * The passed string has to be a URL-Encoded JSON Object, containing the field origin with value as origin_key of an identity provider.
84 | */
85 | private String loginHint;
86 |
87 | /**
88 | * Allow operation using self-signed certificates.
89 | */
90 | private boolean skipSslValidation = false;
91 |
92 | public String getOrg() {
93 | return org;
94 | }
95 |
96 | public void setOrg(String org) {
97 | this.org = org;
98 | }
99 |
100 | public String getSpace() {
101 | return space;
102 | }
103 |
104 | public void setSpace(String space) {
105 | this.space = space;
106 | }
107 |
108 | public URL getUrl() {
109 | return url;
110 | }
111 |
112 | public void setUrl(URL url) {
113 | this.url = url;
114 | }
115 |
116 | public String getClientId() {
117 | return clientId;
118 | }
119 |
120 | public void setClientId(String clientId) {
121 | this.clientId = clientId;
122 | }
123 |
124 | public String getClientSecret() {
125 | return clientSecret;
126 | }
127 |
128 | public void setClientSecret(String clientSecret) {
129 | this.clientSecret = clientSecret;
130 | }
131 |
132 | public String getUsername() {
133 | return username;
134 | }
135 |
136 | public void setUsername(String username) {
137 | this.username = username;
138 | }
139 |
140 | public String getPassword() {
141 | return password;
142 | }
143 |
144 | public void setPassword(String password) {
145 | this.password = password;
146 | }
147 |
148 | public boolean isSkipSslValidation() {
149 | return skipSslValidation;
150 | }
151 |
152 | public void setSkipSslValidation(boolean skipSslValidation) {
153 | this.skipSslValidation = skipSslValidation;
154 | }
155 |
156 | public String getLoginHint() {
157 | return loginHint;
158 | }
159 |
160 | public void setLoginHint(String loginHint) {
161 | this.loginHint = loginHint;
162 | }
163 | }
164 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/cloud/deployer/spi/cloudfoundry/CloudFoundryDeployerAutoConfiguration.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.deployer.spi.cloudfoundry;
18 |
19 | import java.time.Duration;
20 |
21 | import com.github.zafarkhaja.semver.Version;
22 | import org.cloudfoundry.client.CloudFoundryClient;
23 | import org.cloudfoundry.client.v2.info.GetInfoRequest;
24 | import org.cloudfoundry.operations.CloudFoundryOperations;
25 | import org.cloudfoundry.operations.DefaultCloudFoundryOperations;
26 | import org.cloudfoundry.reactor.ConnectionContext;
27 | import org.cloudfoundry.reactor.DefaultConnectionContext;
28 | import org.cloudfoundry.reactor.TokenProvider;
29 | import org.cloudfoundry.reactor.client.ReactorCloudFoundryClient;
30 | import org.cloudfoundry.reactor.tokenprovider.PasswordGrantTokenProvider;
31 | import org.cloudfoundry.reactor.tokenprovider.PasswordGrantTokenProvider.Builder;
32 | import org.slf4j.Logger;
33 | import org.slf4j.LoggerFactory;
34 |
35 | import org.springframework.beans.factory.annotation.Autowired;
36 | import org.springframework.boot.autoconfigure.AutoConfigureOrder;
37 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
38 | import org.springframework.boot.context.properties.ConfigurationProperties;
39 | import org.springframework.boot.context.properties.ConfigurationPropertiesBinding;
40 | import org.springframework.boot.context.properties.EnableConfigurationProperties;
41 | import org.springframework.cloud.deployer.spi.app.AppDeployer;
42 | import org.springframework.cloud.deployer.spi.core.RuntimeEnvironmentInfo;
43 | import org.springframework.cloud.deployer.spi.task.TaskLauncher;
44 | import org.springframework.cloud.deployer.spi.util.RuntimeVersionUtils;
45 | import org.springframework.context.annotation.Bean;
46 | import org.springframework.context.annotation.Configuration;
47 | import org.springframework.core.Ordered;
48 | import org.springframework.util.StringUtils;
49 | import org.springframework.web.client.RestTemplate;
50 |
51 |
52 | /**
53 | * Creates a {@link CloudFoundryAppDeployer}
54 | *
55 | * @author Eric Bottard
56 | * @author Ben Hale
57 | * @author David Turanski
58 | */
59 | @Configuration
60 | @EnableConfigurationProperties
61 | @AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE)
62 | public class CloudFoundryDeployerAutoConfiguration {
63 |
64 | private static final Logger logger = LoggerFactory.getLogger(CloudFoundryDeployerAutoConfiguration.class);
65 |
66 | @Autowired
67 | private EarlyConnectionConfiguration connectionConfiguration;
68 |
69 | @Bean
70 | @ConditionalOnMissingBean
71 | public CloudFoundryOperations cloudFoundryOperations(CloudFoundryClient cloudFoundryClient, CloudFoundryConnectionProperties properties) {
72 | return DefaultCloudFoundryOperations.builder()
73 | .cloudFoundryClient(cloudFoundryClient)
74 | .organization(properties.getOrg())
75 | .space(properties.getSpace())
76 | .build();
77 | }
78 |
79 | private RuntimeEnvironmentInfo runtimeEnvironmentInfo(Class spiClass, Class implementationClass) {
80 | CloudFoundryClient client = connectionConfiguration.cloudFoundryClient(
81 | connectionConfiguration.connectionContext(connectionConfiguration.cloudFoundryConnectionProperties()),
82 | connectionConfiguration.tokenProvider(connectionConfiguration.cloudFoundryConnectionProperties()));
83 | Version version = connectionConfiguration.version(client);
84 |
85 | return new CloudFoundryPlatformSpecificInfo(new RuntimeEnvironmentInfo.Builder())
86 | .apiEndpoint(connectionConfiguration.cloudFoundryConnectionProperties().getUrl().toString())
87 | .org(connectionConfiguration.cloudFoundryConnectionProperties().getOrg())
88 | .space(connectionConfiguration.cloudFoundryConnectionProperties().getSpace())
89 | .builder()
90 | .implementationName(implementationClass.getSimpleName())
91 | .spiClass(spiClass)
92 | .implementationVersion(RuntimeVersionUtils.getVersion(CloudFoundryAppDeployer.class))
93 | .platformType("Cloud Foundry")
94 | .platformClientVersion(RuntimeVersionUtils.getVersion(client.getClass()))
95 | .platformApiVersion(version.toString())
96 | .platformHostVersion("unknown")
97 | .build();
98 | }
99 |
100 | @Bean
101 | @ConditionalOnMissingBean(AppDeployer.class)
102 | public AppDeployer appDeployer(CloudFoundryOperations operations,
103 | AppNameGenerator applicationNameGenerator) {
104 | return new CloudFoundryAppDeployer(
105 | applicationNameGenerator,
106 | connectionConfiguration.appDeploymentProperties(),
107 | operations,
108 | runtimeEnvironmentInfo(AppDeployer.class, CloudFoundryAppDeployer.class)
109 | );
110 | }
111 |
112 | @Bean
113 | CloudFoundryActuatorTemplate actuatorOperations(RestTemplate actuatorRestTemplate, AppDeployer appDeployer) {
114 | return new CloudFoundryActuatorTemplate(actuatorRestTemplate, appDeployer,
115 | connectionConfiguration.appDeploymentProperties().getAppAdmin());
116 | }
117 |
118 | @Bean
119 | RestTemplate actuatorRestTemplate() {
120 | return new RestTemplate();
121 | }
122 |
123 | @Bean
124 | @ConditionalOnMissingBean(AppNameGenerator.class)
125 | public AppNameGenerator appDeploymentCustomizer() {
126 | return new CloudFoundryAppNameGenerator(connectionConfiguration.appDeploymentProperties());
127 | }
128 |
129 | @Bean
130 | @ConditionalOnMissingBean(TaskLauncher.class)
131 | public TaskLauncher taskLauncher(CloudFoundryClient client,
132 | CloudFoundryOperations operations,
133 | Version version) {
134 |
135 | if (version.greaterThanOrEqualTo(UnsupportedVersionTaskLauncher.MINIMUM_SUPPORTED_VERSION)) {
136 | RuntimeEnvironmentInfo runtimeEnvironmentInfo = runtimeEnvironmentInfo(TaskLauncher.class, CloudFoundryTaskLauncher.class);
137 | return new CloudFoundryTaskLauncher(
138 | client,
139 | connectionConfiguration.taskDeploymentProperties(),
140 | operations,
141 | runtimeEnvironmentInfo);
142 | } else {
143 | RuntimeEnvironmentInfo runtimeEnvironmentInfo = runtimeEnvironmentInfo(TaskLauncher.class, UnsupportedVersionTaskLauncher.class);
144 | return new UnsupportedVersionTaskLauncher(version, runtimeEnvironmentInfo);
145 | }
146 | }
147 |
148 | @Bean
149 | @ConfigurationPropertiesBinding
150 | public DurationConverter durationConverter() {
151 | return new DurationConverter();
152 | }
153 |
154 | /**
155 | * A subset of configuration beans that can be used on its own to connect to the Cloud Controller API
156 | * and query it for its version. Automatically applied in CloudFoundryDeployerAutoConfiguration by virtue
157 | * of being a static inner class of it.
158 | *
159 | * @author Eric Bottard
160 | */
161 | @Configuration
162 | @EnableConfigurationProperties
163 | public static class EarlyConnectionConfiguration {
164 |
165 | @Bean
166 | @ConditionalOnMissingBean(name = "appDeploymentProperties")
167 | public CloudFoundryDeploymentProperties appDeploymentProperties() {
168 | return defaultSharedDeploymentProperties();
169 | }
170 |
171 |
172 | @Bean
173 | @ConditionalOnMissingBean(name = "taskDeploymentProperties")
174 | public CloudFoundryDeploymentProperties taskDeploymentProperties() {
175 | return defaultSharedDeploymentProperties();
176 | }
177 |
178 | @Bean
179 | @ConfigurationProperties(prefix = CloudFoundryConnectionProperties.CLOUDFOUNDRY_PROPERTIES)
180 | public CloudFoundryDeploymentProperties defaultSharedDeploymentProperties() {
181 | return new CloudFoundryDeploymentProperties();
182 | }
183 |
184 | @Bean
185 | @ConditionalOnMissingBean
186 | public Version version(CloudFoundryClient client) {
187 | return client.info()
188 | .get(GetInfoRequest.builder()
189 | .build())
190 | .map(response -> Version.valueOf(response.getApiVersion()))
191 | .doOnError(e -> {
192 | throw new RuntimeException("Bad credentials connecting to Cloud Foundry.", e);
193 | })
194 | .doOnNext(version -> logger.info("Connecting to Cloud Foundry with API Version {}", version))
195 | .block(Duration.ofSeconds(appDeploymentProperties().getApiTimeout()));
196 | }
197 |
198 | @Bean
199 | @ConditionalOnMissingBean
200 | public CloudFoundryClient cloudFoundryClient(ConnectionContext connectionContext, TokenProvider tokenProvider) {
201 | return ReactorCloudFoundryClient.builder()
202 | .connectionContext(connectionContext)
203 | .tokenProvider(tokenProvider)
204 | .build();
205 | }
206 |
207 | @Bean
208 | @ConditionalOnMissingBean
209 | public TokenProvider tokenProvider(CloudFoundryConnectionProperties properties) {
210 | Builder tokenProviderBuilder = PasswordGrantTokenProvider.builder()
211 | .username(properties.getUsername())
212 | .password(properties.getPassword())
213 | .loginHint(properties.getLoginHint());
214 | if (StringUtils.hasText(properties.getClientId())) {
215 | tokenProviderBuilder.clientId(properties.getClientId());
216 | }
217 | if (StringUtils.hasText(properties.getClientSecret())) {
218 | tokenProviderBuilder.clientSecret(properties.getClientSecret());
219 | }
220 | return tokenProviderBuilder.build();
221 | }
222 |
223 | @Bean
224 | @ConditionalOnMissingBean
225 | @ConfigurationProperties(prefix = CloudFoundryConnectionProperties.CLOUDFOUNDRY_PROPERTIES)
226 | public CloudFoundryConnectionProperties cloudFoundryConnectionProperties() {
227 | return new CloudFoundryConnectionProperties();
228 | }
229 |
230 | @Bean
231 | @ConditionalOnMissingBean
232 | public ConnectionContext connectionContext(CloudFoundryConnectionProperties properties) {
233 | return DefaultConnectionContext.builder()
234 | .apiHost(properties.getUrl().getHost())
235 | .skipSslValidation(properties.isSkipSslValidation())
236 | .build();
237 | }
238 | }
239 | }
240 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/cloud/deployer/spi/cloudfoundry/CloudFoundryPlatformSpecificInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.deployer.spi.cloudfoundry;
18 |
19 | import org.springframework.cloud.deployer.spi.core.RuntimeEnvironmentInfo;
20 | import org.springframework.util.Assert;
21 |
22 | /**
23 | * A Provides required platform specific values to {@link RuntimeEnvironmentInfo}.
24 | *
25 | * @author David Turanski
26 | */
27 | public class CloudFoundryPlatformSpecificInfo {
28 | static final String API_ENDPOINT = "API Endpoint";
29 |
30 | static final String ORG = "Organization";
31 |
32 | static final String SPACE = "Space";
33 |
34 | private final RuntimeEnvironmentInfo.Builder runtimeEnvironmentInfo;
35 |
36 | private String apiEndpoint;
37 |
38 | private String org;
39 |
40 | private String space;
41 |
42 | public CloudFoundryPlatformSpecificInfo(RuntimeEnvironmentInfo.Builder runtimeEnvironmentInfo) {
43 | this.runtimeEnvironmentInfo = runtimeEnvironmentInfo;
44 | }
45 |
46 | public CloudFoundryPlatformSpecificInfo apiEndpoint(String apiEndpoint) {
47 | this.apiEndpoint = apiEndpoint;
48 | return this;
49 | }
50 |
51 | public CloudFoundryPlatformSpecificInfo org(String org) {
52 | this.org = org;
53 | return this;
54 | }
55 |
56 | public CloudFoundryPlatformSpecificInfo space(String space) {
57 | this.space = space;
58 | return this;
59 | }
60 |
61 | public RuntimeEnvironmentInfo.Builder builder() {
62 | Assert.hasText(apiEndpoint, "'apiEndpoint' must contain text");
63 | Assert.hasText(org, "'org' must contain text");
64 | Assert.hasText(space, "'space' must contain text");
65 | runtimeEnvironmentInfo.addPlatformSpecificInfo(API_ENDPOINT, apiEndpoint);
66 | runtimeEnvironmentInfo.addPlatformSpecificInfo(ORG, org);
67 | runtimeEnvironmentInfo.addPlatformSpecificInfo(SPACE, space);
68 | return runtimeEnvironmentInfo;
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/cloud/deployer/spi/cloudfoundry/DurationConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.deployer.spi.cloudfoundry;
18 |
19 | import java.time.Duration;
20 | import java.time.format.DateTimeParseException;
21 |
22 | import org.springframework.core.convert.converter.Converter;
23 | import org.springframework.util.StringUtils;
24 |
25 | /**
26 | * Converter from String to {@link java.time.Duration}, accepting human readable forms (without an H or a T).
27 | *
28 | * @author Eric Bottard
29 | */
30 | public class DurationConverter implements Converter {
31 |
32 | @Override
33 | public Duration convert(String source) {
34 | if (StringUtils.isEmpty(source)) {
35 | return null;
36 | }
37 | try {
38 | return Duration.parse(source);
39 | }
40 | catch (DateTimeParseException ignored) {
41 | return Duration.parse("PT" + source);
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/cloud/deployer/spi/cloudfoundry/ServiceParser.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019-2020 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.deployer.spi.cloudfoundry;
18 |
19 | import java.util.ArrayList;
20 | import java.util.LinkedHashMap;
21 | import java.util.List;
22 | import java.util.Map;
23 | import java.util.Optional;
24 | import java.util.regex.Matcher;
25 | import java.util.regex.Pattern;
26 | import java.util.stream.Stream;
27 |
28 | import org.springframework.util.StringUtils;
29 |
30 | /**
31 | * Parses service instances and parses binding parameters if provided. Accepts Strings like
32 | * 'myservice foo=bar, cat=bat' or 'service foo:bar, cat:bat', White space is required between the
33 | * service name and parameters, but optional between the key-value pairs.
34 | *
35 | * @author David Turanski
36 | */
37 | abstract class ServiceParser {
38 |
39 | private static Pattern serviceWithParameters = Pattern.compile("([^\\s]+)\\s*?(.*)?");
40 |
41 | private static Pattern singleQuotedLiteral = Pattern.compile("'([^']*?)'");
42 |
43 | /**
44 | * @param serviceSpec the service instance followed by optional parameters.
45 | * @return an Option