(feature): nuget

This commit is contained in:
Maksym Sadovnychyy 2024-08-17 23:50:18 +02:00
parent b37342cda1
commit 325d4172e9
6 changed files with 226 additions and 2 deletions

View File

@ -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/)
```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<string> { "/bin/sh" },
env: new Dictionary<string, string> { { "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 [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.

Binary file not shown.

View File

@ -5,6 +5,18 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>MaksIT.$(MSBuildProjectName.Replace(" ", "_"))</RootNamespace>
<!-- NuGet package metadata -->
<PackageId>PodmanClient.DotNet</PackageId>
<Version>1.0.2</Version>
<Authors>Maksym Sadovnychyy</Authors>
<Company>MAKS-IT</Company>
<Product>PodmanClient</Product>
<Description>Podman API client .NET implementation</Description>
<PackageTags>podman client dotnet</PackageTags>
<RepositoryUrl>https://github.com/MAKS-IT-COM/podman-client-dotnet</RepositoryUrl>
<License>MIT</License>
<RequireLicenseAcceptance>false</RequireLicenseAcceptance>
</PropertyGroup>
</Project>

92
src/README.md Normal file
View File

@ -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<string> { "/bin/sh" },
env: new Dictionary<string, string> { { "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).

View File

@ -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"

View File

@ -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
}