This registers the ActionSets for each resource when the handler packages are initialized. This then allows other packages to retrieve the ActionSets for a given resource from the action package. The initial consumer of this will be the ratelimit package so that it can programmatically enumerate all of the valid combinations of a resource and action. This leaves a number of TODO to refactor the handler packages to also retrieve the action sets from the registered actions instead of using a package variable. This is left as a TODO since there is some inconsistencies in how these package variables are used between the handlers. For example a number of packages use a map of subtypes to ActionSets which is then used withing the handler implementation. Others use a map, but don't seem to use it at all. And others just use an ActionSet.
21 lines
790 B
Go
21 lines
790 B
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
package authmethods
|
|
|
|
import (
|
|
"github.com/hashicorp/boundary/internal/types/action"
|
|
"github.com/hashicorp/boundary/internal/types/resource"
|
|
"golang.org/x/exp/maps"
|
|
)
|
|
|
|
// init functions process in alphabetical order of filenames within a package.
|
|
// this needs to run last since it used the IdActions variable which gets
|
|
// modified in other init functions in this package.
|
|
func init() {
|
|
// TODO: refactor to remove IdActions and CollectionActions package variables
|
|
// Then this registration can happen in authmethod_service.go and we don't
|
|
// need to worry about the order of init functions in a package.
|
|
action.RegisterResource(resource.AuthMethod, action.Union(maps.Values(IdActions)...), CollectionActions)
|
|
}
|