remove secrets from source code

master
Tudor Stanciu 2022-11-24 18:45:24 +02:00
parent 1b3d248da7
commit 1bd47f581e
3 changed files with 35 additions and 10 deletions

View File

@ -6,7 +6,9 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Corsinvest.ProxmoxVE.Api" Version="7.2.0" /> <PackageReference Include="Corsinvest.ProxmoxVE.Api" Version="7.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="5.0.0" /> <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="5.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -1,4 +1,5 @@
using Corsinvest.ProxmoxVE.Api; using Corsinvest.ProxmoxVE.Api;
using Microsoft.Extensions.Configuration;
using Newtonsoft.Json; using Newtonsoft.Json;
using ProxmoxConnector.Integration.Abstractions; using ProxmoxConnector.Integration.Abstractions;
using System; using System;
@ -8,11 +9,26 @@ namespace ProxmoxConnector.Integration.Corsinvest.Services
{ {
internal class PveConnector : IPveConnector internal class PveConnector : IPveConnector
{ {
private readonly string _hostName;
private readonly int _port;
private readonly string _userName;
private readonly string _password;
private readonly string _token;
public PveConnector(IConfiguration configuration)
{
var config = configuration.GetSection("Pve");
_hostName = config["HostName"];
_port = config.GetValue<int>("Port");
_userName = config["UserName"];
_password = config["Password"];
_token = config["Token"];
}
public async Task TestWithLogin() public async Task TestWithLogin()
{ {
//var client = new PveClient("***REMOVED***"); ***REMOVED*** ***REMOVED*** var client = new PveClient(_hostName, _port);
var client = new PveClient("***REMOVED***"); ***REMOVED*** if (await client.Login(_userName, _password))
if (await client.Login(***REMOVED***))
{ {
var vm = client.Nodes["pve-lora"].Qemu[100]; var vm = client.Nodes["pve-lora"].Qemu[100];
@ -46,16 +62,16 @@ namespace ProxmoxConnector.Integration.Corsinvest.Services
public async Task TestWithToken() public async Task TestWithToken()
{ {
//using Api Token //using Api Token
var client2 = new PveClient("***REMOVED***"); var client2 = new PveClient(_hostName, _port);
client2.ApiToken = "root@pam!test-token=***REMOVED***"; client2.ApiToken = _token;
var version = await client2.Version.Version(); var version = await client2.Version.Version();
Console.WriteLine(JsonConvert.SerializeObject(version.Response.data, Formatting.Indented)); Console.WriteLine(JsonConvert.SerializeObject(version.Response.data, Formatting.Indented));
} }
public async Task Start() public async Task Start()
{ {
var client = new PveClient("***REMOVED***"); ***REMOVED*** var client = new PveClient(_hostName, _port);
if (await client.Login(***REMOVED***)) if (await client.Login(_userName, _password))
{ {
var vm = client.Nodes["pve-lora"].Qemu[100]; var vm = client.Nodes["pve-lora"].Qemu[100];
@ -68,8 +84,8 @@ namespace ProxmoxConnector.Integration.Corsinvest.Services
public async Task Stop() public async Task Stop()
{ {
var client = new PveClient("***REMOVED***"); ***REMOVED*** var client = new PveClient(_hostName, _port);
if (await client.Login(***REMOVED***)) if (await client.Login(_userName, _password))
{ {
var vm = client.Nodes["pve-lora"].Qemu[100]; var vm = client.Nodes["pve-lora"].Qemu[100];

View File

@ -15,5 +15,12 @@
//"BaseAddress": "http://localhost:5063/" //"BaseAddress": "http://localhost:5063/"
"BaseAddress": "https://toodle.ddns.net/identity-server-api/" "BaseAddress": "https://toodle.ddns.net/identity-server-api/"
}, },
"Workspace": "Workspace" "Workspace": "Workspace",
"Pve": {
"HostName": "127.0.0.1",
"Port": "8006",
"UserName": "user",
"Password": "pass",
"Token": "user@pam!test-token=76****-***-***-***-1*******5a"
}
} }