Skip to content
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

feat(Deletion Modes): Populate associated resources field in Manifest #1675

Conversation

nesmabadr
Copy link
Contributor

@nesmabadr nesmabadr commented Jul 10, 2024

Description

Changes proposed in this pull request:

  • Populate AssociatedResources field in the Manifest CR
  • Add unit and integration tests

Related issue(s)
Resolves #1651

@nesmabadr nesmabadr requested a review from a team as a code owner July 10, 2024 10:20
@kyma-bot kyma-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cla: yes Indicates the PR's author has signed the CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 10, 2024
@nesmabadr nesmabadr force-pushed the populate_managedResources_manifest branch from 77cf6d9 to 7eeab44 Compare July 10, 2024 13:40
@nesmabadr nesmabadr force-pushed the populate_managedResources_manifest branch from 5608512 to e1fb17f Compare July 10, 2024 14:32
@nesmabadr nesmabadr force-pushed the populate_managedResources_manifest branch from d006b2b to 3fe52f6 Compare July 10, 2024 19:49
@nesmabadr nesmabadr force-pushed the populate_managedResources_manifest branch from 99a0ecd to 30aea5f Compare July 10, 2024 20:48
@nesmabadr nesmabadr added the confirm/helm-update The author explicitly confirms that a Helm update is not needed or is taken care of label Jul 10, 2024
@nesmabadr nesmabadr force-pushed the populate_managedResources_manifest branch from 30aea5f to 2da5507 Compare July 10, 2024 20:58
@nesmabadr nesmabadr changed the title WIP: Populate associated resources field in Manifest feat(Deletion Modes): Populate associated resources field in Manifest Jul 11, 2024
@kyma-bot kyma-bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 11, 2024
@nesmabadr nesmabadr added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. confirm/helm-update The author explicitly confirms that a Helm update is not needed or is taken care of and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. confirm/helm-update The author explicitly confirms that a Helm update is not needed or is taken care of labels Jul 11, 2024
@nesmabadr nesmabadr force-pushed the populate_managedResources_manifest branch from 6f858df to dc59105 Compare July 11, 2024 11:59
@nesmabadr nesmabadr force-pushed the populate_managedResources_manifest branch from dc59105 to aef4158 Compare July 11, 2024 12:09
@lindnerby lindnerby self-assigned this Jul 11, 2024
@lindnerby lindnerby self-requested a review July 11, 2024 13:17
@nesmabadr nesmabadr force-pushed the populate_managedResources_manifest branch from 21e7ce2 to 9e1f073 Compare July 11, 2024 14:17
@kyma-bot kyma-bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 11, 2024
…fest

# Conflicts:
#	internal/manifest/spec_resolver.go
#	tests/integration/controller/kyma/manifest_test.go
@nesmabadr nesmabadr force-pushed the populate_managedResources_manifest branch from 9e1f073 to e8f6fdd Compare July 11, 2024 14:38
internal/manifest/parse.go Outdated Show resolved Hide resolved

"github.com/kyma-project/lifecycle-manager/api/v1beta2"
"github.com/kyma-project/lifecycle-manager/internal/manifest/filemutex"
"github.com/kyma-project/lifecycle-manager/pkg/ocmextensions"
"github.com/kyma-project/lifecycle-manager/pkg/img"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move this to internal instead of pkg? Maybe difficult due to usages in template_to_module which should also be moved

@@ -9,13 +9,31 @@ import (

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This package can also go to internal

CRDsLayer LayerName = "crds"
ConfigLayer LayerName = "config"
CRDsLayer LayerName = "crds"
AssociatedResourcesLayer LayerName = "associated-resources"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these consts are not used within this package

@@ -47,3 +58,24 @@ type (
)

type Layers []Layer

func PullLayer(ctx context.Context, imageRef string, keyChain authn.Keychain) (containerregistryv1.Layer, error) {
noSchemeImageRef := ocmextensions.NoSchemeURL(imageRef)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be moved down closer to actual usage

pkg/img/layer.go Show resolved Hide resolved
@@ -81,7 +92,7 @@ func (p *Parser) GenerateMandatoryModulesFromTemplates(ctx context.Context,
return modules
}

func (p *Parser) appendModuleWithInformation(module v1beta2.AvailableModule, kyma *v1beta2.Kyma,
func (p *Parser) appendModuleWithInformation(ctx context.Context, module v1beta2.AvailableModule, kyma *v1beta2.Kyma,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's refactor this part a bit!
The reason to pass modules list as arg here is to append to it. Appending can be done by consumer, let's change the result of this function to return only the module. and split responsibilities. Then this func also needs a new name.

Also we may try to move all the logic from p.newManifestFromTemplate() into a separate dependency, let's say a ManifestCreator that may be tested separately.

func (p *Parser) fetchAssociatedResourcesField(ctx context.Context, layer *img.OCI, version string) ([]string,
error,
) {
associatedResourcesLayer := v1beta2.ImageSpec{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creating this seems a bit redundant since the only value used for a dependency is layer.CredSecretSelector for the LookupKeyChain()

@nesmabadr nesmabadr force-pushed the populate_managedResources_manifest branch from a49921e to 8d83d22 Compare July 15, 2024 11:56
@nesmabadr nesmabadr closed this Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Indicates the PR's author has signed the CLA. confirm/helm-update The author explicitly confirms that a Helm update is not needed or is taken care of size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
3 participants