New flatten buildpacks/builder implementation - Part 2 - Implementing RFC-0123#1985
Conversation
During builder creation, end-users can provide the flag `--flatten` with the buildpacks they want to put in one layer. Signed-off-by: Juan Bustamante <jbustamante@vmware.com>
natalieparellano
left a comment
There was a problem hiding this comment.
@jjbustamante apologies for being so slow to review this one. In general it looks good to me - I made some suggestions to potentially help readability but otherwise it looks like it does what it's supposed to do. It might make sense to add an acceptance test if we don't have one already.
| type ModuleInfos interface { | ||
| BuildModule() []dist.ModuleInfo | ||
| } | ||
|
|
||
| type FlattenModuleInfos interface { | ||
| FlattenModules() []ModuleInfos | ||
| } |
There was a problem hiding this comment.
Is there any way to combine these two interfaces? Is there a reason for them to be different?
There was a problem hiding this comment.
It is actually a way of having a two dimensional array.
FlattenModules() -> return an array of ModuleInfos where each element is an array of dist.ModuleInfo
Signed-off-by: Juan Bustamante <jbustamante@vmware.com>
Signed-off-by: Juan Bustamante <jbustamante@vmware.com>
Signed-off-by: Juan Bustamante <juan.bustamante@broadcom.com>
Signed-off-by: Juan Bustamante <jbustamante@vmware.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1985 +/- ##
==========================================
+ Coverage 79.49% 79.63% +0.15%
==========================================
Files 175 176 +1
Lines 13135 13199 +64
==========================================
+ Hits 10440 10510 +70
+ Misses 2026 2020 -6
Partials 669 669
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
| return bldr, nil | ||
| } | ||
|
|
||
| func FlattenAll() BuilderOption { |
There was a problem hiding this comment.
FlattenAllcame from my first pull request (see Part 1)- Because the RFC is changing the
pack builder createinterface, now the end-user must define which buildpacks must be flatten together, that's why I found more readable to useWithFlattenas name to the option method
| return b.additionalExtensions | ||
| } | ||
| return &buildpack.ManagedCollection{} | ||
| return nil |
There was a problem hiding this comment.
I think I should return an managedCollectionV1 instance here.
| BuilderTomlPath string | ||
| Registry string | ||
| Policy string | ||
| FlattenExclude []string |
There was a problem hiding this comment.
The --flaten-exclude flag is being removed according to the RFC
natalieparellano
left a comment
There was a problem hiding this comment.
Nice work @jjbustamante. I left a few more nits - I think it could be helpful to add some more tests, but overall this is looking good.
Signed-off-by: Juan Bustamante <jbustamante@vmware.com>
Signed-off-by: Juan Bustamante <jbustamante@vmware.com>
Signed-off-by: Juan Bustamante <jbustamante@vmware.com>
Signed-off-by: Juan Bustamante <jbustamante@vmware.com>
|
@natalieparellano .. if you can take one more look will be awesome |
Signed-off-by: Juan Bustamante <jbustamante@vmware.com>
Summary
This PR implements RFC-0123.
The main idea can be summarize with the following class diagram:
classDiagram ManagedCollection <|-- managedCollection managedCollection <|-- managedCollectionV1 managedCollection <|-- managedCollectionV2 class ManagedCollection { <<interface>> } ModuleInfo --* ModuleInfos ModuleInfos --* FlattenModuleInfos managedCollectionV2 -- FlattenModuleInfos class ModuleInfo { FullName() string } class ModuleInfos { <<interface>> BuildModule() []dist.ModuleInfo } class FlattenModuleInfos { <<interface>> FlattenModules() []ModuleInfos } class managedCollection { +AllModules() +ExplodedModules() +FlattenedModules() +ShouldFlatten() } class managedCollectionV1 { +AddModules() } class managedCollectionV2 { +AddModules() }Our first attempt to implement the flatten feature added a ManagedCollection structure, I extracted the methods to a new interface.
managedCollectionis a base implementation with all the common code for each implementation. The idea was to keep our initial implementation on managedCollectionV1 and implement the new behavior withmanagedCollectionV2.According to the RFC, the user is responsible of defining which buildpacks they want to flatten. In order to represent this we added the
FlattenModuleInfosinterface. It is a two dimensional array with the group of modules we want to put together.managedCollectionV2usesFlattenModuleInfosto determine how to flatten the modules when they are added.Output
Before
After
Documentation
Related
Resolves #1880