Skip to content

Commit 92beee6

Browse files
authored
DEVX-299 add option to customize api url and auth url (#537)
* DEVX-299 add option to customize api url and auth url * DEVX-299 remove optional CI params * Release v5.4.3
1 parent dc15de7 commit 92beee6

File tree

3 files changed

+49
-32
lines changed

3 files changed

+49
-32
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,8 @@ jobs:
2323
SOURCE_PROJECT_KEY: project-sync-source
2424
SOURCE_CLIENT_ID: ${{ secrets.SOURCE_CLIENT_ID }}
2525
SOURCE_CLIENT_SECRET: ${{ secrets.SOURCE_CLIENT_SECRET }}
26-
SOURCE_AUTH_URL: ${{ secrets.SOURCE_AUTH_URL }}
27-
SOURCE_API_URL: ${{ secrets.SOURCE_API_URL }}
2826
TARGET_PROJECT_KEY: project-sync-target
2927
TARGET_CLIENT_ID: ${{ secrets.TARGET_CLIENT_ID }}
3028
TARGET_CLIENT_SECRET: ${{ secrets.TARGET_CLIENT_SECRET }}
31-
TARGET_AUTH_URL: ${{ secrets.TARGET_AUTH_URL }}
32-
TARGET_API_URL: ${{ secrets.TARGET_API_URL }}
3329
- name: Codecov
3430
uses: codecov/codecov-action@v3

README.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ Example:
210210
##### Download
211211

212212
```bash
213-
docker pull commercetools/commercetools-project-sync:5.4.1
213+
docker pull commercetools/commercetools-project-sync:5.4.3
214214
```
215215
##### Run
216216

@@ -222,14 +222,14 @@ docker run \
222222
-e TARGET_PROJECT_KEY=xxxx \
223223
-e TARGET_CLIENT_ID=xxxx \
224224
-e TARGET_CLIENT_SECRET=xxxx \
225-
commercetools/commercetools-project-sync:5.4.1 -s all
225+
commercetools/commercetools-project-sync:5.4.3 -s all
226226
```
227227

228228

229229
### Examples
230230
- To run the all sync modules from a source project to a target project
231231
```bash
232-
docker run commercetools/commercetools-project-sync:5.4.1 -s all
232+
docker run commercetools/commercetools-project-sync:5.4.3 -s all
233233
```
234234
This will run the following sync modules in the given order:
235235
1. `Type` Sync and `ProductType` Sync and `States` Sync and `TaxCategory` Sync and `CustomObject` Sync in parallel.
@@ -239,70 +239,70 @@ commercetools/commercetools-project-sync:5.4.1 -s all
239239

240240
- To run the type sync
241241
```bash
242-
docker run commercetools/commercetools-project-sync:5.4.1 -s types
242+
docker run commercetools/commercetools-project-sync:5.4.3 -s types
243243
```
244244

245245
- To run the productType sync
246246
```bash
247-
docker run commercetools/commercetools-project-sync:5.4.1 -s productTypes
247+
docker run commercetools/commercetools-project-sync:5.4.3 -s productTypes
248248
```
249249

250250
- To run the states sync
251251
```bash
252-
docker run commercetools/commercetools-project-sync:5.4.1 -s states
252+
docker run commercetools/commercetools-project-sync:5.4.3 -s states
253253
```
254254
- To run the taxCategory sync
255255
```bash
256-
docker run commercetools/commercetools-project-sync:5.4.1 -s taxCategories
256+
docker run commercetools/commercetools-project-sync:5.4.3 -s taxCategories
257257
```
258258

259259
- To run the category sync
260260
```bash
261-
docker run commercetools/commercetools-project-sync:5.4.1 -s categories
261+
docker run commercetools/commercetools-project-sync:5.4.3 -s categories
262262
```
263263

264264
- To run the product sync
265265
```bash
266-
docker run commercetools/commercetools-project-sync:5.4.1 -s products
266+
docker run commercetools/commercetools-project-sync:5.4.3 -s products
267267
```
268268

269269
- To run the cartDiscount sync
270270
```bash
271-
docker run commercetools/commercetools-project-sync:5.4.1 -s cartDiscounts
271+
docker run commercetools/commercetools-project-sync:5.4.3 -s cartDiscounts
272272
```
273273

274274
- To run the inventoryEntry sync
275275
```bash
276-
docker run commercetools/commercetools-project-sync:5.4.1 -s inventoryEntries
276+
docker run commercetools/commercetools-project-sync:5.4.3 -s inventoryEntries
277277
```
278278

279279
- To run the customObject sync
280280
```bash
281-
docker run commercetools/commercetools-project-sync:5.4.1 -s customObjects
281+
docker run commercetools/commercetools-project-sync:5.4.3 -s customObjects
282282
```
283283

284284
- To run the customer sync
285285
```bash
286-
docker run commercetools/commercetools-project-sync:5.4.1 -s customers
286+
docker run commercetools/commercetools-project-sync:5.4.3 -s customers
287287
```
288288

289289
- To run the shoppingList sync
290290
```bash
291-
docker run commercetools/commercetools-project-sync:5.4.1 -s shoppingLists
291+
docker run commercetools/commercetools-project-sync:5.4.3 -s shoppingLists
292292
```
293293
- To run both products and shoppingList sync
294294
```bash
295-
docker run commercetools/commercetools-project-sync:5.4.1 -s products shoppingLists
295+
docker run commercetools/commercetools-project-sync:5.4.3 -s products shoppingLists
296296
```
297297

298298
- To run type, productType and shoppingList sync
299299
```bash
300-
docker run commercetools/commercetools-project-sync:5.4.1 -s types productTypes shoppingLists
300+
docker run commercetools/commercetools-project-sync:5.4.3 -s types productTypes shoppingLists
301301
```
302302

303303
- To run all sync modules using a runner name
304304
```bash
305-
docker run commercetools/commercetools-project-sync:5.4.1 -s all -r myRunnerName
305+
docker run commercetools/commercetools-project-sync:5.4.3 -s all -r myRunnerName
306306
```
307307

308308
## Scopes

src/main/java/com/commercetools/project/sync/util/CtpClientUtils.java

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,20 +104,41 @@ private static ProjectApiRoot createCtpClient(
104104
.build(projectKey);
105105
}
106106

107-
private static Properties loadFromEnvVars(String propertiesPrefix) {
108-
String projectKeyKey = propertiesPrefix.toUpperCase().replace(".", "_") + "PROJECT_KEY";
109-
String projectKey = System.getenv(projectKeyKey);
110-
String clientIdKey = propertiesPrefix.toUpperCase().replace(".", "_") + "CLIENT_ID";
111-
String clientId = System.getenv(clientIdKey);
112-
String clientSecretKey = propertiesPrefix.toUpperCase().replace(".", "_") + "CLIENT_SECRET";
113-
String clientSecret = System.getenv(clientSecretKey);
114-
Properties properties = new Properties();
115-
properties.put(propertiesPrefix + PROPERTIES_KEY_PROJECT_KEY_SUFFIX, projectKey);
116-
properties.put(propertiesPrefix + PROPERTIES_KEY_CLIENT_ID_SUFFIX, clientId);
117-
properties.put(propertiesPrefix + PROPERTIES_KEY_CLIENT_SECRET_SUFFIX, clientSecret);
107+
private static Properties loadFromEnvVars(final String propertiesPrefix) {
108+
final Properties properties = new Properties();
109+
110+
final String capitalizeAndReplaceDot = propertiesPrefix.toUpperCase().replace(".", "_");
111+
112+
properties.put(
113+
propertiesPrefix + PROPERTIES_KEY_PROJECT_KEY_SUFFIX,
114+
getPropertyFromEnv(capitalizeAndReplaceDot + "PROJECT_KEY"));
115+
properties.put(
116+
propertiesPrefix + PROPERTIES_KEY_CLIENT_ID_SUFFIX,
117+
getPropertyFromEnv(capitalizeAndReplaceDot + "CLIENT_ID"));
118+
properties.put(
119+
propertiesPrefix + PROPERTIES_KEY_CLIENT_SECRET_SUFFIX,
120+
getPropertyFromEnv(capitalizeAndReplaceDot + "CLIENT_SECRET"));
121+
final String authUrl = getPropertyFromEnv(capitalizeAndReplaceDot + "AUTH_URL");
122+
if (authUrl != null) {
123+
properties.put(propertiesPrefix + PROPERTIES_KEY_AUTH_URL_SUFFIX, authUrl);
124+
}
125+
final String apiUrl = getPropertyFromEnv(capitalizeAndReplaceDot + "API_URL");
126+
if (apiUrl != null) {
127+
properties.put(propertiesPrefix + PROPERTIES_KEY_API_URL_SUFFIX, apiUrl);
128+
}
129+
130+
final String scopes = getPropertyFromEnv(capitalizeAndReplaceDot + "SCOPES");
131+
if (scopes != null) {
132+
properties.put(propertiesPrefix + PROPERTIES_KEY_SCOPES_SUFFIX, scopes);
133+
}
134+
118135
return properties;
119136
}
120137

138+
private static String getPropertyFromEnv(String key) {
139+
return System.getenv(key);
140+
}
141+
121142
private static String extract(
122143
final Properties properties,
123144
final String prefix,

0 commit comments

Comments
 (0)