Skip to content

Commit

Permalink
Restrict initial project listing to only those available to the curre…
Browse files Browse the repository at this point in the history
…nt user
  • Loading branch information
srebhan committed Jun 10, 2024
1 parent c911e90 commit 3f9c982
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions plugins/inputs/openstack/openstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 3f9c982

Please sign in to comment.