FIX: fixed issue where the response of the kube api was not written correct
This commit is contained in:
@@ -10,62 +10,29 @@
|
||||
class WriterMemoryClass
|
||||
{
|
||||
public:
|
||||
// Helper Class for reading result from remote host
|
||||
WriterMemoryClass()
|
||||
{
|
||||
this->m_pBuffer = NULL;
|
||||
this->m_pBuffer = (char*) malloc(MAX_FILE_LENGTH * sizeof(char));
|
||||
this->m_Size = 0;
|
||||
};
|
||||
|
||||
~WriterMemoryClass()
|
||||
{
|
||||
if (this->m_pBuffer)
|
||||
free(this->m_pBuffer);
|
||||
};
|
||||
|
||||
void* Realloc(void* ptr, size_t size)
|
||||
{
|
||||
if(ptr)
|
||||
return realloc(ptr, size);
|
||||
else
|
||||
return malloc(size);
|
||||
};
|
||||
|
||||
// Callback must be declared static, otherwise it won't link...
|
||||
size_t WriteMemoryCallback(char* ptr, size_t size, size_t nmemb)
|
||||
{
|
||||
// Calculate the real size of the incoming buffer
|
||||
size_t realsize = size * nmemb;
|
||||
str_pBuffer.erase();
|
||||
str_pBuffer = std::string(ptr);
|
||||
|
||||
// (Re)Allocate memory for the buffer
|
||||
m_pBuffer = (char*) Realloc(m_pBuffer, m_Size + realsize);
|
||||
|
||||
// Test if Buffer is initialized correctly & copy memory
|
||||
if (m_pBuffer == NULL) {
|
||||
realsize = 0;
|
||||
}
|
||||
|
||||
memcpy(&(m_pBuffer[m_Size]), ptr, realsize);
|
||||
m_Size += realsize;
|
||||
|
||||
|
||||
// return the real size of the buffer...
|
||||
return realsize;
|
||||
return str_pBuffer.size();
|
||||
};
|
||||
|
||||
std::string getResponse()
|
||||
{
|
||||
return std::string(m_pBuffer);
|
||||
// return std::string(m_pBuffer);
|
||||
return str_pBuffer;
|
||||
}
|
||||
|
||||
void print()
|
||||
{
|
||||
std::cout << "Size: " << m_Size << std::endl;
|
||||
std::cout << "Content: " << std::endl << m_pBuffer << std::endl;
|
||||
std::cout << "Size: " << str_pBuffer.size() << std::endl;
|
||||
std::cout << "Content: " << std::endl << str_pBuffer << std::endl;
|
||||
}
|
||||
|
||||
// Public member vars
|
||||
char* m_pBuffer;
|
||||
size_t m_Size;
|
||||
private:
|
||||
std::string str_pBuffer;
|
||||
};
|
||||
@@ -226,12 +226,13 @@ namespace kubecontrol
|
||||
request.perform();
|
||||
|
||||
request.reset();
|
||||
auto response = mWriterChunk.getResponse();
|
||||
std::string response = mWriterChunk.getResponse();
|
||||
InfoPod.update(response);
|
||||
while (InfoPod.Status != "Running" && InfoPod.Status != "Succeeded") {
|
||||
|
||||
while (InfoPod.Status != "Running") {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||
response = this->getInfo(curlURL, token);
|
||||
response = this->getInfo(curlURL, token);
|
||||
|
||||
InfoPod.update(response);
|
||||
|
||||
}
|
||||
@@ -348,8 +349,7 @@ namespace kubecontrol
|
||||
|
||||
|
||||
request.perform();
|
||||
auto response = mWriterChunk.getResponse();
|
||||
return response;
|
||||
return mWriterChunk.getResponse();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -47,7 +47,6 @@ namespace kubecontrol
|
||||
Component = j["metadata"]["labels"]["app.kubernetes.io/component"].get<std::string>();
|
||||
PartOf = j["metadata"]["labels"]["app.kubernetes.io/part-of"].get<std::string>();
|
||||
Image = j["spec"]["containers"][0]["image"].get<std::string>();
|
||||
|
||||
if (j["status"].contains("podIP")) Ip = j["status"]["podIP"].get<std::string>();
|
||||
|
||||
Status = j["status"]["phase"].get<std::string>();
|
||||
@@ -58,6 +57,7 @@ namespace kubecontrol
|
||||
|
||||
} catch (std::exception& e)
|
||||
{
|
||||
// LOG_S(WARNING)<< response;
|
||||
LOG_S(ERROR)<<e.what();
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ SCENARIO("Testing the SimCore Sensor")
|
||||
|
||||
LOG_S(INFO)<<pod1.start(api,token);
|
||||
LOG_S(INFO)<< pod1.getInfo(api, token);
|
||||
// pod1.stop(api,token);
|
||||
pod1.stop(api,token);
|
||||
|
||||
WHEN("constructing Track Object with data")
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user