Skip to content

Commit 16b05b4

Browse files
DoggyDoggyDoggyAndreH871srnagar
authored
Add OpenRewrite recipes for appconfiguration to automate migration to v2 (#46709)
* AadAuthentication test * appconfiguration yml files * appconfiguration yml files update * Delete old samples * Rename new samples folders * Update pom file * Added appconfiguration to rewrite.yml * disabled golden images that use appconfig/implementation * Update pom.xml file for OpenRewrite with dependencies * Pipeline fix * Update CI pipeline to include appconfig dependency --------- Co-authored-by: Andre Hoffmann <[email protected]> Co-authored-by: Srikanta <[email protected]> Co-authored-by: Srikanta <[email protected]>
1 parent 388e64d commit 16b05b4

File tree

31 files changed

+320
-129
lines changed

31 files changed

+320
-129
lines changed

eng/versioning/version_client.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,7 @@ io.clientcore:optional-dependency-tests;1.0.0-beta.1;1.0.0-beta.1
546546

547547
unreleased_com.azure.v2:azure-core;2.0.0-beta.1
548548
unreleased_com.azure.v2:azure-identity;2.0.0-beta.1
549+
unreleased_com.azure.v2:azure-data-appconfiguration;2.0.0-beta.1
549550
unreleased_io.clientcore:http-netty4;1.0.0-beta.1
550551
unreleased_com.azure.resourcemanager:azure-resourcemanager-network;2.54.0
551552

sdk/tools/azure-openrewrite/pom.xml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,15 +168,15 @@
168168
</dependency>
169169

170170
<dependency>
171-
<groupId>com.fasterxml.jackson.core</groupId>
172-
<artifactId>jackson-core</artifactId>
173-
<version>2.18.4.1</version> <!-- {x-version-update;com.fasterxml.jackson.core:jackson-core;external_dependency} -->
171+
<groupId>com.fasterxml.jackson.core</groupId>
172+
<artifactId>jackson-core</artifactId>
173+
<version>2.18.4.1</version> <!-- {x-version-update;com.fasterxml.jackson.core:jackson-core;external_dependency} -->
174174
</dependency>
175175
<!-- Jackson Dataformat Smile -->
176176
<dependency>
177-
<groupId>com.fasterxml.jackson.dataformat</groupId>
178-
<artifactId>jackson-dataformat-smile</artifactId>
179-
<version>2.18.4</version> <!-- {x-version-update;com.fasterxml.jackson.dataformat:jackson-dataformat-smile;external_dependency} -->
177+
<groupId>com.fasterxml.jackson.dataformat</groupId>
178+
<artifactId>jackson-dataformat-smile</artifactId>
179+
<version>2.18.4</version> <!-- {x-version-update;com.fasterxml.jackson.dataformat:jackson-dataformat-smile;external_dependency} -->
180180
</dependency>
181181
<dependency>
182182
<groupId>com.fasterxml.jackson.core</groupId>
@@ -276,6 +276,12 @@
276276
<version>2.0.0-beta.1</version> <!-- {x-version-update;com.azure.v2:azure-core;dependency} -->
277277
<scope>test</scope>
278278
</dependency>
279+
<dependency>
280+
<groupId>com.azure.v2</groupId>
281+
<artifactId>azure-data-appconfiguration</artifactId>
282+
<version>2.0.0-beta.1</version> <!-- {x-version-update;unreleased_com.azure.v2:azure-data-appconfiguration;dependency} -->
283+
<scope>test</scope>
284+
</dependency>
279285
</dependencies>
280286
</profile>
281287

@@ -372,6 +378,12 @@
372378
<version>2.0.0-beta.1</version> <!-- {x-version-update;com.azure.v2:azure-identity;dependency} -->
373379
<scope>provided</scope>
374380
</dependency>
381+
<dependency>
382+
<groupId>com.azure.v2</groupId>
383+
<artifactId>azure-data-appconfiguration</artifactId>
384+
<version>2.0.0-beta.1</version> <!-- {x-version-update;unreleased_com.azure.v2:azure-data-appconfiguration;dependency} -->
385+
<scope>provided</scope>
386+
</dependency>
375387
</dependencies>
376388
</profile>
377389
</profiles>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
# --------------------------------------------------------------------
4+
# Migration Recipes for Azure appconfiguration Library
5+
# --------------------------------------------------------------------
6+
type: specs.openrewrite.org/v1beta/recipe
7+
name: com.azure.openrewrite.migration.data.appconfiguration
8+
displayName: Migrate from azure-appconfiguration to next generation stack
9+
description: This recipe migrates the Azure appconfiguration library to the next generation stack.
10+
recipeList:
11+
12+
- com.azure.openrewrite.recipe.azure.data.appconfiguration
13+
- com.azure.openrewrite.recipe.azure.data.appconfiguration.models
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
# --------------------------------------------------------------------
4+
# Migration Recipes for azure.core.credential
5+
# --------------------------------------------------------------------
6+
type: specs.openrewrite.org/v1beta/recipe
7+
name: com.azure.openrewrite.recipe.azure.data.appconfiguration.models
8+
displayName: Migrate from azure.data.appconfiguration.models to next generation stack
9+
description: This recipe migrates the azure.data.appconfiguration.models package to the next generation stack.
10+
recipeList:
11+
12+
# --------------------------------------------------------------------
13+
# ConfigurationAudience
14+
# --------------------------------------------------------------------
15+
16+
17+
18+
# --------------------------------------------------------------------
19+
# ConfigurationSetting
20+
# --------------------------------------------------------------------
21+
22+
- org.openrewrite.java.ChangeType:
23+
oldFullyQualifiedTypeName: com.azure.data.appconfiguration.models.ConfigurationSetting
24+
newFullyQualifiedTypeName: com.azure.v2.data.appconfiguration.models.ConfigurationSetting
25+
26+
# --------------------------------------------------------------------
27+
# SettingLabelSelector
28+
# --------------------------------------------------------------------
29+
30+
- org.openrewrite.java.ChangeType:
31+
oldFullyQualifiedTypeName: com.azure.data.appconfiguration.models.SettingLabelSelector
32+
newFullyQualifiedTypeName: com.azure.v2.data.appconfiguration.models.SettingLabelSelector
33+
34+
# --------------------------------------------------------------------
35+
# ConfigurationSettingsFilter
36+
# --------------------------------------------------------------------
37+
38+
- org.openrewrite.java.ChangeType:
39+
oldFullyQualifiedTypeName: com.azure.data.appconfiguration.models.ConfigurationSettingsFilter
40+
newFullyQualifiedTypeName: com.azure.v2.data.appconfiguration.models.ConfigurationSettingsFilter
41+
42+
# --------------------------------------------------------------------
43+
# ConfigurationSnapshot
44+
# --------------------------------------------------------------------
45+
46+
- org.openrewrite.java.ChangeType:
47+
oldFullyQualifiedTypeName: com.azure.data.appconfiguration.models.ConfigurationSnapshot
48+
newFullyQualifiedTypeName: com.azure.v2.data.appconfiguration.models.ConfigurationSnapshot
49+
50+
# --------------------------------------------------------------------
51+
# ConfigurationSnapshotStatus
52+
# --------------------------------------------------------------------
53+
54+
55+
56+
# --------------------------------------------------------------------
57+
# FeatureFlagConfigurationSetting
58+
# --------------------------------------------------------------------
59+
60+
- org.openrewrite.java.ChangeType:
61+
oldFullyQualifiedTypeName: com.azure.data.appconfiguration.models.FeatureFlagConfigurationSetting
62+
newFullyQualifiedTypeName: com.azure.v2.data.appconfiguration.models.FeatureFlagConfigurationSetting
63+
64+
# --------------------------------------------------------------------
65+
# FeatureFlagFilter
66+
# --------------------------------------------------------------------
67+
68+
- org.openrewrite.java.ChangeType:
69+
oldFullyQualifiedTypeName: com.azure.data.appconfiguration.models.FeatureFlagFilter
70+
newFullyQualifiedTypeName: com.azure.v2.data.appconfiguration.models.FeatureFlagFilter
71+
72+
# --------------------------------------------------------------------
73+
# SecretReferenceConfigurationSetting
74+
# --------------------------------------------------------------------
75+
76+
- org.openrewrite.java.ChangeType:
77+
oldFullyQualifiedTypeName: com.azure.data.appconfiguration.models.SecretReferenceConfigurationSetting
78+
newFullyQualifiedTypeName: com.azure.v2.data.appconfiguration.models.SecretReferenceConfigurationSetting
79+
80+
# --------------------------------------------------------------------
81+
# SettingFields
82+
# --------------------------------------------------------------------
83+
84+
85+
86+
# --------------------------------------------------------------------
87+
# SettingLabel
88+
# --------------------------------------------------------------------
89+
90+
91+
92+
# --------------------------------------------------------------------
93+
# SettingLabelFields
94+
# --------------------------------------------------------------------
95+
96+
97+
98+
# --------------------------------------------------------------------
99+
# SettingLabelSelector
100+
# --------------------------------------------------------------------
101+
102+
103+
104+
# --------------------------------------------------------------------
105+
# SettingSelector
106+
# --------------------------------------------------------------------
107+
108+
- org.openrewrite.java.ChangeType:
109+
oldFullyQualifiedTypeName: com.azure.data.appconfiguration.models.SettingSelector
110+
newFullyQualifiedTypeName: com.azure.v2.data.appconfiguration.models.SettingSelector
111+
112+
# --------------------------------------------------------------------
113+
# SnapshotComposition
114+
# --------------------------------------------------------------------
115+
116+
117+
118+
# --------------------------------------------------------------------
119+
# SnapshotFields
120+
# --------------------------------------------------------------------
121+
122+
123+
124+
# --------------------------------------------------------------------
125+
# SnapshotSelector
126+
# --------------------------------------------------------------------
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
type: specs.openrewrite.org/v1beta/recipe
4+
name: com.azure.openrewrite.recipe.azure.data.appconfiguration
5+
displayName: Migrate from azure.data.appconfiguration to next generation stack
6+
description: This recipe migrates the azure.data.appconfiguration package to the next generation stack.
7+
recipeList:
8+
9+
10+
11+
# --------------------------------------------------------------------
12+
# ConfigurationAsyncClient
13+
# --------------------------------------------------------------------
14+
15+
16+
17+
18+
19+
# --------------------------------------------------------------------
20+
# ConfigurationClient
21+
# --------------------------------------------------------------------
22+
23+
- org.openrewrite.java.ChangeType:
24+
oldFullyQualifiedTypeName: com.azure.data.appconfiguration.ConfigurationClient
25+
newFullyQualifiedTypeName: com.azure.v2.data.appconfiguration.ConfigurationClient
26+
27+
28+
# --------------------------------------------------------------------
29+
# ConfigurationClientBuilder
30+
# --------------------------------------------------------------------
31+
32+
- org.openrewrite.java.ChangeType:
33+
oldFullyQualifiedTypeName: com.azure.data.appconfiguration.ConfigurationClientBuilder
34+
newFullyQualifiedTypeName: com.azure.v2.data.appconfiguration.ConfigurationClientBuilder
35+
36+
37+
# --------------------------------------------------------------------
38+
# ConfigurationServiceVersion
39+
# --------------------------------------------------------------------
40+
41+

sdk/tools/azure-openrewrite/src/main/resources/META-INF/rewrite/rewrite.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ recipeList:
1212
# Code Migration Recipes
1313
- com.azure.openrewrite.migration.core
1414
- com.azure.openrewrite.migration.identity
15+
- com.azure.openrewrite.migration.data.appconfiguration
1516

1617
# Code Styling recipes
1718
- org.openrewrite.java.OrderImports:

sdk/tools/azure-openrewrite/src/test/resources/migrationExamples/azure-data-appconfiguration/AadAuthentication/v1/AadAuthentication.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
package com.azure.data.appconfiguration;
5-
4+
import com.azure.data.appconfiguration.ConfigurationClient;
5+
import com.azure.data.appconfiguration.ConfigurationClientBuilder;
66
import com.azure.data.appconfiguration.models.ConfigurationSetting;
77
import com.azure.identity.DefaultAzureCredential;
88
import com.azure.identity.DefaultAzureCredentialBuilder;

sdk/tools/azure-openrewrite/src/test/resources/migrationExamples/azure-data-appconfiguration/AadAuthentication/v2/AadAuthentication.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
package com.azure.data.appconfiguration;
5-
6-
import com.azure.data.appconfiguration.models.ConfigurationSetting;
7-
import com.azure.identity.DefaultAzureCredential;
8-
import com.azure.identity.DefaultAzureCredentialBuilder;
4+
import com.azure.v2.data.appconfiguration.ConfigurationClient;
5+
import com.azure.v2.data.appconfiguration.ConfigurationClientBuilder;
6+
import com.azure.v2.data.appconfiguration.models.ConfigurationSetting;
7+
import com.azure.v2.identity.DefaultAzureCredential;
8+
import com.azure.v2.identity.DefaultAzureCredentialBuilder;
99

1010
/**
1111
* Sample demonstrates how to use AAD token to build a configuration client.

sdk/tools/azure-openrewrite/src/test/resources/migrationExamples/azure-data-appconfiguration/ConditionalRequest/v1/ConditionalRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
package com.azure.data.appconfiguration;
5-
64
import com.azure.core.http.rest.Response;
75
import com.azure.core.util.Context;
86
import com.azure.data.appconfiguration.models.ConfigurationSetting;
7+
import com.azure.data.appconfiguration.ConfigurationClient;
8+
import com.azure.data.appconfiguration.ConfigurationClientBuilder;
99

1010
/**
1111
* Sample demonstrates how to add, get, and delete a configuration setting by conditional request.

sdk/tools/azure-openrewrite/src/test/resources/migrationExamples/azure-data-appconfiguration/ConditionalRequest/v2/ConditionalRequest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
package com.azure.data.appconfiguration;
5-
6-
import com.azure.core.http.rest.Response;
7-
import com.azure.core.util.Context;
8-
import com.azure.data.appconfiguration.models.ConfigurationSetting;
4+
import com.azure.v2.data.appconfiguration.ConfigurationClient;
5+
import com.azure.v2.data.appconfiguration.ConfigurationClientBuilder;
6+
import com.azure.v2.data.appconfiguration.models.ConfigurationSetting;
7+
import io.clientcore.core.http.models.RequestContext;
8+
import io.clientcore.core.http.models.Response;
99

1010
/**
1111
* Sample demonstrates how to add, get, and delete a configuration setting by conditional request.
@@ -31,21 +31,21 @@ public static void main(String[] args) {
3131
// given setting matches the one in the service, then the setting is updated. Otherwise, it is
3232
// not updated.
3333
// If the given setting is not exist in the service, the setting will be added to the service.
34-
Response<ConfigurationSetting> settingResponse = client.setConfigurationSettingWithResponse(setting, true, Context.NONE);
34+
Response<ConfigurationSetting> settingResponse = client.setConfigurationSettingWithResponse(setting, true, RequestContext.none());
3535
System.out.printf("Status code: %s, Key: %s, Value: %s", settingResponse.getStatusCode(),
3636
settingResponse.getValue().getKey(), settingResponse.getValue().getValue());
3737

3838
// If you want to conditionally retrieve the setting, set `ifChanged` to true. If the ETag of the
3939
// given setting matches the one in the service, then 304 status code with null value returned in the response.
4040
// Otherwise, a setting with new ETag returned, which is the latest setting retrieved from the service.
41-
settingResponse = client.getConfigurationSettingWithResponse(setting, null, true, Context.NONE);
41+
settingResponse = client.getConfigurationSettingWithResponse(setting, null, true, RequestContext.none());
4242
System.out.printf("Status code: %s, Key: %s, Value: %s", settingResponse.getStatusCode(),
4343
settingResponse.getValue().getKey(), settingResponse.getValue().getValue());
4444

4545
// If you want to conditionally delete the setting, set `ifUnchanged` to true. If the ETag of the
4646
// given setting matches the one in the service, then the setting is deleted. Otherwise, it is
4747
// not deleted.
48-
client.deleteConfigurationSettingWithResponse(settingResponse.getValue(), true, Context.NONE);
48+
client.deleteConfigurationSettingWithResponse(settingResponse.getValue(), true, RequestContext.none());
4949
System.out.printf("Status code: %s, Key: %s, Value: %s", settingResponse.getStatusCode(),
5050
settingResponse.getValue().getKey(), settingResponse.getValue().getValue());
5151
}

0 commit comments

Comments
 (0)