diff --git a/include/kubecontrol/PodController.hpp b/include/kubecontrol/PodController.hpp index eb69738..5ff0749 100644 --- a/include/kubecontrol/PodController.hpp +++ b/include/kubecontrol/PodController.hpp @@ -36,6 +36,7 @@ namespace kubecontrol std::string BearerToken_; std::string ServerAddress_; + std::string Namespace_; std::string ApiCall_; // void addPodInfoToInfoList(std::shared_ptr podinfo); diff --git a/src/kubecontrol/KubePod.cpp b/src/kubecontrol/KubePod.cpp index 515f04f..f8c13f2 100644 --- a/src/kubecontrol/KubePod.cpp +++ b/src/kubecontrol/KubePod.cpp @@ -215,7 +215,7 @@ namespace kubecontrol this->createYAML(); - LOG_S(ERROR)<< this->PathToYaml_; + LOG_S(INFO)<< this->PathToYaml_; std::stringstream stream; stream << YAMLNode_; diff --git a/src/kubecontrol/PodController.cpp b/src/kubecontrol/PodController.cpp index 65c62f3..2515826 100644 --- a/src/kubecontrol/PodController.cpp +++ b/src/kubecontrol/PodController.cpp @@ -21,6 +21,7 @@ namespace kubecontrol YAML::Node config = YAML::LoadFile(pathToKubectlConfig); BearerToken_ = config["users"][0]["user"]["token"].as(); + Namespace_ = config["contexts"][0]["context"]["namespace"].as(); char * KUBERNETES_SERVICE_HOST = std::getenv("KUBERNETES_SERVICE_HOST"); char * KUBERNETES_SERVICE_PORT = std::getenv("KUBERNETES_SERVICE_PORT"); @@ -35,7 +36,7 @@ namespace kubecontrol ServerAddress_ = config["clusters"][0]["cluster"]["server"].as(); } - ApiCall_ = "/api/v1/namespaces/hwinkel/pods/"; + ApiCall_ = "/api/v1/namespaces/"+Namespace_+"/pods/"; } catch (std::exception& e) { LOG_S(ERROR)<< e.what(); throw e.what(); diff --git a/src/kubecontrol/kubecontrol.cpp b/src/kubecontrol/kubecontrol.cpp index 8b0d8d8..9dc5669 100644 --- a/src/kubecontrol/kubecontrol.cpp +++ b/src/kubecontrol/kubecontrol.cpp @@ -44,7 +44,7 @@ namespace kubecontrol void kubecontrol::getPods() { - std::string curlURL = ServerAddress_+"/api/v1/namespaces/hwinkel/pods/"; + std::string curlURL = ServerAddress_+"/api/v1/namespaces/simulator/pods/"; std::string AuthString = "Authorization: Bearer " + BearerToken_; std::list headers; @@ -85,7 +85,7 @@ namespace kubecontrol void kubecontrol::startPod() { - std::string curlURL = ServerAddress_+"/api/v1/namespaces/hwinkel/pods/"; + std::string curlURL = ServerAddress_+"/api/v1/namespaces/simulator/pods/"; std::string AuthString = "Authorization: Bearer " + BearerToken_; std::list headers; @@ -155,7 +155,7 @@ namespace kubecontrol void kubecontrol::deletePod(std::string uid) { - std::string curlURL = ServerAddress_+"/api/v1/namespaces/hwinkel/pods/"+ uid; + std::string curlURL = ServerAddress_+"/api/v1/namespaces/simulator/pods/"+ uid; std::string AuthString = "Authorization: Bearer " + BearerToken_; std::list headers; diff --git a/tests/test_KubePod.cpp b/tests/test_KubePod.cpp index f2a9ee9..a32c6cd 100644 --- a/tests/test_KubePod.cpp +++ b/tests/test_KubePod.cpp @@ -12,8 +12,8 @@ SCENARIO("Testing the SimCore Sensor") GIVEN("different Attributes for a Track in different forms") { - std::string api = "https://192.168.252.5:6443/api/v1/namespaces/hwinkel/pods/"; - std::string token = "eyJhbGciOiJSUzI1NiIsImtpZCI6InJwN2R3a2NEWHJva0ptLVNFUnAxMnUxNEF3VUdmdURRTmw5VWZuM0NCZ3MifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJod2lua2VsIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZWNyZXQubmFtZSI6Imh3aW5rZWwtc2VjcmV0Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6Imh3aW5rZWwiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiJmNDNkNTc5NS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uyrK_mNdW4piDADXKPtEW9YP2x1R57uhTDPFfG6LPMFbZTNyeI-A7A7bmjjAt0ICJDuLeL69J8ig3TS-i54R_PB--wFr-7jZMhnNz2wueyPuXxGiIuX-36H9rZ1cA-Dgt2qtDMNhK0TvOlgwUFU_cRjb2W0NhSvH8uB0qtIqOCyVzapCVwXWinyJPGiPL3ph8VxSo6P0ZDa4UjMJ_D6IlMpUpuHriKPLjGnDwTh2oJBjMFOmC_E0Mnr6Sd0rxzsIjIeG_ST6KqoPwyCTX27CPmO74CJUguLgFXSBOjuzvxon8KRYG6VJhRawEDnTU0zx6XrPXIQ"; auto guid = xg::newGuid(); std::string uuid = guid.str(); // int random = rand() % 100 + 1;