Skip to content

Commit ba3b66a

Browse files
committed
Release 2.0.0
1 parent 667d848 commit ba3b66a

5 files changed

Lines changed: 212 additions & 237 deletions

File tree

Extensions.Configuration.GitLab/Extensions.Configuration.GitLab.csproj

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net5.0</TargetFramework>
5-
<LangVersion>9</LangVersion>
4+
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
65
<Authors>Denis Ivanov</Authors>
7-
<FileVersion>1.0.0</FileVersion>
8-
<AssemblyVersion>1.0.0</AssemblyVersion>
6+
<FileVersion>2.0.0</FileVersion>
7+
<AssemblyVersion>2.0.0</AssemblyVersion>
98
<Description>Provides GitLab variables configuration provider</Description>
109
<PackageTags>GitLab;configuration; ASP.NET Core</PackageTags>
1110
<RepositoryUrl>https://github.com/denis-ivanov/Microsoft.Extensions.Configuration.GitLab</RepositoryUrl>
@@ -16,8 +15,21 @@
1615

1716
<ItemGroup>
1817
<PackageReference Include="GitLabApiClient" Version="1.8.0" />
19-
<PackageReference Include="Microsoft.Extensions.Configuration" Version="5.0.0" />
20-
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="5.0.0" />
18+
</ItemGroup>
19+
20+
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
21+
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.*" />
22+
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.*" />
23+
</ItemGroup>
24+
25+
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
26+
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.*" />
27+
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="9.0.*" />
28+
</ItemGroup>
29+
30+
<ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
31+
<PackageReference Include="Microsoft.Extensions.Configuration" Version="10.0.*" />
32+
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="10.0.*" />
2133
</ItemGroup>
2234

2335
<ItemGroup>

Extensions.Configuration.GitLab/GitLabConfigurationExtensions.cs

Lines changed: 37 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -3,82 +3,48 @@
33
using System;
44
using System.Diagnostics.CodeAnalysis;
55

6-
namespace Extensions.Configuration.GitLab
6+
namespace Extensions.Configuration.GitLab;
7+
8+
public static class GitLabConfigurationExtensions
79
{
8-
public static class GitLabConfigurationExtensions
10+
public static IConfigurationBuilder AddGitLab(
11+
[NotNull] this IConfigurationBuilder builder,
12+
[NotNull] string hostUrl,
13+
[NotNull] string projectId,
14+
[NotNull] string authenticationToken,
15+
[NotNull] string environmentName)
916
{
10-
public static IConfigurationBuilder AddGitLab(
11-
[NotNull] this IConfigurationBuilder builder,
12-
[NotNull] string hostUrl,
13-
[NotNull] string projectId,
14-
[NotNull] string authenticationToken,
15-
[NotNull] string environmentName)
16-
{
17-
if (builder == null)
18-
{
19-
throw new ArgumentNullException(nameof(builder));
20-
}
21-
22-
if (hostUrl == null)
23-
{
24-
throw new ArgumentNullException(nameof(hostUrl));
25-
}
26-
27-
if (projectId == null)
28-
{
29-
throw new ArgumentNullException(nameof(projectId));
30-
}
31-
32-
if (authenticationToken == null)
33-
{
34-
throw new ArgumentNullException(nameof(authenticationToken));
35-
}
36-
37-
if (environmentName == null)
38-
{
39-
throw new ArgumentNullException(nameof(environmentName));
40-
}
41-
42-
var options = new GitLabConfigurationOptions(hostUrl, projectId, authenticationToken, environmentName);
43-
return builder.AddGitLab(options);
44-
}
45-
46-
public static IConfigurationBuilder AddGitLab(
47-
[NotNull] this IConfigurationBuilder builder,
48-
[NotNull] Action<GitLabConfigurationOptions> configure)
49-
{
50-
if (builder == null)
51-
{
52-
throw new ArgumentNullException(nameof(builder));
53-
}
54-
55-
if (configure == null)
56-
{
57-
throw new ArgumentNullException(nameof(configure));
58-
}
17+
ArgumentNullException.ThrowIfNull(builder);
18+
ArgumentNullException.ThrowIfNull(hostUrl);
19+
ArgumentNullException.ThrowIfNull(projectId);
20+
ArgumentNullException.ThrowIfNull(authenticationToken);
21+
ArgumentNullException.ThrowIfNull(environmentName);
22+
23+
var options = new GitLabConfigurationOptions(hostUrl, projectId, authenticationToken, environmentName);
24+
return builder.AddGitLab(options);
25+
}
5926

60-
var options = new GitLabConfigurationOptions();
61-
configure(options);
62-
return builder.AddGitLab(options);
63-
}
27+
public static IConfigurationBuilder AddGitLab(
28+
[NotNull] this IConfigurationBuilder builder,
29+
[NotNull] Action<GitLabConfigurationOptions> configure)
30+
{
31+
ArgumentNullException.ThrowIfNull(builder);
32+
ArgumentNullException.ThrowIfNull(configure);
6433

65-
public static IConfigurationBuilder AddGitLab(
66-
[NotNull] this IConfigurationBuilder builder,
67-
[NotNull] GitLabConfigurationOptions options)
68-
{
69-
if (builder == null)
70-
{
71-
throw new ArgumentNullException(nameof(builder));
72-
}
34+
var options = new GitLabConfigurationOptions();
35+
configure(options);
36+
return builder.AddGitLab(options);
37+
}
7338

74-
if (options == null)
75-
{
76-
throw new ArgumentNullException(nameof(options));
77-
}
39+
public static IConfigurationBuilder AddGitLab(
40+
[NotNull] this IConfigurationBuilder builder,
41+
[NotNull] GitLabConfigurationOptions options)
42+
{
43+
ArgumentNullException.ThrowIfNull(builder);
44+
ArgumentNullException.ThrowIfNull(options);
7845

79-
var gitlabClient = new GitLabClient(options.HostUrl, options.AuthenticationToken);
80-
var source = new GitLabConfigurationSource(gitlabClient, options);
81-
return builder.Add(source);
82-
}
46+
var gitlabClient = new GitLabClient(options.HostUrl, options.AuthenticationToken);
47+
var source = new GitLabConfigurationSource(gitlabClient, options);
48+
return builder.Add(source);
8349
}
8450
}

Extensions.Configuration.GitLab/GitLabConfigurationOptions.cs

Lines changed: 63 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -2,88 +2,87 @@
22
using System;
33
using System.Diagnostics.CodeAnalysis;
44

5-
namespace Extensions.Configuration.GitLab
5+
namespace Extensions.Configuration.GitLab;
6+
7+
public class GitLabConfigurationOptions
68
{
7-
public class GitLabConfigurationOptions
9+
public GitLabConfigurationOptions()
810
{
9-
public GitLabConfigurationOptions()
10-
{
11-
}
11+
}
1212

13-
public GitLabConfigurationOptions(
14-
[NotNull] string hostUrl,
15-
[NotNull] string projectId,
16-
[NotNull] string authenticationToken,
17-
[NotNull] string environmentName)
18-
{
19-
HostUrl = hostUrl ?? throw new ArgumentNullException(nameof(hostUrl));
20-
ProjectId = projectId ?? throw new ArgumentNullException(nameof(projectId));
21-
AuthenticationToken = authenticationToken ?? throw new ArgumentNullException(nameof(authenticationToken));
22-
EnvironmentName = environmentName ?? throw new ArgumentNullException(nameof(environmentName));
23-
}
13+
public GitLabConfigurationOptions(
14+
[NotNull] string hostUrl,
15+
[NotNull] string projectId,
16+
[NotNull] string authenticationToken,
17+
[NotNull] string environmentName)
18+
{
19+
HostUrl = hostUrl ?? throw new ArgumentNullException(nameof(hostUrl));
20+
ProjectId = projectId ?? throw new ArgumentNullException(nameof(projectId));
21+
AuthenticationToken = authenticationToken ?? throw new ArgumentNullException(nameof(authenticationToken));
22+
EnvironmentName = environmentName ?? throw new ArgumentNullException(nameof(environmentName));
23+
}
2424

25-
public TimeSpan ReloadInterval { get; set; } = TimeSpan.FromSeconds(3);
25+
public TimeSpan ReloadInterval { get; set; } = TimeSpan.FromSeconds(3);
2626

27-
public string HostUrl { get; set; }
27+
public string HostUrl { get; set; }
2828

29-
public string AuthenticationToken { get; set; }
29+
public string AuthenticationToken { get; set; }
3030

31-
public string ProjectId { get; set; }
31+
public string ProjectId { get; set; }
3232

33-
public string EnvironmentName { get; set; } = "*";
33+
public string EnvironmentName { get; set; } = "*";
3434

35-
public Func<string, string> KeyNormalizer { get; set; } = NormalizeKey;
35+
public Func<string, string> KeyNormalizer { get; set; } = NormalizeKey;
3636

37-
public GitLabConfigurationOptions WithReloadInterval(TimeSpan reloadInterval)
38-
{
39-
ReloadInterval = reloadInterval;
40-
return this;
41-
}
37+
public GitLabConfigurationOptions WithReloadInterval(TimeSpan reloadInterval)
38+
{
39+
ReloadInterval = reloadInterval;
40+
return this;
41+
}
4242

43-
public GitLabConfigurationOptions WithHostUrl([NotNull] string hostUrl)
44-
{
45-
HostUrl = hostUrl ?? throw new ArgumentNullException(nameof(hostUrl));
46-
return this;
47-
}
43+
public GitLabConfigurationOptions WithHostUrl([NotNull] string hostUrl)
44+
{
45+
HostUrl = hostUrl ?? throw new ArgumentNullException(nameof(hostUrl));
46+
return this;
47+
}
4848

49-
public GitLabConfigurationOptions WithAuthenticationToken([NotNull] string authenticationToken)
50-
{
51-
AuthenticationToken = authenticationToken ?? throw new ArgumentNullException(nameof(authenticationToken));
52-
return this;
53-
}
49+
public GitLabConfigurationOptions WithAuthenticationToken([NotNull] string authenticationToken)
50+
{
51+
AuthenticationToken = authenticationToken ?? throw new ArgumentNullException(nameof(authenticationToken));
52+
return this;
53+
}
5454

55-
public GitLabConfigurationOptions WithProjectId([NotNull] string projectId)
56-
{
57-
ProjectId = projectId ?? throw new ArgumentNullException(nameof(projectId));
58-
return this;
59-
}
55+
public GitLabConfigurationOptions WithProjectId([NotNull] string projectId)
56+
{
57+
ProjectId = projectId ?? throw new ArgumentNullException(nameof(projectId));
58+
return this;
59+
}
6060

61-
public GitLabConfigurationOptions WithEnvironmentName([NotNull] string environmentName)
62-
{
63-
EnvironmentName = environmentName ?? throw new ArgumentNullException(nameof(environmentName));
64-
return this;
65-
}
61+
public GitLabConfigurationOptions WithEnvironmentName([NotNull] string environmentName)
62+
{
63+
EnvironmentName = environmentName ?? throw new ArgumentNullException(nameof(environmentName));
64+
return this;
65+
}
6666

67-
public GitLabConfigurationOptions WithKeyNormalizer([NotNull] Func<string, string> keyNormalizer)
68-
{
69-
KeyNormalizer = keyNormalizer ?? throw new ArgumentNullException(nameof(keyNormalizer));
70-
return this;
71-
}
67+
public GitLabConfigurationOptions WithKeyNormalizer([NotNull] Func<string, string> keyNormalizer)
68+
{
69+
KeyNormalizer = keyNormalizer ?? throw new ArgumentNullException(nameof(keyNormalizer));
70+
return this;
71+
}
7272

73-
private static string NormalizeKey(string key)
73+
private static string NormalizeKey(string key)
74+
{
75+
if (string.IsNullOrEmpty(key))
7476
{
75-
if (string.IsNullOrEmpty(key))
76-
{
77-
return key;
78-
}
77+
return key;
78+
}
7979

80-
var segments = Array.ConvertAll(key.Split('_'), e =>
81-
{
82-
e = e.ToLower();
83-
return e.Length <= 1 ? e : char.ToUpper(e[0]) + e.Substring(1);
84-
});
80+
var segments = Array.ConvertAll(key.Split('_'), e =>
81+
{
82+
e = e.ToLower();
83+
return e.Length <= 1 ? e : char.ToUpper(e[0]) + e.Substring(1);
84+
});
8585

86-
return string.Join(ConfigurationPath.KeyDelimiter, segments);
87-
}
86+
return string.Join(ConfigurationPath.KeyDelimiter, segments);
8887
}
8988
}

0 commit comments

Comments
 (0)