Add tags to the identity v3 project#1882
Add tags to the identity v3 project#1882jtopjian merged 5 commits intogophercloud:masterfrom randomswdev:add-project-tags
Conversation
|
Build failed.
|
|
I looked at the logs of the gophercloud-acceptance-test but I was unable to understand why the test failed. Is there anybody who can help me in locating the failure reasons? |
|
@randomswdev It's an issue at OpenLab - you can safely ignore |
|
@randomswdev could you please implement tags support for |
Looking at the rest api documentation, my understanding is that the project list api does not support filtering on tags. @kayrus Can you double check and let me know? In case I’ll add the tags to the ListOpts tomorrow morning. |
|
@randomswdev I think this is it if I'm not mistaken https://github.com/openstack/keystone/blob/fe39838f712880c336e18eadf320e7c9e2007448/keystone/api/projects.py#L130 |
|
I'm not a stickler for full API support. If it's convenient for you, feel free to add tag filtering support for listing. Otherwise, it can always be done in another PR. |
Added the suggested filters. Sorry for missing them, but the REST API documentation didn't mention them. |
|
Build failed.
|
There's no apology needed. Like I said, it wasn't a requirement to have these included. Thank you for your work on this. Let me know if this is ready for a code review. |
I think it is ready for review. |
jtopjian
left a comment
There was a problem hiding this comment.
@randomswdev Thank you for working on this.
There are two minor nits with the test fixtures. The larger comment has to do with the ability to remove all tags from a project.
In addition, we'll need to have the doc.go file updated to show examples of how to use these additions. And if possible, can you add some acceptance tests?
In my last two commits I added an acceptance test that executes few tag related operations and I updated doc.go |
|
Build failed.
|
|
Build failed.
|
|
@randomswdev Thanks! I had to make the following changes for the acceptance tests to work: --- a/acceptance/openstack/identity/v3/projects_test.go
+++ b/acceptance/openstack/identity/v3/projects_test.go
@@ -224,7 +224,7 @@ func TestProjectsTags(t *testing.T) {
for _, project := range allProjects {
tools.PrintResource(t, project)
- if project.Name == "admin" {
+ if project.Name == projectMain.Name {
found = true
}
}
@@ -259,7 +259,7 @@ func TestProjectsTags(t *testing.T) {
for _, project := range allProjects {
tools.PrintResource(t, project)
- if project.Name == "admin" {
+ if project.Name == projectMain.Name {
found = true
}
}
@@ -277,7 +277,16 @@ func TestProjectsTags(t *testing.T) {
allProjects, err = projects.ExtractProjects(allPages)
th.AssertNoErr(t, err)
- th.AssertEquals(t, len(allProjects), 0)
+ found = false
+ for _, project := range allProjects {
+ tools.PrintResource(t, project)
+
+ if project.Name == projectMain.Name {
+ found = true
+ }
+ }
+
+ th.AssertEquals(t, found, false)
// Search matching not all tags
listOpts = projects.ListOpts{
@@ -325,4 +334,15 @@ func TestProjectsTags(t *testing.T) {
tools.PrintResource(t, updatedProject)
th.AssertEquals(t, len(updatedProject.Tags), 1)
th.AssertEquals(t, updatedProject.Tags[0], "Tag1")
+
+ // Remove all Tags
+ updateOpts = projects.UpdateOpts{
+ Tags: &[]string{},
+ }
+
+ updatedProject, err = projects.Update(client, projectMain.ID, updateOpts).Extract()
+ th.AssertNoErr(t, err)
+
+ tools.PrintResource(t, updatedProject)
+ th.AssertEquals(t, len(updatedProject.Tags), 0)
}The last part is an addition to make sure that removing all tags is successful. Our OpenLab tests have also been fixed, so you'll be able to see the test output in the OpenLab logs. Let me know if you have any questions. |
Impemented the changes you suggested. I'm waiting for the tests to run and complete successfully. |
|
Build succeeded.
|
jtopjian
left a comment
There was a problem hiding this comment.
LGTM - thank you for your work on this!
For #1687
Links to the line numbers/files in the OpenStack source code that support the
code in this PR:
https://github.com/openstack/keystone/blob/fe39838f712880c336e18eadf320e7c9e2007448/keystone/api/projects.py#L111
https://github.com/openstack/keystone/blob/fe39838f712880c336e18eadf320e7c9e2007448/keystone/api/projects.py#L233
https://github.com/openstack/keystone/blob/fe39838f712880c336e18eadf320e7c9e2007448/keystone/api/projects.py#L265
https://github.com/openstack/keystone/blob/fe39838f712880c336e18eadf320e7c9e2007448/keystone/api/projects.py#L490
This pull request adds supports for assocaiting tags to projects using the idenetity v3 APIs. The tags are optional thua llowing backward compatibility with OpenStack versions older than Queens: it is enough to not specify tags when creating or updating a project.