resource: make the populated registry available outside of server#18000
Closed
boxofrad wants to merge 1 commit into
Closed
resource: make the populated registry available outside of server#18000boxofrad wants to merge 1 commit into
boxofrad wants to merge 1 commit into
Conversation
Contributor
Author
|
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
JadhavPoonam
approved these changes
Jul 4, 2023
mkeeler
reviewed
Jul 11, 2023
| func NewTypeRegistry() resource.Registry { | ||
| registry := resource.NewRegistry() | ||
|
|
||
| demo.RegisterTypes(registry) |
Member
There was a problem hiding this comment.
Previously we only made these resources available in dev mode, should we still do the same thing?
Member
There was a problem hiding this comment.
Hmm, I guess dev mode is just another feature flag.
Member
There was a problem hiding this comment.
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
}
Contributor
|
Closing this PR as it's implemented in this PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.