-
Notifications
You must be signed in to change notification settings - Fork 162
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
Extract enumeration to it's own module #1554
Conversation
063a7da
to
c2d583a
Compare
Great that we're doing this, this is going to be super useful. I do have a few questions though.
|
Exactly, this will be odd and ugly but this is a first step π
We could totally ! this is actually a great idea so when we change the api those using tis facade would not have to much to change !
Yes, but as the interface is ugly that mean creating a filter (driftignore style) to do this.
yeah the filter thing passed to the newscanner does that and we could easily put some code doing the facade to transform the |
Codecov Report
@@ Coverage Diff @@
## main #1554 +/- ##
==========================================
+ Coverage 81.41% 83.05% +1.63%
==========================================
Files 442 172 -270
Lines 16215 5959 -10256
==========================================
- Hits 13202 4949 -8253
+ Misses 2687 870 -1817
+ Partials 326 140 -186
|
a2a673f
to
9b407ef
Compare
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.
Thanks for that awesome job π
I have on an aside note a lot of things to be fixed, but that could be done in other PR.
That one is bloated by tons of changes in pkg names, I tried to fix some but this still could lead to merge conflicts (I already rebased it an fixed two of them)
I've also let some comment about metadata, but I'm happy if we decide to merge that one and continue cleaning up the extraction in separated PRs.
TL;DR : nothing critical in my comments to the point that prevent a merge, so feel free to merge it ASAP if you feel comfortable with it @moadibfr
resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsAppAutoscalingTargetResourceType, func(res *resource.Resource) map[string]string { | ||
attrs := make(map[string]string) | ||
if v := res.Attributes().GetString("scalable_dimension"); v != nil && *v != "" { | ||
attrs["Scalable dimension"] = *v | ||
} | ||
return attrs | ||
}) |
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.
I don't get why we removed that from there, this is 100% related to driftctl and should not be in the enum lib.
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.
yeah we already had a chat about this. I was wondering where it fitted the best and decided not to move them (cause yeah how I did was move the whole package and then move back what should not be in the enum,eration package)
I think in the end I agree with that and we can move that back to driftctl. I think in the end enumeration will have no schema and metadata anyway...
resourceSchemaRepository.SetResolveReadAttributesFunc(AwsAppAutoscalingTargetResourceType, func(res *resource.Resource) map[string]string { | ||
return map[string]string{ | ||
"service_namespace": *res.Attributes().GetString("service_namespace"), | ||
"scalable_dimension": *res.Attributes().GetString("scalable_dimension"), | ||
} | ||
}) |
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.
I'm fine to remove that from here since it's related to the enumeration process, but I think that can also be removed from the enum lib and those fields could be set directly in the enumerator function.
I think we could drop metadata notion from the enum lib completley, let's do that in another PR I'll be happy to handle that.
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.
Yeah We should get rid of this but I did not wanted to make to many change in this PR and just move things around
} | ||
return attrs | ||
}) | ||
resourceSchemaRepository.SetFlags(AwsAppAutoscalingTargetResourceType, resource.FlagDeepMode) |
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.
Flags are 100% related to driftctl, we should keep them here
@@ -1,25 +1,12 @@ | |||
package aws | |||
|
|||
import "github.com/snyk/driftctl/pkg/resource" | |||
|
|||
const AwsAppAutoscalingTargetResourceType = "aws_appautoscaling_target" |
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.
I'm in flavor of keeping those const here for now, I think they will be moved under internal or even dropped in the future in the enum lib
resourceSchemaRepository.SetFlags(AwsRouteResourceType, resource.FlagDeepMode) | ||
} | ||
|
||
func CalculateRouteID(tableId, CidrBlock, Ipv6CidrBlock, PrefixListId *string) string { |
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.
I think this is used in a route expander middleware nope ? In my mind in the future the enum lib will mostly be under an internal/
pkg and will only expose List and Refresh methods. We should avoid to add too many coupling, it's IMO OK to have duplicated code here for that kind of stuff.
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.
not sure about this one but there are some place where we compute ID and that may be needed for driftctl too when middleware create it too.
I think I checked that it was used in the enum before moving it but I might be wrong for this one...
"github.com/snyk/driftctl/pkg/resource/google" | ||
) | ||
|
||
func InitMetadatas(remote string, |
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 is already done in remote.Activate()
, is that really usefull to call that manually ?
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 is not the same init. This one will add normalize function that only exists in driftctl so it cannot be call from the enumeration function
0b0f295
to
2a9c1a7
Compare
2a9c1a7
to
3c7a52b
Compare
Description
First step to extract enumeration as a new library. Enumeration is now in a package with no dependencies to driftctl package.