Conversation
829e518 to
c62358f
Compare
|
@tomponline this is ready for review when you have some time. It will likely conflict with #13298 so I'll need to rebase when that's merged. |
c62358f to
550d572
Compare
|
Rebased and ready for review. Thanks. |
550d572 to
7ee82c6
Compare
|
Ready for round two :) |
7ee82c6 to
ccf8b55
Compare
|
I've just pushed again as I realised when working on #13072 that I had missed some equality checks that should now be using the |
| if len(entityTypesFilter) == 0 && projectName == "" { | ||
| for _, dbEntityType := range entityTypes { | ||
| stmt := dbEntityType.AllURLs() | ||
| if stmt != "" { |
There was a problem hiding this comment.
Should an empty stmt be an error condition?
There was a problem hiding this comment.
Hmmm... for this one perhaps but not for URLsByProject for example, as not all entities are project specific.
The implementation of the "server" entityType in the cluster package returns an empty string for AllURLs because there is no database query should be run for it (the caller should know that it's /1.0).
Additionally, remove the "nolint" directive as this function is now in use. Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
The entity deletion triggers are now composed of a trigger name and the SQL for creating it. Signed-off-by: Mark Laing <mark.laing@canonical.com>
Create a map of `entity.TypeName` to `[]Entitlement` for entitlement validation. Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
…ument. Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
b009f89 to
d0b2b3d
Compare
|
@tomponline have rebased |
@tomponline @hamistao this is a much more concise entity type refactor that I think works much better. (Thanks Tom for the idea of keeping the types as they are, but storing them in a map the returns a struct/interface with relevant fields/methods). With this change, I think it should be easy to add the URL prefix classification by: 1. Adding a `PrefixMatch() []string` method to `typeImpl` that returns a slice of URL prefixes to match the entity type against. 2. Adding a function `MatchURLPrefix` which iterates over the `entityType` map, and iterates over the `PrefixMatch()` array for each `typeImpl`, then returns the entity type if `strings.HasPrefix(u.Path, prefix)`. Closes #13262 Closes #12928
Opening as a draft to get some feedback.
entity.Typehas been changed to an interface.entity.Instance,entity.Networkand so on. A variable is also defined for each entity type for ease of use (e.g.var TypeInstance = Instance{}).db/clusterpackage, theEntityTypetype is now a struct which embeds anentityTypeinterface, theentityTypeinterface embeds(shared/entity).Typeand has methods for returning SQL for each entity type.Name()function (e.g.entityType1.Name() == entityType2.Name(). I've added anEqualsmethod to theshared/entitypackage for this.In order to add a new entity type, one needs to implement the interface in the shared package following the same pattern, and add the entity type to the list of all entity types in that package. Afterwards, the interface in the database package must be implemented (with the shared entity type being embedded in the database type) and this type must also be added to the list in the database package.
Closes #12928