Skip to content

Commit 12d9f27

Browse files
authored
Distribute NuGet packages for extractor utils split (#21)
* Change library names * Create packages for all libs * Small style fixes
1 parent bf94780 commit 12d9f27

31 files changed

+283
-234
lines changed

.github/workflows/bump-version.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,16 @@ jobs:
1818
with:
1919
dotnet-version: 3.1.101
2020

21-
- name: Dotnet Pack
21+
- name: Dotnet Pack Config
22+
run: dotnet pack Cognite.Config/Cognite.Configuration.csproj --output nuget-packages --configuration Release -p:PackageVersion=${GITHUB_REF##*/v}
23+
24+
- name: Dotnet Pack Logging
25+
run: dotnet pack Cognite.Logging/Cognite.Logging.csproj --output nuget-packages --configuration Release -p:PackageVersion=${GITHUB_REF##*/v}
26+
27+
- name: Dotnet Pack Metrics
28+
run: dotnet pack Cognite.Metrics/Cognite.Metrics.csproj --output nuget-packages --configuration Release -p:PackageVersion=${GITHUB_REF##*/v}
29+
30+
- name: Dotnet Pack Utils
2231
run: dotnet pack ExtractorUtils/ExtractorUtils.csproj --output nuget-packages --configuration Release -p:PackageVersion=${GITHUB_REF##*/v}
2332

2433
- name: Dotnet Nuget Push
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
using System;
2-
using System.Collections.Generic;
1+
using System.Collections.Generic;
32

4-
namespace Cognite.Utils
3+
namespace Cognite.Extractor.Common
54
{
65
/// <summary>
76
/// Various utility functions

Cognite.Config/Cognite.Configuration.csproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,19 @@
22

33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
5+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
6+
<PackageId>Cognite.Extractor.Configuration</PackageId>
7+
<Author>Cognite AS</Author>
8+
<Company>Cognite AS</Company>
9+
<Copyright>Cognite AS</Copyright>
10+
<PackageLicenseFile>LICENSE</PackageLicenseFile>
11+
<Description>
12+
A library containing utilities for configuring Cognite extractors
13+
</Description>
514
</PropertyGroup>
15+
<ItemGroup>
16+
<None Include="..\LICENSE" Pack="true" Visible="false" PackagePath="" />
17+
</ItemGroup>
618

719
<ItemGroup>
820
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />

Cognite.Config/Configuration.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.IO;
34
using System.Text.RegularExpressions;
45
using YamlDotNet.Core;
56
using YamlDotNet.Core.Events;
67
using YamlDotNet.Serialization;
78
using YamlDotNet.Serialization.NamingConventions;
8-
using System.Collections.Generic;
99

10-
namespace Cognite.Configuration
10+
namespace Cognite.Extractor.Configuration
1111
{
1212
/// <summary>
1313
/// Configuration utility class that uses YamlDotNet to read and deserialize YML documents to extractor config objects.
1414
/// The standard format for extractor config files uses hyphenated tag names (this-is-a-tag in yml is mapped to ThisIsATag object property).
1515
/// Values containing ${ENV_VARIABLE} will be replaced by the environment variable of the same name.
1616
/// </summary>
17-
public static class Configuration
17+
public static class ConfigurationUtils
1818
{
1919
private static DeserializerBuilder builder = new DeserializerBuilder()
2020
.WithNamingConvention(HyphenatedNamingConvention.Instance)
@@ -57,7 +57,7 @@ public static T Read<T>(string path)
5757
/// not found or is not of the integer type.</exception>
5858
public static int GetVersionFromFile(string path)
5959
{
60-
Dictionary<object, object> versionedConfig = Configuration.Read<dynamic>(path);
60+
Dictionary<object, object> versionedConfig = ConfigurationUtils.Read<dynamic>(path);
6161
return GetVersion(versionedConfig);
6262
}
6363

@@ -70,7 +70,7 @@ public static int GetVersionFromFile(string path)
7070
/// not found or is not of the integer type.</exception>
7171
public static int GetVersionFromString(string yaml)
7272
{
73-
Dictionary<object, object> versionedConfig = Configuration.ReadString<dynamic>(yaml);
73+
Dictionary<object, object> versionedConfig = ConfigurationUtils.ReadString<dynamic>(yaml);
7474
return GetVersion(versionedConfig);
7575
}
7676

@@ -80,17 +80,17 @@ public static int GetVersionFromString(string yaml)
8080
/// </summary>
8181
/// <param name="yaml">String containing a yaml configuration</param>
8282
/// <param name="acceptedConfigVersions">Accepted versions</param>
83-
/// <typeparam name="T">A type that inherits from <see cref="BaseConfig"/></typeparam>
83+
/// <typeparam name="T">A type that inherits from <see cref="VersionedConfig"/></typeparam>
8484
/// <returns>A configuration object of type <typeparamref name="T"/></returns>
8585
/// <exception cref="ConfigurationException">Thrown when the version is not valid or
8686
/// in case of yaml parsing errors.</exception>
8787
public static T TryReadConfigFromString<T>(string yaml, params int[] acceptedConfigVersions) where T : VersionedConfig
8888
{
8989
try
9090
{
91-
int configVersion = Configuration.GetVersionFromString(yaml);
91+
int configVersion = ConfigurationUtils.GetVersionFromString(yaml);
9292
CheckVersion(configVersion, acceptedConfigVersions);
93-
return Configuration.ReadString<T>(yaml);
93+
return ConfigurationUtils.ReadString<T>(yaml);
9494
}
9595
catch (YamlDotNet.Core.YamlException ye)
9696
{
@@ -105,18 +105,18 @@ public static T TryReadConfigFromString<T>(string yaml, params int[] acceptedCon
105105
/// </summary>
106106
/// <param name="path">Path to the yml file</param>
107107
/// <param name="acceptedConfigVersions">Accepted versions</param>
108-
/// <typeparam name="T">A type that inherits from <see cref="BaseConfig"/></typeparam>
108+
/// <typeparam name="T">A type that inherits from <see cref="VersionedConfig"/></typeparam>
109109
/// <returns>A configuration object of type <typeparamref name="T"/></returns>
110110
/// <exception cref="ConfigurationException">Thrown when the version is not valid,
111111
/// the yaml file is not found or in case of yaml parsing error.</exception>
112-
public static T TryReadConfigFromFile<T>(string path, params int[] acceptedConfigVersions)
112+
public static T TryReadConfigFromFile<T>(string path, params int[] acceptedConfigVersions) where T : VersionedConfig
113113
{
114114
try
115115
{
116-
int configVersion = Configuration.GetVersionFromFile(path);
116+
int configVersion = ConfigurationUtils.GetVersionFromFile(path);
117117
CheckVersion(configVersion, acceptedConfigVersions);
118118

119-
return Configuration.Read<T>(path);
119+
return ConfigurationUtils.Read<T>(path);
120120
}
121121
catch (System.IO.FileNotFoundException fnfe)
122122
{

Cognite.Config/ConfigurationException.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System;
22

3-
namespace Cognite.Configuration
3+
namespace Cognite.Extractor.Configuration
44
{
55
/// <summary>
66
/// Exception produced by the configuration utils
@@ -26,10 +26,5 @@ public ConfigurationException(string message) : base(message)
2626
public ConfigurationException(string message, Exception innerException) : base(message, innerException)
2727
{
2828
}
29-
30-
public ConfigurationException()
31-
{
32-
}
3329
}
34-
3530
}

Cognite.Config/VersionedConfig.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
namespace Cognite.Configuration {
1+
namespace Cognite.Extractor.Configuration
2+
{
23

34
/// <summary>
45
/// Base configuration object for supporting versioned configuration.
56
/// The config should have a version property, so that versioning and compatibility can be tracked.
67
/// </summary>
7-
public class VersionedConfig {
8+
public class VersionedConfig
9+
{
810

911
/// <summary>
1012
/// Current version of this config object

Cognite.Logging/Cognite.Logging.csproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,19 @@
22

33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
5+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
6+
<PackageId>Cognite.Extractor.Logging</PackageId>
7+
<Author>Cognite AS</Author>
8+
<Company>Cognite AS</Company>
9+
<Copyright>Cognite AS</Copyright>
10+
<PackageLicenseFile>LICENSE</PackageLicenseFile>
11+
<Description>
12+
A library containing logging utilities for Cognite extractors
13+
</Description>
514
</PropertyGroup>
15+
<ItemGroup>
16+
<None Include="..\LICENSE" Pack="true" Visible="false" PackagePath="" />
17+
</ItemGroup>
618

719
<ItemGroup>
820
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.3" />

Cognite.Logging/Logger.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.IO;
42
using Microsoft.Extensions.DependencyInjection;
53
using Microsoft.Extensions.Logging;
64
using Serilog;
75
using Serilog.Core;
86
using Serilog.Events;
97
using Serilog.Extensions.Logging;
108

11-
namespace Cognite.Logging {
9+
namespace Cognite.Extractor.Logging
10+
{
1211

1312
/// <summary>
1413
/// Utility class for configuring extractor loggers.
1514
/// The logging framework used is <see href="https://serilog.net/">Serilog</see>.
1615
/// Loggers are created according to a <see cref="LoggerConfig"/> configuration object.
1716
/// Log messages contain UTC timestamps.
1817
/// </summary>
19-
public static class Logging {
18+
public static class LoggingUtils
19+
{
2020

2121
private const string _logTemplate = "[{UtcTimestamp:yyyy-MM-dd HH:mm:ss.fff} {Level:u3}] {Message:lj}{NewLine}{Exception}";
2222
private const string _logTemplateWithContext = "[{UtcTimestamp:yyyy-MM-dd HH:mm:ss.fff} {Level:u3}] [{SourceContext}] {Message:lj}{NewLine}{Exception}";
@@ -120,11 +120,11 @@ public static void AddLogger(this IServiceCollection services) {
120120
var config = p.GetService<LoggerConfig>();
121121
if (config == null) {
122122
// No logging configuration
123-
var defLog = Logging.GetSerilogDefault();
123+
var defLog = LoggingUtils.GetSerilogDefault();
124124
defLog.Warning("No Logging configuration found. Using default logger");
125125
return defLog;
126126
}
127-
return Logging.GetConfiguredLogger(config);
127+
return LoggingUtils.GetConfiguredLogger(config);
128128
});
129129
services.AddLogging(loggingBuilder => {
130130
loggingBuilder.Services.AddSingleton<ILoggerProvider, SerilogLoggerProvider>(s =>

Cognite.Logging/LoggerConfig.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

2-
namespace Cognite.Logging {
2+
namespace Cognite.Extractor.Logging
3+
{
34

45
/// <summary>
56
/// Logging configuration object
@@ -9,7 +10,7 @@ public class LoggerConfig
910
/// <summary>
1011
/// Logging to console (optional)
1112
/// </summary>
12-
/// <value>A <see cref="ConsoleConfig"/> config object</value>
13+
/// <value>A <see cref="LogConfig"/> config object</value>
1314
public LogConfig Console { get; set; }
1415

1516
/// <summary>

0 commit comments

Comments
 (0)