ADD: added podinfo with building a tree hierarchy for a pod

This commit is contained in:
Henry Winkel
2023-08-16 14:42:00 +02:00
parent 6c2f8f1eb6
commit 89465f06a5
8 changed files with 474 additions and 48 deletions

View File

@@ -1,5 +1,6 @@
#pragma once
#include "kubecontrol/PodInfo.hpp"
#include "nlohmann/json_fwd.hpp"
#include "yaml-cpp/node/node.h"
#include <map>
@@ -19,6 +20,7 @@
#include <vector>
namespace kubecontrol
{
class KubePod
@@ -49,8 +51,10 @@ namespace kubecontrol
std::string stop(std::string apiAddress,std::string token);
std::string getInfo(std::string apiAddress,std::string token);
PodInfo PodInfo;
private:
std::string Owner_;
std::string Uuid_;
@@ -69,5 +73,7 @@ namespace kubecontrol
std::string StopChilds(std::string apiAddress,std::string token,std::string uuid);
};
}

View File

@@ -1,5 +1,9 @@
#pragma once
#include "kubecontrol/PodInfo.hpp"
#include <kubecontrol/KubePod.hpp>
#include <memory>
#include <string>
#include <vector>
namespace kubecontrol
{
@@ -15,14 +19,28 @@ namespace kubecontrol
void stopAllPods();
std::string getPodsInfo();
std::string getInfoForOwnPod();
std::string getInfoForPod(std::string Label);
void checkPodsHierarchy();
std::string getPodsInfoForAll();
private:
std::vector<KubePod> PodList_;
std::string performRequest(std::string url);
void performForceStopRequest(std::string uuid);
std::string BearerToken_;
std::string ServerAddress_;
std::string ApiCall_;
// void addPodInfoToInfoList(std::shared_ptr<PodInfo> podinfo);
std::shared_ptr<PodInfo> getPodInfo(std::string uuid);
std::vector<std::shared_ptr<PodInfo>> podsInfoList_;
};
} // namespace ku

View File

@@ -0,0 +1,66 @@
#pragma once
#include "nlohmann/json_fwd.hpp"
#include <memory>
#include <string>
#include <vector>
#include <nlohmann/json.hpp>
#include <string>
#include <loguru.hpp>
namespace kubecontrol {
class PodInfo
{
public:
PodInfo();
PodInfo(std::string response);
void update(std::string response);
std::string ToString();
nlohmann::json ToJson();
std::vector<std::string> getRelatedPods();
std::string Uuid;
std::string Image;
std::string Ip;
std::string Component;
std::string Status;
std::string PartOf;
void addRelatedPods(std::string uuid);
size_t relatedPodsSize();
private:
std::vector<std::string> relatedPods;
};
// struct PodInfo
// {
// std::string Uuid;
// std::string Image;
// std::string Ip;
// std::string Component;
// std::string Status;
// std::string PartOf;
// std::vector<std::pair<std::string,std::shared_ptr<KubePod>>> relatedPods;
// bool operator==(PodInfo const &rhs )
// {
// if (Uuid == rhs.Uuid) {
// return true;
// }
// return false;
// }
// };
}

View File

@@ -1,5 +1,6 @@
#pragma once
#include <kubecontrol/KubePod.hpp>
#include <string>
#include <algorithm>
@@ -12,4 +13,10 @@ namespace kubecontrol
static std::string to_lower(std::string);
};
}