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

deps: Upgrade open-component-model/ocm to v0.4.0 #1808

Merged
merged 12 commits into from
Oct 31, 2023

Conversation

lindnerby
Copy link
Member

@lindnerby lindnerby commented Oct 18, 2023

Description

Changes proposed in this pull request:

  • Upgrade OCM archive and descriptor generation:
    • The archive was made inmutable in the latest version after archive creation so the order of descriptor and archive creation needed to change
    • Also many APIs have changed that needed to be adapted, especially repository base types
    • Registration of some repository can be removed, they are already registered as defaults in the library
  • Refactoring

Related issue(s)

@lindnerby lindnerby requested a review from a team as a code owner October 18, 2023 11:48
@kyma-bot kyma-bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Oct 18, 2023
@lindnerby lindnerby changed the title deps: Upgrade open-component-model/ocm to v0.4.1 deps: Upgrade open-component-model/ocm to v0.4.0 Oct 23, 2023
@kyma-bot kyma-bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Oct 24, 2023

cmd.CurrentStep.Success()
if cmd.opts.RegistryURL == "" {
return nil
Copy link
Contributor

Choose a reason for hiding this comment

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

return nil is not expected, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

It is, the flow just got inverted since this is the last step it can be skipped if there is no reg given

Copy link
Contributor

Choose a reason for hiding this comment

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

but if no regstry given, this create module command is meaningless, right? It can't push image to remote.

Copy link
Member Author

@lindnerby lindnerby Oct 31, 2023

Choose a reason for hiding this comment

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

i guess it's like this because the command could also be used for just persisting the archive locally to inspect layers? also the registry flag is also not mandatory which is weird if the command should be meaningless without it. i don't know the intentions/requirements when this command was implemented, but agree that this should have a second look at some point.
and it's not only the registry flow that seems inconsistent: also the generation of the template could be interesting to be used without registry for debugging purposes, but at the moment the flow ends there

@@ -111,10 +90,10 @@ func generateResources(log *zap.SugaredLogger, version string, credLabel []byte,
r.Input.Type = "file"
}

if len(credLabel) != 0 {
if len(credMatchLabels) != 0 {

Choose a reason for hiding this comment

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

I don't know why, but it looks strange to me, I'd prefer the following:

Suggested change
if len(credMatchLabels) != 0 {
if len(credMatchLabels) > 0 {

@@ -100,9 +100,7 @@ func (r *Remote) getCredentials(ctx cpi.Context) credentials.Credentials {
return creds
}

// See: github.com/open-component-model/ocm/pkg/contexts/credentials/repositories/dockerconfig/repository.go#IsEmptyAuthConfig()
Copy link
Member

@Tomasz-Smelcerz-SAP Tomasz-Smelcerz-SAP Oct 26, 2023

Choose a reason for hiding this comment

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

Maybe leave this comment? It indicates that the function is written as the one linked.

Copy link
Member Author

@lindnerby lindnerby Oct 30, 2023

Choose a reason for hiding this comment

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

The url results in not found, that's why I removed it.

}

// addSources adds the sources to the component descriptor. If the def.Source is a git repository
func addSources(cd *ocm.ComponentDescriptor, def *Definition, gitRemote string) error {
if strings.HasSuffix(def.Source, ".git") {

Choose a reason for hiding this comment

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

This condition was added as part of #1751. Is it still working?

Copy link
Member Author

@lindnerby lindnerby Oct 30, 2023

Choose a reason for hiding this comment

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

The overall flow of this adding of git source meta information is very illogical and needed some changes. One of these is I made this function explicit, see addGitSources

nil,
nil,
vfs.ModePerm,
)
if err != nil {

Choose a reason for hiding this comment

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

This check has no effect

if err := addSources(cd, def, gitRemote); err != nil {
return nil, err
}
file, err := archiveFs.Create("component-descriptor.yaml")

Choose a reason for hiding this comment

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

Maybe I am wrong, but it looks like it's bypassing the ocm functionality - in the previous version this file was created by the library, isn't it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes because of the newly introduced immutability the name and version on the descriptor must be passed before and the only way to achieve that we could find was by creating this intermediate descriptor

}

return archive, nil
defer file.Close()

Choose a reason for hiding this comment

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

I would move this even before file.Write in line 49.

if err != nil {
return err
}
descriptor.SetLabels([]ocmv1.Label{{

Choose a reason for hiding this comment

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

Why is this removed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Labels are added here:

credMatchLabels, err := CreateCredMatchLabels(registryCredSelector)

@kyma-bot kyma-bot added the lgtm Looks good to me! label Oct 31, 2023
@kyma-bot kyma-bot merged commit f6ad108 into kyma-project:main Oct 31, 2023
6 checks passed
@lindnerby lindnerby deleted the upgr-ocm branch October 31, 2023 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm Looks good to me! size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants