Skip to content

Commit 09d178e

Browse files
authored
.NET 6 migration (#25)
* Multi-target build to .NET Standard 2.1 and .NET 6, nuget updates * Updated the sample app on how to use IOptionsSnapshot. Fixed VaultChangeWatcher dependency injection
1 parent f2e702d commit 09d178e

25 files changed

+337
-167
lines changed

dotnet-tools.json renamed to .config/dotnet-tools.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
"isRoot": true,
44
"tools": {
55
"cake.tool": {
6-
"version": "1.3.0",
6+
"version": "2.2.0",
77
"commands": [
88
"dotnet-cake"
99
]
1010
}
1111
}
12-
}
12+
}

.github/SECURITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ This project supports only the latest version with security updates. However, we
66

77
## Reporting a Vulnerability
88

9-
Contact [user@example.com|@ExampleUser] to report a security vulnerability. You will be thanked!
9+
Contact mihail.merkulov@gmail.com to report a security vulnerability. You will be thanked!

.github/workflows/build.yml

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ jobs:
1919
runs-on: ubuntu-latest
2020
steps:
2121
- name: Checkout
22-
uses: actions/checkout@v2
22+
uses: actions/checkout@v3
2323
with:
2424
lfs: true
2525
fetch-depth: 0
2626
- name: 'Git Fetch Tags'
2727
run: git fetch --tags
2828
shell: pwsh
2929
- name: 'Install .NET Core SDK'
30-
uses: actions/setup-dotnet@v1
30+
uses: actions/setup-dotnet@v2
3131
with:
32-
dotnet-version: 3.1.x
32+
dotnet-version: '6.0.x'
3333
- name: 'Dotnet Tool Restore'
3434
run: dotnet tool restore
3535
shell: pwsh
@@ -38,17 +38,38 @@ jobs:
3838
shell: pwsh
3939
- name: 'Dotnet Cake Test'
4040
run: dotnet cake --target=Test
41-
shell: pwsh
42-
- name: 'Dotnet Cake Pack'
43-
run: dotnet cake --target=Pack
44-
shell: pwsh
41+
shell: pwsh
42+
- name: Copy Coverage To Predictable Location
43+
if: github.event_name == 'pull_request'
44+
run: cp coverage/*/coverage.opencover.xml coverage/coverage.opencover.xml
4545
- name: 'Publish Code Coverage'
4646
uses: actions/upload-artifact@v2
4747
with:
4848
name: tests
49-
path: './Artefacts/**/coverage.opencover.xml'
49+
path: './coverage/coverage.opencover.xml'
5050
- name: 'Publish Test Results'
5151
uses: actions/upload-artifact@v2
5252
with:
5353
name: tests
54-
path: './Artefacts/VaultSharp.Extensions.Configuration.Test.html'
54+
path: './coverage/VaultSharp.Extensions.Configuration.Test.html'
55+
# - name: Code Coverage Summary Report
56+
# if: github.event_name == 'pull_request'
57+
# uses: irongut/[email protected]
58+
# with:
59+
# filename: coverage/coverage.opencover.xml
60+
# badge: true
61+
# fail_below_min: true
62+
# format: markdown
63+
# hide_branch_rate: false
64+
# hide_complexity: true
65+
# indicators: true
66+
# output: both
67+
# - name: Add Coverage PR Comment
68+
# uses: marocchino/sticky-pull-request-comment@v2
69+
# if: github.event_name == 'pull_request'
70+
# with:
71+
# recreate: true
72+
# path: code-coverage-results.md
73+
- name: 'Dotnet Cake Pack'
74+
run: dotnet cake --target=Pack
75+
shell: pwsh

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,3 +354,4 @@ MigrationBackup/
354354
.ionide/
355355

356356
Artefacts/
357+
coverage/

Directory.Build.props

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,16 @@
77
<PropertyGroup Label="Package">
88
<Authors>Mikhail Merkulov</Authors>
99
<Company>Mikhail Merkulov</Company>
10-
<Copyright>Copyright 2020 © Mikhail Merkulov. All rights Reserved</Copyright>
10+
<Copyright>Copyright 2022 © Mikhail Merkulov. All rights Reserved</Copyright>
1111
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
1212
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1313
<PackageProjectUrl>https://github.com/MrZoidberg/VaultSharp.Extensions.Configuration</PackageProjectUrl>
1414
<RepositoryUrl>https://github.com/MrZoidberg/VaultSharp.Extensions.Configuration.git</RepositoryUrl>
1515
<RepositoryType>git</RepositoryType>
1616
<PackageReleaseNotes>https://github.com/MrZoidberg/VaultSharp.Extensions.Configuration/releases</PackageReleaseNotes>
1717
</PropertyGroup>
18-
<ItemGroup Label="Package References">
19-
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" PrivateAssets="All" Version="5.0.3" />
20-
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" PrivateAssets="All" Version="16.10.56" />
21-
<PackageReference Include="MinVer" PrivateAssets="All" Version="2.5.0" />
22-
<PackageReference Include="StyleCop.Analyzers" PrivateAssets="All" Version="1.1.118" />
23-
</ItemGroup>
24-
</Project>
18+
19+
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
20+
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
21+
</PropertyGroup>
22+
</Project>

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2020 Project Author
3+
Copyright (c) 2022 Mikhail Merkulov
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
VaultSharp.Extensions.Configuration is an extension to [VaultSharp](https://github.com/rajanadar/VaultSharp) that allows reading configuration options from Vault.
66

7+
VaultSharp.Extensions.Configuration is a .NET Standard 2.1 and .NET 6.0 based cross-platform C# Library.
8+
79
## Get Started
810

911
VaultSharp.Extensions.Configuration can be installed using the Nuget package manager or the dotnet CLI.
@@ -67,8 +69,10 @@ Keep in mind that your service should be registered as scoped or transient to re
6769
Also `IOptionsSnapshot` can return empty value in some cases ([it's .net core bug](https://github.com/dotnet/runtime/issues/37860))
6870

6971
## Configuration using additional characters for a configuration path
72+
7073
This will be helpful when you want to flatten the structure of the secrets.
71-
For example the following two secret objects will evaluate to the same configuration if for the second object the `additionalCharactersForConfigurationPath` option is used with `new []{'.'}` value:
74+
For example the following two secret objects will evaluate to the same configuration if for the second object the `additionalCharactersForConfigurationPath` option is used with `new []{'.'}` value:
75+
7276
```json
7377
{
7478
"secrets":
@@ -80,6 +84,7 @@ For example the following two secret objects will evaluate to the same configura
8084
}
8185
}
8286
```
87+
8388
```json
8489
{
8590
"secrets":
@@ -128,7 +133,7 @@ All parameters are grouped and arranged in folders and can be managed within the
128133

129134
There are two ways to create nested parameters.
130135

131-
1. Description of nesting directly in Json format:
136+
1. Description of nesting directly in Json format (preferred approach):
132137

133138
```json
134139
{

Source/Directory.Build.props

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,4 @@
2020
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
2121
</PropertyGroup>
2222

23-
<ItemGroup Label="Package References">
24-
<PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="All" Version="1.0.0" />
25-
</ItemGroup>
26-
2723
</Project>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace SampleWebApp.Controllers;
2+
3+
using Microsoft.AspNetCore.Mvc;
4+
using Microsoft.Extensions.Options;
5+
using Options;
6+
7+
[Route("hello")]
8+
[ApiController]
9+
public class HelloController
10+
{
11+
[HttpGet("")]
12+
public IActionResult GetValue([FromServices] IOptionsSnapshot<TestOptions> testOptions) => new OkObjectResult(testOptions.Value);
13+
}

Source/SampleWebApp/Dockerfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env
1+
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env
22
WORKDIR /app
33

44
# Copy csproj and restore as distinct layers
5-
COPY /SampleWebApp/SampleWebApp.csproj ./SampleWebApp/
6-
COPY /VaultSharp.Extensions.Configuration/VaultSharp.Extensions.Configuration.csproj ./VaultSharp.Extensions.Configuration/
7-
RUN dotnet restore ./SampleWebApp/SampleWebApp.csproj
5+
COPY /Source/SampleWebApp/SampleWebApp.csproj ./Source/SampleWebApp/
6+
COPY /Source/VaultSharp.Extensions.Configuration/VaultSharp.Extensions.Configuration.csproj ./Source/VaultSharp.Extensions.Configuration/
7+
RUN dotnet restore ./Source/SampleWebApp/SampleWebApp.csproj
88

99
# Copy everything else and build
1010
COPY . ./
11-
RUN dotnet publish ./SampleWebApp/SampleWebApp.csproj -c Release -o out
11+
RUN dotnet publish ./Source/SampleWebApp/SampleWebApp.csproj -c Release -o out
1212

1313
# Build runtime image
14-
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
14+
FROM mcr.microsoft.com/dotnet/aspnet:6.0
1515
WORKDIR /app
1616
COPY --from=build-env /app/out .
1717
ENTRYPOINT ["dotnet", "SampleWebApp.dll"]

0 commit comments

Comments
 (0)