ADD: added updated drone.yml and changed some function calls

This commit is contained in:
Henry Winkel
2024-03-13 16:41:56 +01:00
parent 48101a673a
commit 0e05106d1e
13 changed files with 264 additions and 231 deletions

View File

@@ -1,6 +1,6 @@
#pragma once
#include "kubecontrol/KubernetesAPI.hpp"
#include <kubecontrol/KubernetesAPI.hpp>
#include "nlohmann/json_fwd.hpp"
#include "yaml-cpp/node/node.h"
#include <map>
@@ -17,17 +17,14 @@
#include <curlpp/cURLpp.hpp>
#include <filesystem>
#include <map>
#include <vector>
namespace kubecontrol
namespace kubecontrol
{
enum PullPolicy: uint32_t
{
{
ALWAYS,
IFNOTPRESENT,
NEVER
@@ -43,10 +40,10 @@ namespace kubecontrol
case PullPolicy::NEVER: return "Never";
default: return "Always";
}
}
}
struct PodChild
{
std::string UUID;
@@ -55,7 +52,6 @@ namespace kubecontrol
std::string Status;
};
struct PodInfos
{
std::string UUID;
@@ -68,108 +64,109 @@ namespace kubecontrol
class KubePod
{
public:
KubePod(std::string Owner, std::string Uuid, std::string ContainerImage,std::string Namespace = "simulator") ;
KubePod(std::string Owner, std::string Uuid, std::string Component, std::string ContainerImage,std::string Namespace = "simulator");
public:
KubePod(std::string &Owner, std::string &Uuid, std::string &ContainerImage,std::string Namespace = "simulator") ;
KubePod(std::string &Owner, std::string &Uuid, std::string &Component, std::string &ContainerImage,std::string Namespace = "simulator");
/**
* @brief returns the uuid of the pod
*
* @return std::string
*
* @return std::string
*/
std::string getUUID();
/**
* @brief Get the Owner of the pods
*
* @return std::string
*
* @return std::string
*/
std::string getOwner();
/**
* @brief Get the Ip of the pod
*
* @return std::string
*
* @return std::string
*/
std::string getIp();
/**
* @brief Get the Status
*
* @return std::string
* @brief Get the Status
*
* @return std::string
*/
std::string getStatus();
/**
* @brief Set the Environment Vars for pod
*
* @param key
* @param val
*
* @param key
* @param val
*/
void setEnvironmentVar(std::string key, std::string val);
/**
* @brief Get the Environment Vars
*
* @return std::map<std::string, std::string>
* @brief Get the Environment Vars
*
* @return std::map<std::string, std::string>
*/
std::map<std::string, std::string> GetEnvironmentVars();
/**
* @brief Get the Environment Var for a specific key
*
*
* @param key std::string
* @return std::string
* @return std::string
*/
std::string GetEnvironmentVar(std::string key);
/**
* @brief Set CMD args
*
* @param args
* @brief Set CMD args
*
* @param args
*/
void setArgs(std::string args);
void setArgs(std::string &args);
/**
* @brief Get the Args
*
* @return std::vector<std::string>
* @brief Get the Args
*
* @return std::vector<std::string>
*/
std::vector<std::string> GetArgs();
/**
* @brief Set the Command for a pod
*
* @param command
*/
void setCommand(std::string command);
/**
* @brief Get the Command
*
* @return std::string
* @brief Set the Command for a pod
*
* @param command
*/
void setCommand(std::string &command);
/**
* @brief Get the Command
*
* @return std::string
*/
std::string getCommand();
/**
* @brief Set the Component var for the pod
*
* @param component
*
* @param component
*/
void setComponent(std::string component);
void setComponent(std::string &component);
/**
* @brief Get the Component var
*
* @return std::string
*
* @return std::string
*/
std::string getComponent();
/**
* @brief add a Container to a pod
*
*
* @param name std::string
* @param image std::string
* @param envs std::map<std::string,std:.string>
@@ -178,17 +175,17 @@ namespace kubecontrol
void addContainer(std::string name,std::string image, std::shared_ptr<std::map<std::string, std::string>> envs = nullptr, PullPolicy pullPolicy = ALWAYS);
/**
* @brief sets the name of the pod
* @param string - term to be displayed
* @brief sets the name of the pod
* @param string - term to be displayed
*/
void setName(std::string name);
void setName(std::string &name);
/**
* @brief return the name of the pod
* @return std::string
*/
std::string getName();
int start(KubernetesAPI APIInterface,bool WaitTillRunning = true);
int stop(KubernetesAPI APIInterface);
@@ -204,7 +201,7 @@ namespace kubecontrol
std::vector<PodChild> getPodsChilds(KubernetesAPI APIInterface);
private:
static const int MaxWaitTimeInSeconds;
@@ -222,11 +219,11 @@ namespace kubecontrol
std::string Ip_;
std::string Status_;
std::string PartOf_;
std::string PartOf_;
std::vector<PodChild> ChildPods;
std::string PodCommand_;
YAML::Node YAMLNode_;
std::map<std::string, std::string> EnvirmonentVars_;
@@ -236,12 +233,12 @@ namespace kubecontrol
/**
* @brief extracts the asked inforamtion from the kubernetes response
*
*
*
*
*/
int extractInformationFromResopnse(std::string response);
};
}
}

View File

@@ -6,11 +6,11 @@
namespace kubecontrol
{
class KubernetesAPI
class KubernetesAPI
{
public:
public:
KubernetesAPI();
KubernetesAPI(YAML::Node config);
explicit KubernetesAPI(YAML::Node config);
KubernetesAPI(std::string APIAddress, std::string Token);
@@ -32,4 +32,4 @@ class KubernetesAPI
};
}
}

View File

@@ -13,8 +13,8 @@ namespace kubecontrol
class PodController
{
public:
PodController(std::string pathToKubectlConfig);
public:
explicit PodController(std::string pathToKubectlConfig);
std::string getServerAddress();
@@ -38,8 +38,8 @@ namespace kubecontrol
PodInfos extractInfosFromKubePod(KubePod *pod);
mutable std::mutex mx_;
};
} // namespace ku

View File

@@ -6,20 +6,20 @@ namespace kubecontrol
{
class kubecontrol
{
public:
kubecontrol(std::string pathToKubectlConfig);
explicit kubecontrol(std::string &pathToKubectlConfig);
void getPods();
void startPod();
void deletePod(std::string uid);
std::string createYAML();
private:
std::string BearerToken_;
std::string ServerAddress_;
std::string NameSpace_;
private:
std::string BearerToken_;
std::string ServerAddress_;
std::string NameSpace_;
};
}
}