Skip to content

Commit b75c34f

Browse files
committed
test for gh action
1 parent 03539ae commit b75c34f

File tree

5 files changed

+79
-30
lines changed

5 files changed

+79
-30
lines changed

.github/workflows/cd-pipeline.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ jobs:
4848
dotnet Dataverse.ConfigurationMigrationTool.Console.dll import --schema "../data/data_schema.xml" --data "../data/data.xml"
4949
env:
5050
DOTNET_ENVIRONMENT: Production
51+
environment: Production
5152

5253

5354

src/Dataverse.ConfigurationMigrationTool/Dataverse.ConfigurationMigrationTool.Console/Features/Import/Commands/ImportCommands.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ public async Task Import([Option("schema")] string schemafilepath, [Option("data
2929
{
3030

3131
var ImportQueue = new Queue<ImportDataTask>();
32-
ConsoleApp.WriteLine("Importing data from file {datafilepath} with schema {schemafilepath}", datafilepath, schemafilepath);
32+
ConsoleApp.WriteLine($"{datafilepath} with schema {schemafilepath}");
3333
var schema = await _importDataProvider.ReadSchemaFromFile(schemafilepath);
3434
var importdata = await _importDataProvider.ReadFromFile(datafilepath);
35-
ConsoleApp.WriteLine("Schema Count: {schema} | Data count {data}", schema.Entity.Count, importdata.Entity.Count);
35+
ConsoleApp.WriteLine($"Schema Count: {schema.Entity.Count} | Data count {importdata.Entity.Count}");
3636

3737

3838
var schemaValidationResult = await _schemaValidator.Validate(schema);
Lines changed: 72 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using Cocona;
2-
using Dataverse.ConfigurationMigrationTool.Console.Features.Import;
1+
using Dataverse.ConfigurationMigrationTool.Console.Features.Import;
32
using Dataverse.ConfigurationMigrationTool.Console.Features.Shared;
43
using Dataverse.ConfigurationMigrationTool.Console.Services.Dataverse;
54
using Dataverse.ConfigurationMigrationTool.Console.Services.Dataverse.Configuration;
@@ -11,38 +10,85 @@
1110
using Microsoft.Extensions.Logging;
1211
using Microsoft.PowerPlatform.Dataverse.Client;
1312
using System.Reflection;
14-
15-
var builder = CoconaApp.CreateBuilder();
16-
builder.Configuration
13+
var builder = new HostBuilder();
14+
builder.ConfigureHostConfiguration((config) =>
15+
{
16+
// Configure the host configuration, such as environment variables, command line arguments, etc.
17+
config.AddEnvironmentVariables();
18+
});
19+
builder.ConfigureAppConfiguration((context, config) =>
20+
{
21+
config
1722
.AddEnvironmentVariables()
1823
.AddJsonFile("appsettings.json", false, false)
19-
.AddJsonFile($"appsettings.{builder.Environment.EnvironmentName}.json", false, false);
20-
Console.WriteLine($"Using configuration file: appsettings.{builder.Environment.EnvironmentName}.json");
21-
foreach (var arg in args)
24+
.AddJsonFile($"appsettings.{context.HostingEnvironment.EnvironmentName}.json", false, false);
25+
if (!context.HostingEnvironment.IsProduction())
26+
{
27+
//Secrets should never be in clear text in source controlled file such appsettings.json.
28+
//For Developement, we therefore store them locally into UserSecrets Store, part of dotnet foundation.
29+
//For Production, secrets can be either written into appsettings.Production.json file by pipeline
30+
//or you can configure another Configuration Provider to provide the secrets like AzureKeyvault or Hashicorp Vault.
31+
config.AddUserSecrets(Assembly.GetExecutingAssembly());
32+
}
33+
Console.WriteLine($"Using configuration file: appsettings.{context.HostingEnvironment.EnvironmentName}.json");
34+
foreach (var arg in context.Configuration.AsEnumerable())
35+
{
36+
Console.WriteLine($"Configuration: {arg.Key} => {arg.Value}");
37+
}
38+
});
39+
builder.ConfigureServices((context, services) =>
2240
{
23-
Console.WriteLine($"Argument: {arg}");
24-
}
25-
if (!builder.Environment.IsProduction())
26-
{
27-
//Secrets should never be in clear text in source controlled file such appsettings.json.
28-
//For Developement, we therefore store them locally into UserSecrets Store, part of dotnet foundation.
29-
//For Production, secrets can be either written into appsettings.Production.json file by pipeline
30-
//or you can configure another Configuration Provider to provide the secrets like AzureKeyvault or Hashicorp Vault.
31-
builder.Configuration.AddUserSecrets(Assembly.GetExecutingAssembly());
32-
}
33-
builder.Services
41+
42+
services
3443
.AddLogging(lb => lb.AddConsole())
35-
.Configure<SdkDataverseServiceFactoryOptions>(builder.Configuration.GetSection("Dataverse"))
36-
.Configure<ParallelismBulkOrganizationServiceOptions>(builder.Configuration.GetSection("Dataverse"))
44+
.Configure<SdkDataverseServiceFactoryOptions>(context.Configuration.GetSection("Dataverse"))
45+
.Configure<ParallelismBulkOrganizationServiceOptions>(context.Configuration.GetSection("Dataverse"))
3746
.AddTransient<IImportDataProvider, FileReaderDataImportProvider>()
3847
.AddSingleton<IFileDataReader, XmlFileDataReader>()
3948
.AddTransient<IMetadataService, DataverseMetadataService>()
4049
.AddTransient<ServiceClient>((sp) => (ServiceClient)sp.GetRequiredService<IDataverseClientFactory>().Create())
4150
.AddSingleton<IBulkOrganizationService, ParallelismBulkOrganizationService>()
4251
.AddDataverseClient()
4352
.AddImportFeature();
44-
Console.WriteLine($"Services are completed");
45-
var app = builder.Build();
46-
app.UseImportFeature();
47-
Console.WriteLine($"Running App");
48-
await app.RunAsync();
53+
// Configure other services.
54+
});
55+
builder.ConfigureCocona(args, configureApplication: app =>
56+
{
57+
// Configure your app's commands normally as you would with app
58+
app.UseImportFeature();
59+
});
60+
await builder.RunConsoleAsync(x => x.SuppressStatusMessages = true);
61+
//var builder = CoconaApp.CreateBuilder();
62+
//builder.Configuration
63+
// .AddEnvironmentVariables()
64+
// .AddJsonFile("appsettings.json", false, false)
65+
// .AddJsonFile($"appsettings.{builder.Environment.EnvironmentName}.json", false, false);
66+
//Console.WriteLine($"Using configuration file: appsettings.{builder.Environment.EnvironmentName}.json");
67+
//foreach (var arg in args)
68+
//{
69+
// Console.WriteLine($"Argument: {arg}");
70+
//}
71+
//if (!builder.Environment.IsProduction())
72+
//{
73+
// //Secrets should never be in clear text in source controlled file such appsettings.json.
74+
// //For Developement, we therefore store them locally into UserSecrets Store, part of dotnet foundation.
75+
// //For Production, secrets can be either written into appsettings.Production.json file by pipeline
76+
// //or you can configure another Configuration Provider to provide the secrets like AzureKeyvault or Hashicorp Vault.
77+
// builder.Configuration.AddUserSecrets(Assembly.GetExecutingAssembly());
78+
//}
79+
//builder.Services
80+
// .AddLogging(lb => lb.AddConsole())
81+
// .Configure<SdkDataverseServiceFactoryOptions>(builder.Configuration.GetSection("Dataverse"))
82+
// .Configure<ParallelismBulkOrganizationServiceOptions>(builder.Configuration.GetSection("Dataverse"))
83+
// .AddTransient<IImportDataProvider, FileReaderDataImportProvider>()
84+
// .AddSingleton<IFileDataReader, XmlFileDataReader>()
85+
// .AddTransient<IMetadataService, DataverseMetadataService>()
86+
// .AddTransient<ServiceClient>((sp) => (ServiceClient)sp.GetRequiredService<IDataverseClientFactory>().Create())
87+
// .AddSingleton<IBulkOrganizationService, ParallelismBulkOrganizationService>()
88+
// .AddDataverseClient()
89+
// .AddImportFeature();
90+
//Console.WriteLine($"Services are completed");
91+
//var app = builder.Build();
92+
//app.UseImportFeature();
93+
//Console.WriteLine($"Running App");
94+
//await app.RunAsync();

src/Dataverse.ConfigurationMigrationTool/Dataverse.ConfigurationMigrationTool.Console/Properties/launchSettings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
"commandName": "Project",
55
"commandLineArgs": "import --schema ../../../TestAssets/data_schema.xml --data ../../../TestAssets/data.xml",
66
"environmentVariables": {
7-
"DOTNET_ENVIRONMENT": "Development"
7+
"DOTNET_ENVIRONMENT": "Development",
8+
"environment": "Development"
9+
810
}
911
}
1012
}

src/Dataverse.ConfigurationMigrationTool/Dataverse.ConfigurationMigrationTool.Console/Services/Dataverse/SdkDataverseServiceFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public SdkDataverseServiceFactory(IOptions<SdkDataverseServiceFactoryOptions> op
1818
}
1919
public IOrganizationServiceAsync2 Create()
2020
{
21-
throw new InvalidOperationException($"test: {_options.Url} {_options.ClientId} {_options.ClientSecret}");
21+
// throw new InvalidOperationException($"test: {_options.Url} {_options.ClientId} {_options.ClientSecret}");
2222
var serviceClient = new ServiceClient(
2323
new Uri(_options.Url),
2424
_options.ClientId.ToString(),

0 commit comments

Comments
 (0)