-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
resource: make the populated registry available outside of server #18000
Conversation
PR 18k! 🎉 |
Moves type registration to an exported method, so that the registry can be used within the CLI for HCL validation, and inside the agent HTTP server for endpoint generation.
854ae56
to
81fb575
Compare
func NewTypeRegistry() resource.Registry { | ||
registry := resource.NewRegistry() | ||
|
||
demo.RegisterTypes(registry) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously we only made these resources available in dev mode, should we still do the same thing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I guess dev mode is just another feature flag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This actually makes me wonder whether enablement based on flags should be a feature of the resource service.
type Registration struct {
// Type is the GVK of the resource type.
Type *pbresource.Type
// Proto is the resource's protobuf message type.
Proto proto.Message
// ACLs are hooks called to perform authorization on RPCs.
ACLs *ACLHooks
// Validate is called to structurally validate the resource (e.g.
// check for required fields).
Validate func(*pbresource.Resource) error
// Mutate is called to fill out any autogenerated fields (e.g. UUIDs).
Mutate func(*pbresource.Resource) error
// RequireDevMode being set to true will only allow usage of this resource when in dev mode.
RequireDevMode bool
// RequireExperiment will cause the resource to only be allowed to be used if the corresponding experiment flag is set.
RequireExperiment string
// In the future, we'll add hooks, the controller etc. here.
// TODO: https://github.com/hashicorp/consul/pull/16622#discussion_r1134515909
}
Closing this PR as it's implemented in this PR. |
Description
Moves type registration to an exported method, so that the registry can be used within the CLI for HCL validation, and inside the agent HTTP server for endpoint generation.
This does mean that we can no longer feature-flag the registration of experimental resource types, but I think that's fine, as long as the controller is still feature-flagged.