Skip to content

Commit 532dca1

Browse files
authored
Merge pull request #61 from AzureCosmosDB/develop
Changes to resolve issues and update Cosmos SDK
2 parents 486c5b7 + 510c8a5 commit 532dca1

20 files changed

+575
-124
lines changed

.github/actions/build-with-plugins/action.yml

+11-8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ inputs:
1010
runtime:
1111
description: Target platform runtime (win-x64)
1212
required: true
13+
build-version:
14+
description: Build or release version (0.0.1)
15+
required: true
1316
runs:
1417
using: composite
1518
steps:
@@ -27,7 +30,7 @@ runs:
2730
-p:EnableCompressionInSingleFile=true \
2831
-p:PublishReadyToRun=false \
2932
-p:PublishTrimmed=false \
30-
-p:Version=0.0.${{ github.run_number }}
33+
-p:Version=${{ inputs.build-version }}
3134
- name: Build Cosmos Extension
3235
shell: bash
3336
run: |
@@ -42,7 +45,7 @@ runs:
4245
-p:EnableCompressionInSingleFile=true \
4346
-p:PublishReadyToRun=false \
4447
-p:PublishTrimmed=false \
45-
-p:Version=0.0.${{ github.run_number }}
48+
-p:Version=${{ inputs.build-version }}
4649
- name: Build JSON Extension
4750
shell: bash
4851
run: |
@@ -57,7 +60,7 @@ runs:
5760
-p:EnableCompressionInSingleFile=true \
5861
-p:PublishReadyToRun=false \
5962
-p:PublishTrimmed=false \
60-
-p:Version=0.0.${{ github.run_number }}
63+
-p:Version=${{ inputs.build-version }}
6164
- name: Build Azure Table Extension
6265
shell: bash
6366
run: |
@@ -72,7 +75,7 @@ runs:
7275
-p:EnableCompressionInSingleFile=true \
7376
-p:PublishReadyToRun=false \
7477
-p:PublishTrimmed=false \
75-
-p:Version=0.0.${{ github.run_number }}
78+
-p:Version=${{ inputs.build-version }}
7679
- name: Build Mongo Extension
7780
shell: bash
7881
run: |
@@ -87,7 +90,7 @@ runs:
8790
-p:EnableCompressionInSingleFile=true \
8891
-p:PublishReadyToRun=false \
8992
-p:PublishTrimmed=false \
90-
-p:Version=0.0.${{ github.run_number }}
93+
-p:Version=${{ inputs.build-version }}
9194
- name: Build SQL Server Extension
9295
shell: bash
9396
run: |
@@ -102,7 +105,7 @@ runs:
102105
-p:EnableCompressionInSingleFile=true \
103106
-p:PublishReadyToRun=false \
104107
-p:PublishTrimmed=false \
105-
-p:Version=0.0.${{ github.run_number }}
108+
-p:Version=${{ inputs.build-version }}
106109
- name: Build Parquet Extension
107110
shell: bash
108111
run: |
@@ -117,7 +120,7 @@ runs:
117120
-p:EnableCompressionInSingleFile=true \
118121
-p:PublishReadyToRun=false \
119122
-p:PublishTrimmed=false \
120-
-p:Version=0.0.${{ github.run_number }}
123+
-p:Version=${{ inputs.build-version }}
121124
- name: Build Cognitive Search Extension
122125
shell: bash
123126
run: |
@@ -132,7 +135,7 @@ runs:
132135
-p:EnableCompressionInSingleFile=true \
133136
-p:PublishReadyToRun=false \
134137
-p:PublishTrimmed=false \
135-
-p:Version=0.0.${{ github.run_number }}
138+
-p:Version=${{ inputs.build-version }}
136139
- name: Upload package
137140
uses: actions/upload-artifact@v3
138141
with:

.github/workflows/internal-test-build.yml

+3
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,20 @@ jobs:
2222
platform: windows
2323
platform-short: win
2424
runtime: win-x64
25+
build-version: 0.0.${{ github.run_number }}
2526
- name: Execute Action build-with-plugins for MacOS
2627
uses: ./.github/actions/build-with-plugins
2728
id: build-with-plugins-mac
2829
with:
2930
platform: mac
3031
platform-short: mac
3132
runtime: osx-x64
33+
build-version: 0.0.${{ github.run_number }}
3234
- name: Execute Action build-with-plugins for Linux
3335
uses: ./.github/actions/build-with-plugins
3436
id: build-with-plugins-linux
3537
with:
3638
platform: linux
3739
platform-short: linux
3840
runtime: linux-x64
41+
build-version: 0.0.${{ github.run_number }}

.github/workflows/release.yml

+9-6
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ jobs:
2626
path: linux-package
2727
- name: Package output files
2828
run: |
29-
zip -r dmt-${{ github.ref_name }}-win-x64.zip windows-package/*
30-
zip -r dmt-${{ github.ref_name }}-mac-x64.zip mac-package/*
31-
zip -r dmt-${{ github.ref_name }}-linux-x64.zip linux-package/*
29+
zip -r dmt-${{ github.event.release.tag_name }}-win-x64.zip windows-package/*
30+
zip -r dmt-${{ github.event.release.tag_name }}-mac-x64.zip mac-package/*
31+
zip -r dmt-${{ github.event.release.tag_name }}-linux-x64.zip linux-package/*
3232
- name: Create GitHub release
3333
uses: softprops/action-gh-release@v1
3434
with:
3535
files: |
36-
dmt-${{ github.ref_name }}-win-x64.zip
37-
dmt-${{ github.ref_name }}-mac-x64.zip
38-
dmt-${{ github.ref_name }}-linux-x64.zip
36+
dmt-${{ github.event.release.tag_name }}-win-x64.zip
37+
dmt-${{ github.event.release.tag_name }}-mac-x64.zip
38+
dmt-${{ github.event.release.tag_name }}-linux-x64.zip
3939
build-package:
4040
name: Build self-contained executables
4141
runs-on: ubuntu-latest
@@ -52,17 +52,20 @@ jobs:
5252
platform: windows
5353
platform-short: win
5454
runtime: win-x64
55+
build-version: ${{ github.event.release.tag_name }}
5556
- name: Execute Action build-with-plugins for MacOS
5657
uses: ./.github/actions/build-with-plugins
5758
id: build-with-plugins-mac
5859
with:
5960
platform: mac
6061
platform-short: mac
6162
runtime: osx-x64
63+
build-version: ${{ github.event.release.tag_name }}
6264
- name: Execute Action build-with-plugins for Linux
6365
uses: ./.github/actions/build-with-plugins
6466
id: build-with-plugins-linux
6567
with:
6668
platform: linux
6769
platform-short: linux
6870
runtime: linux-x64
71+
build-version: ${{ github.event.release.tag_name }}

Core/Cosmos.DataTransfer.Core/DataTransferOptions.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
public class DataTransferOptions
44
{
55
public string? Source { get; set; }
6-
public string? Sink { get; set; }
6+
private string? _sink;
7+
public string? Sink { get => _sink; set => _sink = value; }
8+
public string? Target { get => _sink; set => _sink = value; }
9+
public string? Destination { get => _sink; set => _sink = value; }
710
public string? SettingsPath { get; set; }
811
}

Core/Cosmos.DataTransfer.Core/ExtensionManifestBuilder.cs

+37-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public class ExtensionManifestBuilder : IExtensionManifestBuilder
1111
{
1212
private readonly ILogger _logger;
1313
private readonly IExtensionLoader _extensionLoader;
14+
private static string? _appVersion;
1415

1516
public ExtensionManifestBuilder(IExtensionLoader extensionLoader, ILogger<ExtensionManifestBuilder> logger)
1617
{
@@ -45,10 +46,19 @@ public ExtensionManifest BuildManifest(ExtensionDirection direction)
4546
{
4647
extensions.AddRange(GetSinks());
4748
}
48-
var manifest = new ExtensionManifest(extensions
49-
.Select(e => new ExtensionManifestItem(e.DisplayName,
50-
direction,
51-
GetExtensionSettings(e as IExtensionWithSettings))).ToList());
49+
var manifest = new ExtensionManifest(AppVersion, extensions
50+
.Select(e =>
51+
{
52+
var assembly = Assembly.GetAssembly(e.GetType());
53+
var version = assembly != null ? GetAssemblyVersion(assembly) : null;
54+
var assemblyName = assembly?.GetName().Name;
55+
56+
return new ExtensionManifestItem(e.DisplayName,
57+
direction,
58+
version,
59+
assemblyName,
60+
GetExtensionSettings(e as IExtensionWithSettings));
61+
}).ToList());
5262
return manifest;
5363
}
5464

@@ -132,5 +142,28 @@ private static PropertyType GetPropertyType(Type type)
132142

133143
return PropertyType.String;
134144
}
145+
146+
private static string AppVersion => _appVersion ??= GetAppVersion();
147+
148+
private static string GetAppVersion()
149+
{
150+
var assembly = Assembly.GetEntryAssembly() ?? Assembly.GetExecutingAssembly();
151+
152+
return GetAssemblyVersion(assembly);
153+
}
154+
155+
private static string GetAssemblyVersion(Assembly assembly)
156+
{
157+
var assemblyVersionAttribute = assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
158+
159+
if (assemblyVersionAttribute is null)
160+
{
161+
return assembly.GetName().Version?.ToString() ?? "";
162+
}
163+
else
164+
{
165+
return assemblyVersionAttribute.InformationalVersion;
166+
}
167+
}
135168
}
136169
}

Core/Cosmos.DataTransfer.Core/Properties/launchSettings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
},
3535
"SettingsCommand": {
3636
"commandName": "Project",
37-
"commandLineArgs": "settings --sink -e cosmos-nosql"
37+
"commandLineArgs": "settings --sink"
3838
}
3939
}
4040
}

Core/Cosmos.DataTransfer.Core/RunCommand.cs

+33-9
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,16 @@ public static void AddRunOptions(Command command)
2727
{
2828
var sourceOption = new Option<string?>(
2929
aliases: new[] { "--source", "-from" },
30-
description: "The extension to read data.");
30+
description: "The extension to read data.")
31+
{
32+
ArgumentHelpName = "source"
33+
};
3134
var sinkOption = new Option<string?>(
32-
aliases: new[] { "--sink", "-to" },
33-
description: "The extension to write data.");
35+
aliases: new[] { "--sink", "-to", "--target", "--destination" },
36+
description: "The extension to write data.")
37+
{
38+
ArgumentHelpName = "sink"
39+
};
3440
var settingsOption = new Option<FileInfo?>(
3541
aliases: new[] { "--settings" },
3642
description: "The settings file. (default: migrationsettings.json)");
@@ -90,7 +96,7 @@ public async Task<int> InvokeAsync(InvocationContext context)
9096
cancellationToken.ThrowIfCancellationRequested();
9197

9298
var sourceConfig = combinedConfig.GetSection("SourceSettings");
93-
var sinkConfig = combinedConfig.GetSection("SinkSettings");
99+
var sinkConfig = GetSinkConfig(combinedConfig);
94100
var operationConfigs = combinedConfig.GetSection("Operations");
95101
var operations = operationConfigs?.GetChildren().ToList();
96102
if (operations?.Any() == true)
@@ -103,16 +109,16 @@ public async Task<int> InvokeAsync(InvocationContext context)
103109
{
104110
sourceBuilder.AddConfiguration(operationSource);
105111
}
106-
var operationSink = operationConfig.GetSection("SinkSettings");
112+
var operationSink = GetSinkConfig(operationConfig);
107113
var sinkBuilder = new ConfigurationBuilder().AddConfiguration(sinkConfig);
108114
if (operationSink.Exists())
109115
{
110116
sinkBuilder.AddConfiguration(operationSink);
111117
}
112-
await ExecuteDataTransferOperation(source,
113-
sourceBuilder.Build(),
114-
sink,
115-
sinkBuilder.Build(),
118+
await ExecuteDataTransferOperation(source,
119+
sourceBuilder.Build(),
120+
sink,
121+
sinkBuilder.Build(),
116122
cancellationToken);
117123
}
118124
}
@@ -124,6 +130,24 @@ await ExecuteDataTransferOperation(source,
124130
return 0;
125131
}
126132

133+
private static IConfigurationSection GetSinkConfig(IConfiguration combinedConfig)
134+
{
135+
var config = combinedConfig.GetSection("SinkSettings");
136+
if (config != null && config.Exists())
137+
{
138+
return config;
139+
}
140+
141+
config = combinedConfig.GetSection("TargetSettings");
142+
if (config != null && config.Exists())
143+
{
144+
return config;
145+
}
146+
147+
config = combinedConfig.GetSection("DestinationSettings");
148+
return config;
149+
}
150+
127151
private async Task ExecuteDataTransferOperation(IDataSourceExtension source, IConfiguration sourceConfig, IDataSinkExtension sink, IConfiguration sinkConfig, CancellationToken cancellationToken)
128152
{
129153
_logger.LogDebug("Loaded {SettingCount} settings for source {SourceName}:\n\t\t{SettingList}",

0 commit comments

Comments
 (0)