From 3f9c982d09ba748622013155c192302e6d57770a Mon Sep 17 00:00:00 2001 From: Sven Rebhan Date: Fri, 7 Jun 2024 17:03:33 +0200 Subject: [PATCH] Restrict initial project listing to only those available to the current user --- plugins/inputs/openstack/openstack.go | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/plugins/inputs/openstack/openstack.go b/plugins/inputs/openstack/openstack.go index 4152465226ace..35fd1a5d0dfaa 100644 --- a/plugins/inputs/openstack/openstack.go +++ b/plugins/inputs/openstack/openstack.go @@ -37,7 +37,6 @@ import ( "github.com/gophercloud/gophercloud/v2/openstack/identity/v3/projects" "github.com/gophercloud/gophercloud/v2/openstack/identity/v3/services" "github.com/gophercloud/gophercloud/v2/openstack/identity/v3/tokens" - "github.com/gophercloud/gophercloud/v2/openstack/identity/v3/users" "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/agents" "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/networks" "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/ports" @@ -251,17 +250,7 @@ func (o *OpenStack) Start(telegraf.Accumulator) error { } // We need the project to deliver a human readable name in servers - - // Get session token details and extract the user id in order to fetch their projects - // FIXME?: the provider object might already contain the user info - i haven't managed to find it - token := tokens.Get(context.TODO(), o.identity, provider.TokenID) - user, err := token.ExtractUser() - if err != nil { - return fmt.Errorf("unable to extract user from the obtained token: %w", err) - } - o.Log.Debug("obtained user: %+v", user) - - page, err = users.ListProjects(o.identity, user.ID).AllPages(ctx) + page, err = projects.ListAvailable(o.identity).AllPages(ctx) if err != nil { return fmt.Errorf("unable to list projects: %w", err) }