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

Resolve bundle digests when DepV2 is enabled #3071

Merged
merged 4 commits into from
May 16, 2024

Conversation

kichristensen
Copy link
Contributor

What does this change

When Dependencies V2 is enable bundle dependencies with a default bundle reference will be resolved to digests.

What issue does it fix

Closes #2676

Notes for the reviewer

Checklist

  • Did you write tests?
  • Did you write documentation?
  • Did you change porter.yaml or a storage document record? Update the corresponding schema file.
  • If this is your first pull request, please add your name to the bottom of our Contributors list. Thank you for making Porter better! 🙇‍♀️

Signed-off-by: Kim Christensen <kimworking@gmail.com>
func (p *Porter) resolveDependencyDigest(ctx context.Context, e *yaml.Editor, opts cnabtooci.RegistryOptions) error {
// find all referenced dependencies that does not have digest specified
// get the digest for all of them and update the manifest with the digest
return e.WalkNodes(ctx, "dependencies.requires.*", func(ctx context.Context, nc *yqlib.NodeContext) error {
Copy link
Member

Choose a reason for hiding this comment

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

My only concern is

  1. Should we resolve dependencies that aren't required (I feel yes?) - and:
  2. Are there any concerns with this and "shared dependencies", where the dependency is already installed and running (I think this should be okay)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. I'm not sure I fully understand what you mean with "dependencies not required"
  2. I think it should be okay too, but I will create a test to verify it. It makes sense long term anyway

Copy link
Contributor Author

@kichristensen kichristensen Apr 11, 2024

Choose a reason for hiding this comment

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

@schristoff Number 2 Should be covered by the existing integration for shared dependencies,

func TestSharedDependencies(t *testing.T) {

Do you agree?

return e.WriteFile(build.LOCAL_MANIFEST)
}

func (p *Porter) resolveDependencyDigest(ctx context.Context, e *yaml.Editor, opts cnabtooci.RegistryOptions) error {
Copy link
Member

Choose a reason for hiding this comment

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

Could this be reworked to leverage existing dependency resolution logic? - moving this into "validate" logic may help us reduce LOC and improve efficiency :)

})
if err != nil {
return err
}

if p.IsFeatureEnabled(experimental.FlagDependenciesV2) {
Copy link
Member

Choose a reason for hiding this comment

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

Same as below (?) - I would love to see this moved into here - we can use this too :)

Copy link
Member

@schristoff schristoff left a comment

Choose a reason for hiding this comment

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

Thank you for working on this. I've taken a stab at it before but would get sidetracked. I would love to see it using the validate() logic, which makes this a little straightforward but long term could improve efficiency and be more "predictable" in placement.

@kichristensen
Copy link
Contributor Author

kichristensen commented Apr 11, 2024

Thank you for working on this. I've taken a stab at it before but would get sidetracked. I would love to see it using the validate() logic, which makes this a little straightforward but long term could improve efficiency and be more "predictable" in placement.

@schristoff Are you suggesting to use validate() to do the digest replacement? Or are you suggesting to not do the replacement in the file, but only in memory during validate()? Or something else?

Copy link
Member

@schristoff schristoff left a comment

Choose a reason for hiding this comment

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

We've have a lot of conversations about this, but ultimately my forgetfulness has been holding this PR up. Let's just merge it and if I ever remember, I can refactor.

@schristoff schristoff merged commit 2bb8be0 into getporter:main May 16, 2024
15 checks passed
@kichristensen kichristensen deleted the bundleDigest branch May 20, 2024 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Resolve dependency digests during build
2 participants