-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from Infisical/daniel/csharp-sdk
Feat: .NET SDK (breaking change for Java)
- Loading branch information
Showing
17 changed files
with
515 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
name: Release .NET SDK | ||
run-name: Release .NET SDK | ||
|
||
on: | ||
push: | ||
tags: | ||
- "*.*.*" # version, e.g. 1.0.0 | ||
|
||
jobs: | ||
generate_schemas: | ||
uses: ./.github/workflows/generate-schemas.yml | ||
|
||
build_rust: | ||
uses: ./.github/workflows/build-c-bindings.yml | ||
|
||
test-rust-crate: | ||
uses: ./.github/workflows/rust-test.yml | ||
|
||
build_dotnet: | ||
name: Build .NET | ||
runs-on: ubuntu-22.04 | ||
needs: | ||
- test-rust-crate | ||
- generate_schemas | ||
- build_rust | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
|
||
- name: Download C# schemas artifact | ||
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 | ||
with: | ||
name: schemas.cs | ||
path: languages/csharp/Infisical.Sdk | ||
|
||
- name: Set up .NET Core | ||
uses: actions/setup-dotnet@3447fd6a9f9e57506b15f895c5b76d3b197dc7c2 # v3.2.0 | ||
with: | ||
global-json-file: languages/csharp/global.json | ||
|
||
- name: Download x86_64-apple-darwin files | ||
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 | ||
with: | ||
name: libinfisical_c_files-x86_64-apple-darwin | ||
path: languages/csharp/Infisical.Sdk/macos-x64 | ||
|
||
- name: Download aarch64-apple-darwin files | ||
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 | ||
with: | ||
name: libinfisical_c_files-aarch64-apple-darwin | ||
path: languages/csharp/Infisical.Sdk/macos-arm64 | ||
|
||
- name: Download x86_64-unknown-linux-gnu files | ||
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 | ||
with: | ||
name: libinfisical_c_files-x86_64-unknown-linux-gnu | ||
path: languages/csharp/Infisical.Sdk/ubuntu-x64 | ||
|
||
- name: Download x86_64-pc-windows-msvc files | ||
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 | ||
with: | ||
name: libinfisical_c_files-x86_64-pc-windows-msvc | ||
path: languages/csharp/Infisical.Sdk/windows-x64 | ||
|
||
- name: Build .NET 8 Project | ||
working-directory: languages/csharp/Infisical.Sdk | ||
run: | | ||
dotnet restore | ||
dotnet build --configuration Release | ||
- name: Pack NuGet Package | ||
env: | ||
VERSION: ${{ github.ref_name }} | ||
run: dotnet pack --configuration Release -p:PackageID=Infisical.Sdk -p:Version=${VERSION} --output ./nuget-output /nologo /v:n | ||
working-directory: languages/csharp/Infisical.Sdk | ||
|
||
- name: Upload NuGet package | ||
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 | ||
with: | ||
name: Infisical.Sdk.${{github.ref_name}}.nupkg | ||
path: | | ||
./languages/csharp/Infisical.Sdk/nuget-output/*.nupkg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
languages/csharp/Infisical.Sdk.Samples/Infisical.Sdk.Samples.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Infisical.Sdk\Infisical.Sdk.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
namespace Infisical.Sdk.Samples; | ||
|
||
|
||
using Infisical.Sdk; | ||
|
||
|
||
|
||
internal class Program | ||
{ | ||
private static void Main(string[] args) | ||
{ | ||
|
||
ClientSettings settings = new ClientSettings | ||
{ | ||
ClientId = "Test" | ||
}; | ||
|
||
|
||
using var infisicalClient = new InfisicalClient(settings); | ||
|
||
var key = infisicalClient.createSymmetricKey(); | ||
|
||
Console.WriteLine($"Key: {key}"); | ||
|
||
|
||
EncryptSymmetricOptions options = new EncryptSymmetricOptions | ||
{ | ||
Key = key, | ||
Plaintext = "Hello World!" | ||
}; | ||
|
||
var encrypted = infisicalClient.encryptSymmetric(options); | ||
|
||
Console.WriteLine($"Encrypted: {encrypted.Ciphertext}"); | ||
|
||
|
||
|
||
DecryptSymmetricOptions decryptOptions = new DecryptSymmetricOptions | ||
{ | ||
Key = key, | ||
Ciphertext = encrypted.Ciphertext, | ||
Iv = encrypted.Iv, | ||
Tag = encrypted.Tag | ||
}; | ||
|
||
var decrypted = infisicalClient.decryptSymmetric(decryptOptions); | ||
|
||
Console.WriteLine($"Decrypted: {decrypted}"); | ||
|
||
|
||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System.Text.Json; | ||
|
||
namespace Infisical.Sdk; | ||
|
||
internal class CommandRunner | ||
{ | ||
private readonly InfisicalHandle _handle; | ||
|
||
internal CommandRunner(InfisicalHandle handle) | ||
{ | ||
_handle = handle; | ||
} | ||
|
||
internal T? RunCommand<T>(Command command) | ||
{ | ||
var req = JsonSerializer.Serialize(command, Converter.Settings); | ||
var result = InfisicalLibrary.RunCommand(req, _handle); | ||
return JsonSerializer.Deserialize<T>(result, Converter.Settings); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<RootNamespace>Infisical.Sdk</RootNamespace> | ||
|
||
<Title>Infisical SDK</Title> | ||
<Authors>Infisical</Authors> | ||
<Description>.NET SDK for Infisical</Description> | ||
<Copyright>Infisical</Copyright> | ||
<Product>SDK</Product> | ||
|
||
<RepositoryUrl>https://github.com/infisical/sdk/tree/master/languages/csharp</RepositoryUrl> | ||
<RepositoryType>Git</RepositoryType> | ||
|
||
<PackageProjectUrl>https://infisical.com</PackageProjectUrl> | ||
<PackageId>Infisical.Sdk</PackageId> | ||
<PackageIcon>infisical.png</PackageIcon> | ||
<PackageTags>Infisical;Sdk;.NET</PackageTags> | ||
<PackageReadmeFile>README.md</PackageReadmeFile> | ||
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="System.Text.Json" Version="7.0.3" /> | ||
<None Include="infisical.png" Pack="true" PackagePath="\" /> | ||
<None Include="../README.md" Pack="true" PackagePath="\" /> | ||
<None Include="../LICENSE.txt" Pack="true" PackagePath="\" /> | ||
</ItemGroup> | ||
|
||
<PropertyGroup> | ||
<!--Debugonly--> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug||AnyCPU' "> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup Condition="'$(Configuration)'=='Debug'"> | ||
<Content Include="../../../target/debug/libinfisical_c*.dylib"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
<PackageCopyToOutput>true</PackageCopyToOutput> | ||
</Content> | ||
<Content Include="../../../target/debug/libinfisical*.so"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
<PackageCopyToOutput>true</PackageCopyToOutput> | ||
</Content> | ||
<Content Include="../../../target/debug/infisical_c*.dll"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
<PackageCopyToOutput>true</PackageCopyToOutput> | ||
</Content> | ||
</ItemGroup> | ||
<ItemGroup Condition="'$(Configuration)'=='Release'"> | ||
<Content Include="macos-x64/libinfisical*.dylib"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
<PackageCopyToOutput>true</PackageCopyToOutput> | ||
<PackagePath>runtimes/osx-x64/native</PackagePath> | ||
</Content> | ||
<Content Include="macos-arm64/libinfisical*.dylib"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
<PackageCopyToOutput>true</PackageCopyToOutput> | ||
<PackagePath>runtimes/osx-arm64/native</PackagePath> | ||
</Content> | ||
<Content Include="ubuntu-x64/libinfisical*.so"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
<PackageCopyToOutput>true</PackageCopyToOutput> | ||
<PackagePath>runtimes/linux-x64/native</PackagePath> | ||
</Content> | ||
<Content Include="windows-x64/infisical_c*.dll"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
<PackageCopyToOutput>true</PackageCopyToOutput> | ||
<PackagePath>runtimes/win-x64/native</PackagePath> | ||
</Content> | ||
</ItemGroup> | ||
</Project> |
Oops, something went wrong.