Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge gz-fuel-tools9 ➡️ main #434

Merged
merged 4 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,32 @@

## 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
Expand Down
4 changes: 4 additions & 0 deletions include/gz/fuel_tools/CollectionIdentifier.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions include/gz/fuel_tools/ModelIdentifier.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions include/gz/fuel_tools/WorldIdentifier.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 14 additions & 3 deletions src/CollectionIdentifier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,20 @@ 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));
}

//////////////////////////////////////////////////
gz::common::URI CollectionIdentifier::Url() const
{
return common::URI(
common::joinPaths(this->dataPtr->server.Url().Str(),
this->dataPtr->owner,
"collections",
this->dataPtr->name), true);
}

//////////////////////////////////////////////////
Expand Down
41 changes: 33 additions & 8 deletions src/CollectionIdentifier_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,29 +44,54 @@ TEST(CollectionIdentifier, SetFields)

/////////////////////////////////////////////////
/// \brief Unique Name
// See https://github.com/gazebosim/gz-fuel-tools/issues/231
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());
}

/////////////////////////////////////////////////
/// \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());
}

/////////////////////////////////////////////////
Expand Down Expand Up @@ -124,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"
Expand Down
10 changes: 10 additions & 0 deletions src/ModelIdentifier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
26 changes: 26 additions & 0 deletions src/ModelIdentifier_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions src/WorldIdentifier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
27 changes: 27 additions & 0 deletions src/WorldIdentifier_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading