From 9d8c1c2591005aca353d9fdb15bacb801fb47fc1 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Wed, 24 Jul 2024 16:10:09 -0500 Subject: [PATCH 1/3] Add Url accessor to Identifiers (#429) Previously we were relying on UniqueName to hold a Url. UniqueName was updated to generate filesystem-safe paths for both Linux and Windows, so it no longer holds a valid Url. This adds a peer method to also retrieve the Url of the Model/World/Collection Signed-off-by: Michael Carroll --- include/gz/fuel_tools/CollectionIdentifier.hh | 4 +++ include/gz/fuel_tools/ModelIdentifier.hh | 4 +++ include/gz/fuel_tools/WorldIdentifier.hh | 4 +++ src/CollectionIdentifier.cc | 10 +++++++ src/CollectionIdentifier_TEST.cc | 27 ++++++++++++++++++- src/ModelIdentifier.cc | 10 +++++++ src/ModelIdentifier_TEST.cc | 26 ++++++++++++++++++ src/WorldIdentifier.cc | 10 +++++++ src/WorldIdentifier_TEST.cc | 27 +++++++++++++++++++ 9 files changed, 121 insertions(+), 1 deletion(-) diff --git a/include/gz/fuel_tools/CollectionIdentifier.hh b/include/gz/fuel_tools/CollectionIdentifier.hh index 9e7d5cca..da0170ea 100644 --- a/include/gz/fuel_tools/CollectionIdentifier.hh +++ b/include/gz/fuel_tools/CollectionIdentifier.hh @@ -92,6 +92,10 @@ namespace gz::fuel_tools /// \return Unique collection name. public: std::string UniqueName() const; + /// \brief Returns a URL for the collection. + /// \remarks this is Server/Owner/Name. + public: gz::common::URI Url() const; + /// \brief Returns all the collection information as a string. Convenient /// for debugging. /// \param[in] _prefix Optional prefix for every line of the string. diff --git a/include/gz/fuel_tools/ModelIdentifier.hh b/include/gz/fuel_tools/ModelIdentifier.hh index 70eb9d2a..534a6ef2 100644 --- a/include/gz/fuel_tools/ModelIdentifier.hh +++ b/include/gz/fuel_tools/ModelIdentifier.hh @@ -84,6 +84,10 @@ namespace gz::fuel_tools /// \return Unique model name. public: std::string UniqueName() const; + /// \brief Returns a URL for the model. + /// \remarks this is Server/Owner/Name. + public: gz::common::URI Url() const; + /// \brief set the name of the model. /// \param[in] _name The name to set. Must be ascii and pass [-_a-z0-9]+. /// \return true if successful. diff --git a/include/gz/fuel_tools/WorldIdentifier.hh b/include/gz/fuel_tools/WorldIdentifier.hh index 62c8d738..d14bdee2 100644 --- a/include/gz/fuel_tools/WorldIdentifier.hh +++ b/include/gz/fuel_tools/WorldIdentifier.hh @@ -131,6 +131,10 @@ namespace gz::fuel_tools /// \return Unique world name. public: std::string UniqueName() const; + /// \brief Returns a URL for the world. + /// \remarks this is Server/Owner/Name. + public: gz::common::URI Url() const; + // /// \brief Sets the SHA 2 256 hash of the world // /// \param[in] _hash a 256 bit SHA 2 hash // /// \returns true if successful diff --git a/src/CollectionIdentifier.cc b/src/CollectionIdentifier.cc index 949e4be6..2ac1d5cf 100644 --- a/src/CollectionIdentifier.cc +++ b/src/CollectionIdentifier.cc @@ -76,6 +76,16 @@ std::string CollectionIdentifier::UniqueName() const this->dataPtr->name); } +////////////////////////////////////////////////// +gz::common::URI CollectionIdentifier::Url() const +{ + return common::URI( + common::joinPaths(this->dataPtr->server.Url().Str(), + this->dataPtr->owner, + "collections", + this->dataPtr->name), true); +} + ////////////////////////////////////////////////// std::string CollectionIdentifier::Name() const { diff --git a/src/CollectionIdentifier_TEST.cc b/src/CollectionIdentifier_TEST.cc index e18b393a..4191e3c6 100644 --- a/src/CollectionIdentifier_TEST.cc +++ b/src/CollectionIdentifier_TEST.cc @@ -44,7 +44,6 @@ TEST(CollectionIdentifier, SetFields) ///////////////////////////////////////////////// /// \brief Unique Name -// See https://github.com/gazebosim/gz-fuel-tools/issues/231 TEST(CollectionIdentifier, UniqueName) { gz::fuel_tools::ServerConfig srv1; @@ -69,6 +68,32 @@ TEST(CollectionIdentifier, UniqueName) EXPECT_EQ("https://localhost:8003/alice/collections/hello", id.UniqueName()); } +///////////////////////////////////////////////// +/// \brief Unique Name +TEST(CollectionIdentifier, Url) +{ + gz::fuel_tools::ServerConfig srv1; + srv1.SetUrl(common::URI("https://localhost:8001", true)); + + gz::fuel_tools::ServerConfig srv2; + srv2.SetUrl(common::URI("https://localhost:8002", true)); + + gz::fuel_tools::ServerConfig srv3; + srv3.SetUrl(common::URI("https://localhost:8003", true)); + + CollectionIdentifier id; + id.SetName("hello"); + id.SetOwner("alice"); + id.SetServer(srv1); + EXPECT_EQ("https://localhost:8001/alice/collections/hello", id.Url().Str()); + + id.SetServer(srv2); + EXPECT_EQ("https://localhost:8002/alice/collections/hello", id.Url().Str()); + + id.SetServer(srv3); + EXPECT_EQ("https://localhost:8003/alice/collections/hello", id.Url().Str()); +} + ///////////////////////////////////////////////// /// \brief Copy constructor deep copies TEST(CollectionIdentifier, CopyConstructorDeepCopy) diff --git a/src/ModelIdentifier.cc b/src/ModelIdentifier.cc index 1eb42ede..8c428fe3 100644 --- a/src/ModelIdentifier.cc +++ b/src/ModelIdentifier.cc @@ -155,6 +155,16 @@ std::string ModelIdentifier::UniqueName() const this->dataPtr->name)); } +////////////////////////////////////////////////// +common::URI ModelIdentifier::Url() const +{ + return common::URI( + common::joinPaths(this->dataPtr->server.Url().Str(), + this->dataPtr->owner, + "models", + this->dataPtr->name), true); +} + ////////////////////////////////////////////////// std::string ModelIdentifier::Name() const { diff --git a/src/ModelIdentifier_TEST.cc b/src/ModelIdentifier_TEST.cc index deabbcd3..9b63bcdd 100644 --- a/src/ModelIdentifier_TEST.cc +++ b/src/ModelIdentifier_TEST.cc @@ -80,6 +80,32 @@ TEST(ModelIdentifier, UniqueName) EXPECT_EQ("localhost%3A8003/alice/models/hello", id.UniqueName()); } +///////////////////////////////////////////////// +/// \brief Url +TEST(ModelIdentifier, Url) +{ + gz::fuel_tools::ServerConfig srv1; + srv1.SetUrl(common::URI("https://localhost:8001", true)); + + gz::fuel_tools::ServerConfig srv2; + srv2.SetUrl(common::URI("https://localhost:8002", true)); + + gz::fuel_tools::ServerConfig srv3; + srv3.SetUrl(common::URI("https://localhost:8003", true)); + + ModelIdentifier id; + id.SetName("hello"); + id.SetOwner("alice"); + id.SetServer(srv1); + EXPECT_EQ("https://localhost:8001/alice/models/hello", id.Url().Str()); + + id.SetServer(srv2); + EXPECT_EQ("https://localhost:8002/alice/models/hello", id.Url().Str()); + + id.SetServer(srv3); + EXPECT_EQ("https://localhost:8003/alice/models/hello", id.Url().Str()); +} + ///////////////////////////////////////////////// /// \brief Copy constructor deep copies TEST(ModelIdentifier, CopyConstructorDeepCopy) diff --git a/src/WorldIdentifier.cc b/src/WorldIdentifier.cc index 02d36313..085fc611 100644 --- a/src/WorldIdentifier.cc +++ b/src/WorldIdentifier.cc @@ -91,6 +91,16 @@ std::string WorldIdentifier::UniqueName() const this->dataPtr->name)); } +////////////////////////////////////////////////// +gz::common::URI WorldIdentifier::Url() const +{ + return common::URI( + common::joinPaths(this->dataPtr->server.Url().Str(), + this->dataPtr->owner, + "worlds", + this->dataPtr->name), true); +} + ////////////////////////////////////////////////// std::string WorldIdentifier::Name() const { diff --git a/src/WorldIdentifier_TEST.cc b/src/WorldIdentifier_TEST.cc index 4e293f41..332e222f 100644 --- a/src/WorldIdentifier_TEST.cc +++ b/src/WorldIdentifier_TEST.cc @@ -72,6 +72,33 @@ TEST(WorldIdentifier, UniqueName) EXPECT_EQ("localhost%3A8003/alice/worlds/hello", id.UniqueName()); } +///////////////////////////////////////////////// +/// \brief Url +TEST(WorldIdentifier, Url) +{ + gz::fuel_tools::ServerConfig srv1; + srv1.SetUrl(gz::common::URI("https://localhost:8001/", true)); + + gz::fuel_tools::ServerConfig srv2; + srv2.SetUrl(gz::common::URI("https://localhost:8002", true)); + + gz::fuel_tools::ServerConfig srv3; + srv3.SetUrl(gz::common::URI("https://localhost:8003/", true)); + + WorldIdentifier id; + id.SetName("hello"); + id.SetOwner("alice"); + + id.SetServer(srv1); + EXPECT_EQ("https://localhost:8001/alice/worlds/hello", id.Url().Str()); + + id.SetServer(srv2); + EXPECT_EQ("https://localhost:8002/alice/worlds/hello", id.Url().Str()); + + id.SetServer(srv3); + EXPECT_EQ("https://localhost:8003/alice/worlds/hello", id.Url().Str()); +} + ///////////////////////////////////////////////// /// \brief Copy constructor deep copies TEST(WorldIdentifier, CopyConstructorDeepCopy) From db91a855fff9d975a9e59636414ba1008a3e50df Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Fri, 26 Jul 2024 12:17:16 -0500 Subject: [PATCH 2/3] Make CollectionIdentifier::UniqueName consistent (#430) Signed-off-by: Michael Carroll --- src/CollectionIdentifier.cc | 7 ++++--- src/CollectionIdentifier_TEST.cc | 14 +++++++------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/CollectionIdentifier.cc b/src/CollectionIdentifier.cc index 2ac1d5cf..d6c2f235 100644 --- a/src/CollectionIdentifier.cc +++ b/src/CollectionIdentifier.cc @@ -71,9 +71,10 @@ CollectionIdentifier::~CollectionIdentifier() = default; ////////////////////////////////////////////////// std::string CollectionIdentifier::UniqueName() const { - return common::joinPaths(this->dataPtr->server.Url().Str(), - this->dataPtr->owner, "collections", - this->dataPtr->name); + return common::copyToUnixPath(common::joinPaths( + uriToPath(this->dataPtr->server.Url()), + this->dataPtr->owner, "collections", + this->dataPtr->name)); } ////////////////////////////////////////////////// diff --git a/src/CollectionIdentifier_TEST.cc b/src/CollectionIdentifier_TEST.cc index 4191e3c6..633603a3 100644 --- a/src/CollectionIdentifier_TEST.cc +++ b/src/CollectionIdentifier_TEST.cc @@ -47,25 +47,25 @@ TEST(CollectionIdentifier, SetFields) TEST(CollectionIdentifier, UniqueName) { gz::fuel_tools::ServerConfig srv1; - srv1.SetUrl(common::URI("https://localhost:8001")); + srv1.SetUrl(common::URI("https://localhost:8001", true)); gz::fuel_tools::ServerConfig srv2; - srv2.SetUrl(common::URI("https://localhost:8002")); + srv2.SetUrl(common::URI("https://localhost:8002", true)); gz::fuel_tools::ServerConfig srv3; - srv3.SetUrl(common::URI("https://localhost:8003")); + srv3.SetUrl(common::URI("https://localhost:8003", true)); CollectionIdentifier id; id.SetName("hello"); id.SetOwner("alice"); id.SetServer(srv1); - EXPECT_EQ("https://localhost:8001/alice/collections/hello", id.UniqueName()); + EXPECT_EQ("localhost%3A8001/alice/collections/hello", id.UniqueName()); id.SetServer(srv2); - EXPECT_EQ("https://localhost:8002/alice/collections/hello", id.UniqueName()); + EXPECT_EQ("localhost%3A8002/alice/collections/hello", id.UniqueName()); id.SetServer(srv3); - EXPECT_EQ("https://localhost:8003/alice/collections/hello", id.UniqueName()); + EXPECT_EQ("localhost%3A8003/alice/collections/hello", id.UniqueName()); } ///////////////////////////////////////////////// @@ -149,7 +149,7 @@ TEST(CollectionIdentifier, AsString) std::string str = "Name: \n"\ "Owner: \n"\ - "Unique name: https://fuel.gazebosim.org/collections/\n" + "Unique name: fuel.gazebosim.org/collections/\n" "Server:\n" " URL: https://fuel.gazebosim.org\n" " Version: 1.0\n" From 9726ac5ec3299a7b13dc9d09db0edb1be08f9d96 Mon Sep 17 00:00:00 2001 From: "Addisu Z. Taddese" Date: Tue, 6 Aug 2024 19:16:34 -0500 Subject: [PATCH 3/3] Prepare for 9.1.0 (#432) Signed-off-by: Addisu Z. Taddese --- CMakeLists.txt | 2 +- Changelog.md | 26 ++++++++++++++++++++++++++ package.xml | 2 +- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 85374fe4..905e4084 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.5.1 FATAL_ERROR) #============================================================================ # Initialize the project #============================================================================ -project(gz-fuel_tools9 VERSION 9.0.3) +project(gz-fuel_tools9 VERSION 9.1.0) #============================================================================ # Find gz-cmake diff --git a/Changelog.md b/Changelog.md index f273c2f0..47e4f5ff 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,31 @@ ## Gazebo Fuel Tools 9.x +### Gazebo Fuel Tools 9.1.0 (2024-08-06) + +1. Make `CollectionIdentifier::UniqueName` consistent + * [Pull request #430](https://github.com/gazebosim/gz-fuel-tools/pull/430) + +1. Add Url accessor to Identifiers + * [Pull request #429](https://github.com/gazebosim/gz-fuel-tools/pull/429) + +1. Migrate curl_formadd from form API to mime API (deprecated in Ubuntu Noble) + * [Pull request #415](https://github.com/gazebosim/gz-fuel-tools/pull/415) + +1. Add package.xml + * [Pull request #408](https://github.com/gazebosim/gz-fuel-tools/pull/408) + +1. CLI for creating config.yaml + * [Pull request #413](https://github.com/gazebosim/gz-fuel-tools/pull/413) + +1. Clean all ASAN reported memory problems (curl related) + * [Pull request #416](https://github.com/gazebosim/gz-fuel-tools/pull/416) + +1. Add Private function to world identifier + * [Pull request #414](https://github.com/gazebosim/gz-fuel-tools/pull/414) + +1. Use config.yaml file from default cache location, if it exists + * [Pull request #410](https://github.com/gazebosim/gz-fuel-tools/pull/410) + ### Gazebo Fuel Tools 9.0.3 (2024-04-09) 1. Use relative install path for gz tool data diff --git a/package.xml b/package.xml index 38697e63..5c1887d2 100644 --- a/package.xml +++ b/package.xml @@ -2,7 +2,7 @@ gz-fuel_tools9 - 9.0.3 + 9.1.0 Gazebo Fuel Tools: Classes and tools for interacting with Gazebo Fuel Nate Koenig Apache License 2.0