mirror of
https://github.com/logos-storage/logos-storage-nim-cs-dist-tests.git
synced 2026-01-06 23:43:07 +00:00
fixes serialization issue of containerAdditionals
This commit is contained in:
parent
5bbb95f1ff
commit
ecd0e70261
@ -1,4 +1,5 @@
|
|||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
namespace KubernetesWorkflow.Recipe
|
namespace KubernetesWorkflow.Recipe
|
||||||
{
|
{
|
||||||
@ -21,14 +22,13 @@ namespace KubernetesWorkflow.Recipe
|
|||||||
var typeName = GetTypeName(typeof(T));
|
var typeName = GetTypeName(typeof(T));
|
||||||
var userData = Additionals.SingleOrDefault(a => a.Type == typeName);
|
var userData = Additionals.SingleOrDefault(a => a.Type == typeName);
|
||||||
if (userData == null) return default;
|
if (userData == null) return default;
|
||||||
var jobject = (JObject)userData.UserData;
|
return JsonConvert.DeserializeObject<T>(userData.UserData);
|
||||||
return jobject.ToObject<T>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Additional ConvertToAdditional(object userData)
|
private static Additional ConvertToAdditional(object userData)
|
||||||
{
|
{
|
||||||
var typeName = GetTypeName(userData.GetType());
|
var typeName = GetTypeName(userData.GetType());
|
||||||
return new Additional(typeName, userData);
|
return new Additional(typeName, JsonConvert.SerializeObject(userData));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string GetTypeName(Type type)
|
private static string GetTypeName(Type type)
|
||||||
@ -41,13 +41,13 @@ namespace KubernetesWorkflow.Recipe
|
|||||||
|
|
||||||
public class Additional
|
public class Additional
|
||||||
{
|
{
|
||||||
public Additional(string type, object userData)
|
public Additional(string type, string userData)
|
||||||
{
|
{
|
||||||
Type = type;
|
Type = type;
|
||||||
UserData = userData;
|
UserData = userData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Type { get; }
|
public string Type { get; }
|
||||||
public object UserData { get; }
|
public string UserData { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -169,7 +169,7 @@ namespace CodexPlugin
|
|||||||
public bool IsValidator { get; private set; }
|
public bool IsValidator { get; private set; }
|
||||||
public Ether InitialEth { get; private set; } = 0.Eth();
|
public Ether InitialEth { get; private set; } = 0.Eth();
|
||||||
public TestToken InitialTestTokens { get; private set; } = 0.Tst();
|
public TestToken InitialTestTokens { get; private set; } = 0.Tst();
|
||||||
public EthAccountSetup EthAccountSetup { get; private set; } = new EthAccountSetup();
|
public EthAccountSetup EthAccountSetup { get; } = new EthAccountSetup();
|
||||||
|
|
||||||
public IMarketplaceSetup AsStorageNode()
|
public IMarketplaceSetup AsStorageNode()
|
||||||
{
|
{
|
||||||
@ -201,8 +201,8 @@ namespace CodexPlugin
|
|||||||
var result = "[(clientNode)"; // When marketplace is enabled, being a clientNode is implicit.
|
var result = "[(clientNode)"; // When marketplace is enabled, being a clientNode is implicit.
|
||||||
result += IsStorageNode ? "(storageNode)" : "()";
|
result += IsStorageNode ? "(storageNode)" : "()";
|
||||||
result += IsValidator ? "(validator)" : "() ";
|
result += IsValidator ? "(validator)" : "() ";
|
||||||
result += $"Address: '{EthAccountSetup}' ";
|
result += $"Pinned address: '{EthAccountSetup}' ";
|
||||||
result += $"{InitialEth.Eth} / {InitialTestTokens}";
|
result += $"{InitialEth} / {InitialTestTokens}";
|
||||||
result += "] ";
|
result += "] ";
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -235,6 +235,7 @@ namespace CodexPlugin
|
|||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
|
if (!accounts.Any()) return "NoEthAccounts";
|
||||||
return string.Join(",", accounts.Select(a => a.ToString()).ToArray());
|
return string.Join(",", accounts.Select(a => a.ToString()).ToArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
using CodexPlugin.Hooks;
|
using CodexPlugin.Hooks;
|
||||||
using Core;
|
using Core;
|
||||||
|
using GethPlugin;
|
||||||
using KubernetesWorkflow;
|
using KubernetesWorkflow;
|
||||||
using KubernetesWorkflow.Types;
|
using KubernetesWorkflow.Types;
|
||||||
using Logging;
|
using Logging;
|
||||||
@ -38,6 +39,7 @@ namespace CodexPlugin
|
|||||||
var podInfo = GetPodInfo(rc);
|
var podInfo = GetPodInfo(rc);
|
||||||
var podInfos = string.Join(", ", rc.Containers.Select(c => $"Container: '{c.Name}' PodLabel: '{c.RunningPod.StartResult.Deployment.PodLabel}' runs at '{podInfo.K8SNodeName}'={podInfo.Ip}"));
|
var podInfos = string.Join(", ", rc.Containers.Select(c => $"Container: '{c.Name}' PodLabel: '{c.RunningPod.StartResult.Deployment.PodLabel}' runs at '{podInfo.K8SNodeName}'={podInfo.Ip}"));
|
||||||
Log($"Started node with image '{containers.First().Containers.First().Recipe.Image}'. ({podInfos})");
|
Log($"Started node with image '{containers.First().Containers.First().Recipe.Image}'. ({podInfos})");
|
||||||
|
LogEthAddress(rc);
|
||||||
}
|
}
|
||||||
LogSeparator();
|
LogSeparator();
|
||||||
|
|
||||||
@ -144,6 +146,13 @@ namespace CodexPlugin
|
|||||||
Log("----------------------------------------------------------------------------");
|
Log("----------------------------------------------------------------------------");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void LogEthAddress(RunningPod rc)
|
||||||
|
{
|
||||||
|
var account = rc.Containers.First().Recipe.Additionals.Get<EthAccount>();
|
||||||
|
if (account == null) return;
|
||||||
|
Log($"{rc.Name} = {account}");
|
||||||
|
}
|
||||||
|
|
||||||
private void Log(string message)
|
private void Log(string message)
|
||||||
{
|
{
|
||||||
pluginTools.GetLog().Log(message);
|
pluginTools.GetLog().Log(message);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user