From de06e407c5e5cf8f8fd4d30138911c7c74dbb0a2 Mon Sep 17 00:00:00 2001 From: Maksym Sadovnychyy Date: Sat, 17 Aug 2024 23:50:18 +0200 Subject: [PATCH] (feature): nuget --- README.md | 71 +++++++++++++++- src/PodmanClient.DotNet.nuspec | Bin 0 -> 1956 bytes src/PodmanClient/PodmanClientDotNet.csproj | 12 +++ src/README.md | 92 +++++++++++++++++++++ src/Release-NuGetPackage.bat | 7 ++ src/Release-NuGetPackage.ps1 | 46 +++++++++++ 6 files changed, 226 insertions(+), 2 deletions(-) create mode 100644 src/PodmanClient.DotNet.nuspec create mode 100644 src/README.md create mode 100644 src/Release-NuGetPackage.bat create mode 100644 src/Release-NuGetPackage.ps1 diff --git a/README.md b/README.md index 040fa93..2bf01c6 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,70 @@ -# Podman Client DotNet +Sure! Here's how your README file would look in Markdown format: -Podman API .NET cilent implementation based on podman latest [documentation](https://docs.podman.io/en/latest/) \ No newline at end of file +```markdown +# PodmanClientDotNet + +## Description + +`PodmanClientDotNet` is a .NET library designed to provide seamless interaction with the Podman API, allowing developers to manage and control containers directly from their .NET applications. This client library wraps the Podman API endpoints, offering a .NET-friendly interface to perform common container operations such as creating, starting, stopping, deleting containers, and more. + +## Purpose + +The primary goal of `PodmanClientDotNet` is to simplify the integration of Podman into .NET applications by providing a comprehensive, easy-to-use client library. Whether you're managing container lifecycles, executing commands inside containers, or manipulating container images, this library allows developers to interface with Podman using the familiar .NET development environment. + +## Key Features + +- **Container Management:** Create, start, stop, and delete containers with straightforward methods. +- **Image Operations:** Pull, tag, and manage images using the Podman API. +- **Exec Support:** Execute commands inside running containers, with support for attaching input/output streams. +- **Volume and Network Management:** Manage container volumes and networks as needed. +- **Streamlined Error Handling:** Provides detailed error handling, with informative responses based on HTTP status codes. + +## Usage Example + +```csharp +// Initialize the PodmanClient with base URL and timeout +var podmanClient = new PodmanClient("http://localhost:8080", 5); + +// Create a new container +var createResponse = await podmanClient.CreateContainerAsync( + name: "my-container", + image: "alpine:latest", + command: new List { "/bin/sh" }, + env: new Dictionary { { "ENV_VAR", "value" } }, + remove: true +); + +// Start the container +await podmanClient.StartContainerAsync(createResponse.Id); + +// Execute a command inside the container +var execResponse = await podmanClient.CreateExecAsync(createResponse.Id, new[] { "echo", "Hello, World!" }); +await podmanClient.StartExecAsync(execResponse.Id); +``` + +## Installation + +To include `PodmanClientDotNet` in your .NET project, you can add the package via NuGet: + +```shell +dotnet add package PodmanClient.DotNet --version 1.0.2 +``` + +## Documentation + +For detailed documentation on each method, including parameter descriptions and example usage, please refer to the official documentation (link to be provided). + +## Contribution + +Contributions to this project are welcome! Please fork the repository and submit a pull request with your changes. If you encounter any issues or have feature requests, feel free to open an issue on GitHub. + +## License + +This project is licensed under the MIT License - see the [LICENSE](LICENSE.md) file for details. + +## Contact + +For any questions or inquiries, please reach out via GitHub or [email](mailto:maksym.sadovnychyy@gmail.com). +``` + +This Markdown file is structured to provide a clear and informative README for your GitHub repository, offering essential details about your `PodmanClientDotNet` library. \ No newline at end of file diff --git a/src/PodmanClient.DotNet.nuspec b/src/PodmanClient.DotNet.nuspec new file mode 100644 index 0000000000000000000000000000000000000000..34a6d3814fcb28c129ce782cbf44f7be50064af9 GIT binary patch literal 1956 zcmds&&2AGx5QOWD#5;_90wmiIaX{E?gbW7+gh;?`FaE=};y>1#fFFt1;K6{eX0xou zNut%e%w zjOUEq;nE&h^+B1c#53XRcNJq_KErAOqp9BT9`jzqX$sCb{@TV~uH!n>Cs;0{-}U}^e42kk zo*l>qnVqLnKGi6| z`y~nuuGoUU>l-hE^mosJMT4wYpgIhDVy`&etI5%aSf>OPR z+{C4LR?J8~WhL)|iUX@X)@eL*v*>AIJ;%F@Hg}_B$4*b_XBS3}p0i_w4z6N_HJ!aS z-Ft_vn=o%D%-acb=j>iNan`(<%9QJryJHJWPf>kuwBpICr$3E8Jk3V-U6aKeUUk4* zQ(txdYj52{TW`K)`kanMoI~qX$5eMu?FsNK$m-i|KsR%J#8RE!9PH*s$gyvt2ChDj zRaVO7zh}->=C|&z5uH2N13rFs=>L+BJMW1psN8p`*|~EgcKL28^@P2?iLX=WU#)FR bb))~Zw(39gZ*}t=*Q(XCYFqm6TFvk;pWH=2 literal 0 HcmV?d00001 diff --git a/src/PodmanClient/PodmanClientDotNet.csproj b/src/PodmanClient/PodmanClientDotNet.csproj index 3502635..c4cb102 100644 --- a/src/PodmanClient/PodmanClientDotNet.csproj +++ b/src/PodmanClient/PodmanClientDotNet.csproj @@ -5,6 +5,18 @@ enable enable MaksIT.$(MSBuildProjectName.Replace(" ", "_")) + + + PodmanClient.DotNet + 1.0.2 + Maksym Sadovnychyy + MAKS-IT + PodmanClient + Podman API client .NET implementation + podman client dotnet + https://github.com/MAKS-IT-COM/podman-client-dotnet + MIT + false diff --git a/src/README.md b/src/README.md new file mode 100644 index 0000000..e762411 --- /dev/null +++ b/src/README.md @@ -0,0 +1,92 @@ +# PodmanClientDotNet + +## Description + +`PodmanClientDotNet` is a .NET library designed to provide seamless interaction with the Podman API, allowing developers to manage and control containers directly from their .NET applications. This client library wraps the Podman API endpoints, offering a .NET-friendly interface to perform common container operations such as creating, starting, stopping, deleting containers, and more. + +## Purpose + +The primary goal of `PodmanClientDotNet` is to simplify the integration of Podman into .NET applications by providing a comprehensive, easy-to-use client library. Whether you're managing container lifecycles, executing commands inside containers, or manipulating container images, this library allows developers to interface with Podman using the familiar .NET development environment. + +## Key Features + +- **Container Management:** Create, start, stop, and delete containers with straightforward methods. +- **Image Operations:** Pull, tag, and manage images using the Podman API. +- **Exec Support:** Execute commands inside running containers, with support for attaching input/output streams. +- **Volume and Network Management:** Manage container volumes and networks as needed. +- **Streamlined Error Handling:** Provides detailed error handling, with informative responses based on HTTP status codes. + +## Usage Example + +```csharp +// Initialize the PodmanClient with base URL and timeout +var podmanClient = new PodmanClient("http://localhost:8080", 5); + +// Create a new container +var createResponse = await podmanClient.CreateContainerAsync( + name: "my-container", + image: "alpine:latest", + command: new List { "/bin/sh" }, + env: new Dictionary { { "ENV_VAR", "value" } }, + remove: true +); + +// Start the container +await podmanClient.StartContainerAsync(createResponse.Id); + +// Execute a command inside the container +var execResponse = await podmanClient.CreateExecAsync(createResponse.Id, new[] { "echo", "Hello, World!" }); +await podmanClient.StartExecAsync(execResponse.Id); +``` + +## Installation + +To include `PodmanClientDotNet` in your .NET project, you can add the package via NuGet: + +```shell +dotnet add package PodmanClientDotNet +``` + +## Documentation + +For detailed documentation on each method, including parameter descriptions and example usage, please refer to the official documentation (link to be provided). + +## Contribution + +Contributions to this project are welcome! Please fork the repository and submit a pull request with your changes. If you encounter any issues or have feature requests, feel free to open an issue on GitHub. + +## License + +This project is licensed under the MIT License. See the full license text below. + +--- + +### MIT License + +``` +MIT License + +Copyright (c) 2024 Maksym Sadovnychyy (MAKS-IT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +``` + +## Contact + +For any questions or inquiries, please reach out via GitHub or [email](mailto:maksym.sadovnychyy@gmail.com). \ No newline at end of file diff --git a/src/Release-NuGetPackage.bat b/src/Release-NuGetPackage.bat new file mode 100644 index 0000000..ba9cefe --- /dev/null +++ b/src/Release-NuGetPackage.bat @@ -0,0 +1,7 @@ +@echo off + +REM Change directory to the location of the script +cd /d %~dp0 + +REM Invoke the PowerShell script (Release-NuGetPackage.ps1) in the same directory +powershell -ExecutionPolicy Bypass -File "%~dp0Release-NuGetPackage.ps1" diff --git a/src/Release-NuGetPackage.ps1 b/src/Release-NuGetPackage.ps1 new file mode 100644 index 0000000..bf48625 --- /dev/null +++ b/src/Release-NuGetPackage.ps1 @@ -0,0 +1,46 @@ +# Retrieve the API key from the environment variable +$apiKey = $env:NUGET_MAKS_IT +if (-not $apiKey) { + Write-Host "Error: API key not found in environment variable NUGET_MAKS_IT." + exit 1 +} + +# NuGet source +$nugetSource = "https://api.nuget.org/v3/index.json" + +# Define paths +$solutionDir = Split-Path -Parent $MyInvocation.MyCommand.Path +$projectDir = "$solutionDir\PodmanClient" +$outputDir = "$projectDir\bin\Release" + +# Clean previous builds +Write-Host "Cleaning previous builds..." +dotnet clean $projectDir -c Release + +# Build the project +Write-Host "Building the project..." +dotnet build $projectDir -c Release + +# Pack the NuGet package +Write-Host "Packing the project..." +dotnet pack $projectDir -c Release --no-build + +# Look for the .nupkg file +$packageFile = Get-ChildItem -Path $outputDir -Filter "*.nupkg" -Recurse | Sort-Object LastWriteTime -Descending | Select-Object -First 1 + +if ($packageFile) { + Write-Host "Package created successfully: $($packageFile.FullName)" + + # Push the package to NuGet + Write-Host "Pushing the package to NuGet..." + dotnet nuget push $packageFile.FullName -k $apiKey -s $nugetSource --skip-duplicate + + if ($LASTEXITCODE -eq 0) { + Write-Host "Package pushed successfully." + } else { + Write-Host "Failed to push the package." + } +} else { + Write-Host "Package creation failed. No .nupkg file found." + exit 1 +}