From 66cd80abd47580e18528b1ba0614dd5b9ffa14bb Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Wed, 27 Sep 2023 14:51:38 +0000 Subject: [PATCH 1/4] Remove deprecated ignition files Signed-off-by: Michael Carroll --- include/CMakeLists.txt | 1 - include/ignition/fuel_tools.hh | 19 -------- include/ignition/fuel_tools/ClientConfig.hh | 19 -------- .../fuel_tools/CollectionIdentifier.hh | 19 -------- include/ignition/fuel_tools/Export.hh | 19 -------- include/ignition/fuel_tools/FuelClient.hh | 19 -------- include/ignition/fuel_tools/Helpers.hh | 24 ---------- include/ignition/fuel_tools/Interface.hh | 19 -------- include/ignition/fuel_tools/JSONParser.hh | 19 -------- include/ignition/fuel_tools/Model.hh | 19 -------- .../ignition/fuel_tools/ModelIdentifier.hh | 19 -------- include/ignition/fuel_tools/ModelIter.hh | 19 -------- include/ignition/fuel_tools/RestClient.hh | 19 -------- include/ignition/fuel_tools/Result.hh | 19 -------- .../ignition/fuel_tools/WorldIdentifier.hh | 19 -------- include/ignition/fuel_tools/WorldIter.hh | 19 -------- include/ignition/fuel_tools/Zip.hh | 19 -------- include/ignition/fuel_tools/config.hh | 46 ------------------- src/ClientConfig.cc | 24 +--------- test/integration/deprecated_TEST.cc | 32 ------------- 20 files changed, 1 insertion(+), 411 deletions(-) delete mode 100644 include/ignition/fuel_tools.hh delete mode 100644 include/ignition/fuel_tools/ClientConfig.hh delete mode 100644 include/ignition/fuel_tools/CollectionIdentifier.hh delete mode 100644 include/ignition/fuel_tools/Export.hh delete mode 100644 include/ignition/fuel_tools/FuelClient.hh delete mode 100644 include/ignition/fuel_tools/Helpers.hh delete mode 100644 include/ignition/fuel_tools/Interface.hh delete mode 100644 include/ignition/fuel_tools/JSONParser.hh delete mode 100644 include/ignition/fuel_tools/Model.hh delete mode 100644 include/ignition/fuel_tools/ModelIdentifier.hh delete mode 100644 include/ignition/fuel_tools/ModelIter.hh delete mode 100644 include/ignition/fuel_tools/RestClient.hh delete mode 100644 include/ignition/fuel_tools/Result.hh delete mode 100644 include/ignition/fuel_tools/WorldIdentifier.hh delete mode 100644 include/ignition/fuel_tools/WorldIter.hh delete mode 100644 include/ignition/fuel_tools/Zip.hh delete mode 100644 include/ignition/fuel_tools/config.hh delete mode 100644 test/integration/deprecated_TEST.cc diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 992a1312..a35a0475 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -1,2 +1 @@ add_subdirectory(gz) -install(DIRECTORY ignition DESTINATION ${GZ_INCLUDE_INSTALL_DIR_FULL}) diff --git a/include/ignition/fuel_tools.hh b/include/ignition/fuel_tools.hh deleted file mode 100644 index ffffce19..00000000 --- a/include/ignition/fuel_tools.hh +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (C) 2022 Open Source Robotics Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include -#include diff --git a/include/ignition/fuel_tools/ClientConfig.hh b/include/ignition/fuel_tools/ClientConfig.hh deleted file mode 100644 index 61c4c834..00000000 --- a/include/ignition/fuel_tools/ClientConfig.hh +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (C) 2017 Open Source Robotics Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include -#include diff --git a/include/ignition/fuel_tools/CollectionIdentifier.hh b/include/ignition/fuel_tools/CollectionIdentifier.hh deleted file mode 100644 index d1190876..00000000 --- a/include/ignition/fuel_tools/CollectionIdentifier.hh +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (C) 2020 Open Source Robotics Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include -#include diff --git a/include/ignition/fuel_tools/Export.hh b/include/ignition/fuel_tools/Export.hh deleted file mode 100644 index 2d32dfcc..00000000 --- a/include/ignition/fuel_tools/Export.hh +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (C) 2022 Open Source Robotics Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include -#include diff --git a/include/ignition/fuel_tools/FuelClient.hh b/include/ignition/fuel_tools/FuelClient.hh deleted file mode 100644 index d2bcb4e2..00000000 --- a/include/ignition/fuel_tools/FuelClient.hh +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (C) 2017 Open Source Robotics Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include -#include diff --git a/include/ignition/fuel_tools/Helpers.hh b/include/ignition/fuel_tools/Helpers.hh deleted file mode 100644 index 990c4a60..00000000 --- a/include/ignition/fuel_tools/Helpers.hh +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2017 Open Source Robotics Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include -#include - -#define ign_strcat gz_strcat -#define ign_strcpy gz_strcpy -#define ign_sprintf gz_sprintf -#define ign_strdup gz_strdup diff --git a/include/ignition/fuel_tools/Interface.hh b/include/ignition/fuel_tools/Interface.hh deleted file mode 100644 index e96f09a7..00000000 --- a/include/ignition/fuel_tools/Interface.hh +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (C) 2018 Open Source Robotics Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include -#include diff --git a/include/ignition/fuel_tools/JSONParser.hh b/include/ignition/fuel_tools/JSONParser.hh deleted file mode 100644 index 91b74a06..00000000 --- a/include/ignition/fuel_tools/JSONParser.hh +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (C) 2017 Open Source Robotics Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include -#include diff --git a/include/ignition/fuel_tools/Model.hh b/include/ignition/fuel_tools/Model.hh deleted file mode 100644 index 4027323f..00000000 --- a/include/ignition/fuel_tools/Model.hh +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (C) 2017 Open Source Robotics Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include -#include diff --git a/include/ignition/fuel_tools/ModelIdentifier.hh b/include/ignition/fuel_tools/ModelIdentifier.hh deleted file mode 100644 index 23845149..00000000 --- a/include/ignition/fuel_tools/ModelIdentifier.hh +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (C) 2017 Open Source Robotics Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include -#include diff --git a/include/ignition/fuel_tools/ModelIter.hh b/include/ignition/fuel_tools/ModelIter.hh deleted file mode 100644 index 05a757a2..00000000 --- a/include/ignition/fuel_tools/ModelIter.hh +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (C) 2017 Open Source Robotics Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include -#include diff --git a/include/ignition/fuel_tools/RestClient.hh b/include/ignition/fuel_tools/RestClient.hh deleted file mode 100644 index 4daf0e1a..00000000 --- a/include/ignition/fuel_tools/RestClient.hh +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (C) 2017 Open Source Robotics Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include -#include diff --git a/include/ignition/fuel_tools/Result.hh b/include/ignition/fuel_tools/Result.hh deleted file mode 100644 index e7c87e8c..00000000 --- a/include/ignition/fuel_tools/Result.hh +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (C) 2017 Open Source Robotics Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include -#include diff --git a/include/ignition/fuel_tools/WorldIdentifier.hh b/include/ignition/fuel_tools/WorldIdentifier.hh deleted file mode 100644 index 497775ee..00000000 --- a/include/ignition/fuel_tools/WorldIdentifier.hh +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (C) 2018 Open Source Robotics Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include -#include diff --git a/include/ignition/fuel_tools/WorldIter.hh b/include/ignition/fuel_tools/WorldIter.hh deleted file mode 100644 index d2862468..00000000 --- a/include/ignition/fuel_tools/WorldIter.hh +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (C) 2018 Open Source Robotics Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include -#include diff --git a/include/ignition/fuel_tools/Zip.hh b/include/ignition/fuel_tools/Zip.hh deleted file mode 100644 index 21168112..00000000 --- a/include/ignition/fuel_tools/Zip.hh +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (C) 2017 Open Source Robotics Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include -#include diff --git a/include/ignition/fuel_tools/config.hh b/include/ignition/fuel_tools/config.hh deleted file mode 100644 index 9b866308..00000000 --- a/include/ignition/fuel_tools/config.hh +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2022 Open Source Robotics Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef IGNITION_FUEL_TOOLS__CONFIG_HH_ -#define IGNITION_FUEL_TOOLS__CONFIG_HH_ - -#include - -#define IGNITION_FUEL_TOOLS_MAJOR_VERSION GZ_FUEL_TOOLS_MAJOR_VERSION -#define IGNITION_FUEL_TOOLS_MINOR_VERSION GZ_FUEL_TOOLS_MINOR_VERSION -#define IGNITION_FUEL_TOOLS_PATCH_VERSION GZ_FUEL_TOOLS_PATCH_VERSION - -#define IGNITION_FUEL_TOOLS_VERSION GZ_FUEL_TOOLS_VERSION -#define IGNITION_FUEL_TOOLS_VERSION_FULL GZ_FUEL_TOOLS_VERSION_FULL - -#define IGNITION_FUEL_TOOLS_VERSION_HEADER GZ_FUEL_TOOLS_VERSION_HEADER - -#define IGNITION_FUEL_INITIAL_CONFIG_PATH GZ_FUEL_INITIAL_CONFIG_PATH - -namespace gz -{ -} - -namespace ignition -{ - #ifndef SUPPRESS_IGNITION_HEADER_DEPRECATION - #pragma message("ignition namespace is deprecated! Use gz instead!") - #endif - using namespace gz; -} - -#endif diff --git a/src/ClientConfig.cc b/src/ClientConfig.cc index 1b11c76e..13e4d4cb 100644 --- a/src/ClientConfig.cc +++ b/src/ClientConfig.cc @@ -211,17 +211,7 @@ ClientConfig::ClientConfig() : dataPtr(new ClientConfigPrivate) std::string gzFuelPath = ""; if (!gz::common::env("GZ_FUEL_CACHE_PATH", gzFuelPath)) { - // TODO(CH3): Deprecated. Remove on tock. - if (gz::common::env("IGN_FUEL_CACHE_PATH", gzFuelPath)) - { - gzwarn << "Using deprecated environment variable [IGN_FUEL_CACHE_PATH] " - << "to set cache path. Please use [GZ_FUEL_CACHE_PATH] instead." - << std::endl; - } - else - { - return; - } + return; } if (!gz::common::isDirectory(gzFuelPath)) @@ -449,18 +439,6 @@ bool ClientConfig::LoadConfig(const std::string &_file) << "path in the configuration file will be ignored" << std::endl; cacheLocation = gzFuelPath; } - // TODO(CH3): Deprecated. Remove on tock. - else if (gz::common::env("IGN_FUEL_CACHE_PATH", gzFuelPath)) - { - gzwarn << "Using deprecated environment variable [IGN_FUEL_CACHE_PATH] " - << "to set cache path. Please use [GZ_FUEL_CACHE_PATH] instead." - << std::endl; - - gzwarn << "GZ_FUEL_CACHE_PATH is set to [" << gzFuelPath << "]. The " - << "path in the configuration file will be ignored" << std::endl; - - cacheLocation = gzFuelPath; - } this->SetCacheLocation(cacheLocation); // Cleanup. diff --git a/test/integration/deprecated_TEST.cc b/test/integration/deprecated_TEST.cc deleted file mode 100644 index c2e7408c..00000000 --- a/test/integration/deprecated_TEST.cc +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2022 Open Source Robotics Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * -*/ - -#include - -#define SUPPRESS_IGNITION_HEADER_DEPRECATION - -#include -#include - -///////////////////////////////////////////////// -// Make sure the ignition namespace still works -TEST(Deprecated, IgnitionNamespace) -{ - ignition::fuel_tools::Model model; -} - -#undef SUPPRESS_IGNITION_HEADER_DEPRECATION From 74261e5256616bbeb36b4db8e2f61222c810a4dd Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Wed, 27 Sep 2023 15:12:52 +0000 Subject: [PATCH 2/4] Split ServerConfig and ClientConfig across multiple files Signed-off-by: Michael Carroll --- include/gz/fuel_tools/ClientConfig.hh | 65 +---------- include/gz/fuel_tools/ServerConfig.hh | 110 ++++++++++++++++++ src/CMakeLists.txt | 2 + src/ClientConfig.cc | 128 --------------------- src/ClientConfig_TEST.cc | 60 ---------- src/ServerConfig.cc | 160 ++++++++++++++++++++++++++ src/ServerConfig_TEST.cc | 125 ++++++++++++++++++++ 7 files changed, 398 insertions(+), 252 deletions(-) create mode 100644 include/gz/fuel_tools/ServerConfig.hh create mode 100644 src/ServerConfig.cc create mode 100644 src/ServerConfig_TEST.cc diff --git a/include/gz/fuel_tools/ClientConfig.hh b/include/gz/fuel_tools/ClientConfig.hh index da7eb962..870f8b39 100644 --- a/include/gz/fuel_tools/ClientConfig.hh +++ b/include/gz/fuel_tools/ClientConfig.hh @@ -25,6 +25,7 @@ #include #include "gz/fuel_tools/Export.hh" +#include "gz/fuel_tools/ServerConfig.hh" #ifdef _WIN32 // Disable warning C4251 which is triggered by @@ -37,73 +38,9 @@ namespace gz { namespace fuel_tools { - /// \brief forward declaration - class ServerConfigPrivate; - /// \brief Forward Declaration class ClientConfigPrivate; - /// \brief Describes options needed for a server. - class GZ_FUEL_TOOLS_VISIBLE ServerConfig - { - /// \brief Constructor. - public: ServerConfig(); - - /// \brief Copy constructor. - /// \param[in] _orig The server config to copy. - public: ServerConfig(const ServerConfig &_orig); - - /// \brief Assignment operator overload. - /// \param[in] _orig The server config to copy. - public: ServerConfig &operator=(const ServerConfig &_orig); - - /// \brief Destructor. - public: ~ServerConfig(); - - /// \brief Clear the server config. This will set all values to empty - /// strings, except the version string which will be set to its default - /// value. - public: void Clear(); - - /// \brief Get the URL to access the server. - /// \return The URL of this server. - public: common::URI Url() const; - - /// \brief Set the URL of this server. - /// \param[in] _url URL of this server. - public: void SetUrl(const common::URI &_url); - - /// \brief Get the API key to auth with the server. - /// \return The API key. - public: std::string ApiKey() const; - - /// \brief Set the API key to auth with the server. - /// \param[in] _key The API key. - public: void SetApiKey(const std::string &_key); - - /// \brief Get the protocol version used with this server. - /// \return The version. E.g.: "1.0". - public: std::string Version() const; - - /// \brief Set the protocol version used with this server. - /// \param[in] _version The version. E.g.: "1.0". - public: void SetVersion(const std::string &_version); - - /// \brief Returns all the server information as a string. - /// \param[in] _prefix Optional prefix for every line of the string. - /// \return Server information string - public: std::string AsString(const std::string &_prefix = "") const; - - /// \brief Returns all the available model information as a string using - /// colors for better human parsing. - /// \param[in] _prefix Optional prefix for every line of the string. - /// \return Model information string - public: std::string AsPrettyString(const std::string &_prefix = "") const; - - /// \brief PIMPL - private: std::unique_ptr dataPtr; - }; - /// \brief High level interface to Gazebo Fuel. /// class GZ_FUEL_TOOLS_VISIBLE ClientConfig diff --git a/include/gz/fuel_tools/ServerConfig.hh b/include/gz/fuel_tools/ServerConfig.hh new file mode 100644 index 00000000..e5fe4224 --- /dev/null +++ b/include/gz/fuel_tools/ServerConfig.hh @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2017 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef GZ_FUEL_TOOLS_SERVERCONFIG_HH_ +#define GZ_FUEL_TOOLS_SERVERCONFIG_HH_ + +#include +#include +#include + +#include + +#include "gz/fuel_tools/Export.hh" + +#ifdef _WIN32 +// Disable warning C4251 which is triggered by +// std::unique_ptr +#pragma warning(push) +#pragma warning(disable: 4251) +#endif + +namespace gz +{ + namespace fuel_tools + { + /// \brief forward declaration + class ServerConfigPrivate; + + /// \brief Describes options needed for a server. + class GZ_FUEL_TOOLS_VISIBLE ServerConfig + { + /// \brief Constructor. + public: ServerConfig(); + + /// \brief Copy constructor. + /// \param[in] _orig The server config to copy. + public: ServerConfig(const ServerConfig &_orig); + + /// \brief Assignment operator overload. + /// \param[in] _orig The server config to copy. + public: ServerConfig &operator=(const ServerConfig &_orig); + + /// \brief Destructor. + public: ~ServerConfig(); + + /// \brief Clear the server config. This will set all values to empty + /// strings, except the version string which will be set to its default + /// value. + public: void Clear(); + + /// \brief Get the URL to access the server. + /// \return The URL of this server. + public: common::URI Url() const; + + /// \brief Set the URL of this server. + /// \param[in] _url URL of this server. + public: void SetUrl(const common::URI &_url); + + /// \brief Get the API key to auth with the server. + /// \return The API key. + public: std::string ApiKey() const; + + /// \brief Set the API key to auth with the server. + /// \param[in] _key The API key. + public: void SetApiKey(const std::string &_key); + + /// \brief Get the protocol version used with this server. + /// \return The version. E.g.: "1.0". + public: std::string Version() const; + + /// \brief Set the protocol version used with this server. + /// \param[in] _version The version. E.g.: "1.0". + public: void SetVersion(const std::string &_version); + + /// \brief Returns all the server information as a string. + /// \param[in] _prefix Optional prefix for every line of the string. + /// \return Server information string + public: std::string AsString(const std::string &_prefix = "") const; + + /// \brief Returns all the available model information as a string using + /// colors for better human parsing. + /// \param[in] _prefix Optional prefix for every line of the string. + /// \return Model information string + public: std::string AsPrettyString(const std::string &_prefix = "") const; + + /// \brief PIMPL + private: std::unique_ptr dataPtr; + }; + } +} + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +#endif // GZ_FUEL_TOOLS_SERVERCONFIG_HH_ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c2ec97ac..2748e73f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -12,6 +12,7 @@ set (sources ModelIter.cc RestClient.cc Result.cc + ServerConfig.cc Zip.cc WorldIdentifier.cc WorldIter.cc @@ -31,6 +32,7 @@ set (gtest_sources Model_TEST.cc RestClient_TEST.cc Result_TEST.cc + ServerConfig_TEST.cc WorldIdentifier_TEST.cc WorldIter_TEST.cc Zip_TEST.cc diff --git a/src/ClientConfig.cc b/src/ClientConfig.cc index 13e4d4cb..b558255f 100644 --- a/src/ClientConfig.cc +++ b/src/ClientConfig.cc @@ -77,134 +77,6 @@ class gz::fuel_tools::ClientConfigPrivate "IgnitionFuelTools-" GZ_FUEL_TOOLS_VERSION_FULL; }; -////////////////////////////////////////////////// -/// \brief Private data class -class gz::fuel_tools::ServerConfigPrivate -{ - /// \brief Clear values. - public: void Clear() - { - this->url.Clear(); - this->key = ""; - this->version = "1.0"; - } - - /// \brief URL to reach server - public: common::URI url{"https://fuel.gazebosim.org"}; - - /// \brief A key to auth with the server - public: std::string key = ""; - - /// \brief The protocol version used when talking with this server. - public: std::string version = "1.0"; -}; - -////////////////////////////////////////////////// -ServerConfig::ServerConfig() - : dataPtr (new ServerConfigPrivate) -{ -} - -////////////////////////////////////////////////// -ServerConfig::ServerConfig(const ServerConfig &_orig) - : dataPtr(new ServerConfigPrivate) -{ - *(this->dataPtr) = *(_orig.dataPtr); -} - -////////////////////////////////////////////////// -void ServerConfig::Clear() -{ - this->dataPtr->Clear(); -} - -////////////////////////////////////////////////// -ServerConfig &ServerConfig::operator=(const ServerConfig &_orig) -{ - *(this->dataPtr) = *(_orig.dataPtr); - return *this; -} - -////////////////////////////////////////////////// -ServerConfig::~ServerConfig() -{ -} - -////////////////////////////////////////////////// -common::URI ServerConfig::Url() const -{ - return this->dataPtr->url; -} - -////////////////////////////////////////////////// -void ServerConfig::SetUrl(const common::URI &_url) -{ - this->dataPtr->url = _url; -} - -////////////////////////////////////////////////// -std::string ServerConfig::ApiKey() const -{ - return this->dataPtr->key; -} - -////////////////////////////////////////////////// -void ServerConfig::SetApiKey(const std::string &_key) -{ - this->dataPtr->key = _key; -} - -////////////////////////////////////////////////// -std::string ServerConfig::Version() const -{ - return this->dataPtr->version; -} - -////////////////////////////////////////////////// -void ServerConfig::SetVersion(const std::string &_version) -{ - this->dataPtr->version = _version; -} - -////////////////////////////////////////////////// -std::string ServerConfig::AsString(const std::string &_prefix) const -{ - std::stringstream out; - out << _prefix << "URL: " << this->Url().Str() << std::endl - << _prefix << "Version: " << this->Version() << std::endl - << _prefix << "API key: " << this->ApiKey() << std::endl; - return out.str(); -} - -////////////////////////////////////////////////// -std::string ServerConfig::AsPrettyString(const std::string &_prefix) const -{ - std::string prop = "\033[96m\033[1m"; - std::string value = "\033[37m"; - std::string reset = "\033[0m"; - - std::stringstream out; - - if (this->Url().Valid()) - { - out << _prefix << prop << "URL: " << reset - << value << this->Url().Str() << reset << std::endl; - } - - if (!this->Version().empty()) - { - out << _prefix << prop << "Version: " << reset - << value << this->Version() << reset << std::endl; - } - - if (!this->ApiKey().empty()) - { - out << _prefix << prop << "API key: " << reset - << value << this->ApiKey() << reset << std::endl; - } - return out.str(); -} - ////////////////////////////////////////////////// ClientConfig::ClientConfig() : dataPtr(new ClientConfigPrivate) { diff --git a/src/ClientConfig_TEST.cc b/src/ClientConfig_TEST.cc index efff93c0..c2b93292 100644 --- a/src/ClientConfig_TEST.cc +++ b/src/ClientConfig_TEST.cc @@ -65,8 +65,6 @@ class ClientConfigTest: public ::testing::Test public: std::shared_ptr tempDir; }; -class ServerConfigTest: public ClientConfigTest {}; - ///////////////////////////////////////////////// /// \brief Initially only the default server in config TEST_F(ClientConfigTest, InitiallyDefaultServers) @@ -268,19 +266,6 @@ TEST_F(ClientConfigTest, UserAgent) EXPECT_EQ("my_user_agent", config.UserAgent()); } -///////////////////////////////////////////////// -TEST_F(ServerConfigTest, ApiKey) -{ - ServerConfig config; - EXPECT_TRUE(config.ApiKey().empty()); - - config.SetApiKey("my_api_key"); - EXPECT_EQ("my_api_key", config.ApiKey()); - - config.SetApiKey("my_other_api_key"); - EXPECT_EQ("my_other_api_key", config.ApiKey()); -} - ///////////////////////////////////////////////// TEST_F(ClientConfigTest, AsString) { @@ -371,48 +356,3 @@ TEST_F(ClientConfigTest, AsPrettyString) EXPECT_NE(str.find("ABCD"), std::string::npos); } } - -///////////////////////////////////////////////// -TEST_F(ServerConfigTest, Url) -{ - // Invalid URL string - { - ServerConfig srv; - srv.SetUrl(common::URI("asdf")); - EXPECT_TRUE(srv.Url().Str().empty()); - } - - // Valid URL - { - ServerConfig srv; - srv.SetUrl(common::URI("http://banana:8080")); - EXPECT_EQ("http://banana:8080", srv.Url().Str()); - EXPECT_EQ("http", srv.Url().Scheme()); - EXPECT_EQ("banana:8080", srv.Url().Path().Str()); - EXPECT_FALSE(srv.Url().Authority()); - } - - // Trailing / - { - ServerConfig srv; - srv.SetUrl(common::URI("http://banana:8080")); - EXPECT_EQ("http://banana:8080", srv.Url().Str()); - EXPECT_EQ("http", srv.Url().Scheme()); - EXPECT_EQ("banana:8080", srv.Url().Path().Str()); - EXPECT_FALSE(srv.Url().Authority()); - } - - // Set from URI - { - auto url = common::URI(); - url.SetScheme("http"); - url.Path() = common::URIPath("banana:8080"); - - ServerConfig srv; - srv.SetUrl(url); - EXPECT_EQ("http://banana:8080", srv.Url().Str()); - EXPECT_EQ("http", srv.Url().Scheme()); - EXPECT_EQ("banana:8080", srv.Url().Path().Str()); - EXPECT_FALSE(srv.Url().Authority()); - } -} diff --git a/src/ServerConfig.cc b/src/ServerConfig.cc new file mode 100644 index 00000000..3855734f --- /dev/null +++ b/src/ServerConfig.cc @@ -0,0 +1,160 @@ +/* + * Copyright (C) 2017 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "gz/fuel_tools/ServerConfig.hh" +#include "gz/fuel_tools/config.hh" + +using namespace gz; +using namespace fuel_tools; + +////////////////////////////////////////////////// +/// \brief Private data class +class gz::fuel_tools::ServerConfigPrivate +{ + /// \brief Clear values. + public: void Clear() + { + this->url.Clear(); + this->key = ""; + this->version = "1.0"; + } + + /// \brief URL to reach server + public: common::URI url{"https://fuel.gazebosim.org"}; + + /// \brief A key to auth with the server + public: std::string key = ""; + + /// \brief The protocol version used when talking with this server. + public: std::string version = "1.0"; +}; + +////////////////////////////////////////////////// +ServerConfig::ServerConfig() + : dataPtr (new ServerConfigPrivate) +{ +} + +////////////////////////////////////////////////// +ServerConfig::ServerConfig(const ServerConfig &_orig) + : dataPtr(new ServerConfigPrivate) +{ + *(this->dataPtr) = *(_orig.dataPtr); +} + +////////////////////////////////////////////////// +void ServerConfig::Clear() +{ + this->dataPtr->Clear(); +} + +////////////////////////////////////////////////// +ServerConfig &ServerConfig::operator=(const ServerConfig &_orig) +{ + *(this->dataPtr) = *(_orig.dataPtr); + return *this; +} + +////////////////////////////////////////////////// +ServerConfig::~ServerConfig() +{ +} + +////////////////////////////////////////////////// +common::URI ServerConfig::Url() const +{ + return this->dataPtr->url; +} + +////////////////////////////////////////////////// +void ServerConfig::SetUrl(const common::URI &_url) +{ + this->dataPtr->url = _url; +} + +////////////////////////////////////////////////// +std::string ServerConfig::ApiKey() const +{ + return this->dataPtr->key; +} + +////////////////////////////////////////////////// +void ServerConfig::SetApiKey(const std::string &_key) +{ + this->dataPtr->key = _key; +} + +////////////////////////////////////////////////// +std::string ServerConfig::Version() const +{ + return this->dataPtr->version; +} + +////////////////////////////////////////////////// +void ServerConfig::SetVersion(const std::string &_version) +{ + this->dataPtr->version = _version; +} + +////////////////////////////////////////////////// +std::string ServerConfig::AsString(const std::string &_prefix) const +{ + std::stringstream out; + out << _prefix << "URL: " << this->Url().Str() << std::endl + << _prefix << "Version: " << this->Version() << std::endl + << _prefix << "API key: " << this->ApiKey() << std::endl; + return out.str(); +} + +////////////////////////////////////////////////// +std::string ServerConfig::AsPrettyString(const std::string &_prefix) const +{ + std::string prop = "\033[96m\033[1m"; + std::string value = "\033[37m"; + std::string reset = "\033[0m"; + + std::stringstream out; + + if (this->Url().Valid()) + { + out << _prefix << prop << "URL: " << reset + << value << this->Url().Str() << reset << std::endl; + } + + if (!this->Version().empty()) + { + out << _prefix << prop << "Version: " << reset + << value << this->Version() << reset << std::endl; + } + + if (!this->ApiKey().empty()) + { + out << _prefix << prop << "API key: " << reset + << value << this->ApiKey() << reset << std::endl; + } + return out.str(); +} diff --git a/src/ServerConfig_TEST.cc b/src/ServerConfig_TEST.cc new file mode 100644 index 00000000..4c386b28 --- /dev/null +++ b/src/ServerConfig_TEST.cc @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2017 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "gz/fuel_tools/config.hh" +#include "gz/fuel_tools/ServerConfig.hh" + +using namespace gz; +using namespace fuel_tools; + +///////////////////////////////////////////////// +/// \brief Get home directory. +/// \return Home directory or empty string if home wasn't found. +/// \ToDo: Move this function to gz::common::Filesystem +std::string homePath() +{ + std::string homePath; +#ifndef _WIN32 + gz::common::env("HOME", homePath); +#else + gz::common::env("USERPROFILE", homePath); +#endif + return homePath; +} + +///////////////////////////////////////////////// +class ServerConfigTest: public ::testing::Test +{ + public: void SetUp() override + { + gz::common::Console::SetVerbosity(4); + tempDir = gz::common::testing::MakeTestTempDirectory(); + ASSERT_TRUE(tempDir->Valid()) << tempDir->Path(); + + gz::common::chdir(tempDir->Path()); + } + + public: std::string cachePath() + { + return this->tempDir->Path(); + } + + public: std::shared_ptr tempDir; +}; + +///////////////////////////////////////////////// +TEST_F(ServerConfigTest, ApiKey) +{ + ServerConfig config; + EXPECT_TRUE(config.ApiKey().empty()); + + config.SetApiKey("my_api_key"); + EXPECT_EQ("my_api_key", config.ApiKey()); + + config.SetApiKey("my_other_api_key"); + EXPECT_EQ("my_other_api_key", config.ApiKey()); +} + + +///////////////////////////////////////////////// +TEST_F(ServerConfigTest, Url) +{ + // Invalid URL string + { + ServerConfig srv; + srv.SetUrl(common::URI("asdf")); + EXPECT_TRUE(srv.Url().Str().empty()); + } + + // Valid URL + { + ServerConfig srv; + srv.SetUrl(common::URI("http://banana:8080")); + EXPECT_EQ("http://banana:8080", srv.Url().Str()); + EXPECT_EQ("http", srv.Url().Scheme()); + EXPECT_EQ("banana:8080", srv.Url().Path().Str()); + EXPECT_FALSE(srv.Url().Authority()); + } + + // Trailing / + { + ServerConfig srv; + srv.SetUrl(common::URI("http://banana:8080")); + EXPECT_EQ("http://banana:8080", srv.Url().Str()); + EXPECT_EQ("http", srv.Url().Scheme()); + EXPECT_EQ("banana:8080", srv.Url().Path().Str()); + EXPECT_FALSE(srv.Url().Authority()); + } + + // Set from URI + { + auto url = common::URI(); + url.SetScheme("http"); + url.Path() = common::URIPath("banana:8080"); + + ServerConfig srv; + srv.SetUrl(url); + EXPECT_EQ("http://banana:8080", srv.Url().Str()); + EXPECT_EQ("http", srv.Url().Scheme()); + EXPECT_EQ("banana:8080", srv.Url().Path().Str()); + EXPECT_FALSE(srv.Url().Authority()); + } +} From 0515af1381f8fa32a24f2742cf62455e6af1a244 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Wed, 27 Sep 2023 15:15:05 +0000 Subject: [PATCH 3/4] Drop focal from CI Signed-off-by: Michael Carroll --- .github/workflows/ci.yml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ca539218..f34b97bd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,19 +3,6 @@ name: Ubuntu CI on: [push, pull_request] jobs: - focal-ci: - runs-on: ubuntu-latest - name: Ubuntu Focal CI - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Compile and test - id: ci - uses: gazebo-tooling/action-gz-ci@focal - with: - codecov-enabled: true - cppcheck-enabled: true - cpplint-enabled: true jammy-ci: runs-on: ubuntu-latest name: Ubuntu Jammy CI From 645befb3a04a15bfd4a4e3ca119f871afbcf9b64 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Wed, 4 Oct 2023 15:13:37 +0000 Subject: [PATCH 4/4] Address reviewer feedback Signed-off-by: Michael Carroll --- include/gz/fuel_tools/ServerConfig.hh | 1 - src/ServerConfig.cc | 2 -- src/ServerConfig_TEST.cc | 2 -- 3 files changed, 5 deletions(-) diff --git a/include/gz/fuel_tools/ServerConfig.hh b/include/gz/fuel_tools/ServerConfig.hh index e5fe4224..66e7abc9 100644 --- a/include/gz/fuel_tools/ServerConfig.hh +++ b/include/gz/fuel_tools/ServerConfig.hh @@ -20,7 +20,6 @@ #include #include -#include #include diff --git a/src/ServerConfig.cc b/src/ServerConfig.cc index 3855734f..fffaaff6 100644 --- a/src/ServerConfig.cc +++ b/src/ServerConfig.cc @@ -20,13 +20,11 @@ #include #include #include -#include #include #include #include #include "gz/fuel_tools/ServerConfig.hh" -#include "gz/fuel_tools/config.hh" using namespace gz; using namespace fuel_tools; diff --git a/src/ServerConfig_TEST.cc b/src/ServerConfig_TEST.cc index 4c386b28..3e51e6e1 100644 --- a/src/ServerConfig_TEST.cc +++ b/src/ServerConfig_TEST.cc @@ -24,7 +24,6 @@ #include #include -#include "gz/fuel_tools/config.hh" #include "gz/fuel_tools/ServerConfig.hh" using namespace gz; @@ -78,7 +77,6 @@ TEST_F(ServerConfigTest, ApiKey) EXPECT_EQ("my_other_api_key", config.ApiKey()); } - ///////////////////////////////////////////////// TEST_F(ServerConfigTest, Url) {