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

runtime: ensure that the generated project uses the right camel version #413

Merged
merged 2 commits into from
Feb 8, 2019

Conversation

lburgazzoli
Copy link
Contributor

@lburgazzoli lburgazzoli commented Feb 6, 2019

Fixes #384

This is an interim solution until the runtime bits will be moved to Apache Camel as one of the supported platforms.

So far, the implementation works properly for integration running with Camel Main and not so well for Spring Boot ones as in such case transitive dependencies could introduce conflict among spring-boot versions.

What's left:

  • look-up camel catalog associated to the configured camel version
    • from embedded resource
    • from a custom resource
  • improve spring boot support
  • include additional catalogs by default (i.e. 2.22.x)

@lburgazzoli
Copy link
Contributor Author

@astefanutti do you mind doing a review ?

The list of impacted files is huge but that's because now the camel catalog is not more "global" but a function has been introduced to retrieve the one that matches the configured camel version (it always falls back to the default one if no matching catalog is found).

There is something still left I'll address in future PRs

for _, d := range ctx.Project.Dependencies[:] {
if a, ok := ctx.Request.Catalog.Artifacts[d.ArtifactID]; ok {
for _, item := range a.Dependencies {
if item.GroupID == "" || item.ArtifactID == "" {
Copy link
Member

Choose a reason for hiding this comment

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

Is that expected to have a dependency without a groupId and an artifactId?

continue
}
for _, item := range *a.Exclusions {
if item.GroupID == "" || item.ArtifactID == "" {
Copy link
Member

Choose a reason for hiding this comment

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

Is that expected to have an exclusion without a groupId and an artifactId?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

mh, I think it is a leftover for the testing phase, let me remove it

t.Exclusions = &exclusions
}

*t.Exclusions = append(*t.Exclusions, item)
Copy link
Member

Choose a reason for hiding this comment

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

Would be possible that the exclusion is already there and shouldn't be duplicated?

//
// post process dependencies
//
for _, d := range ctx.Project.Dependencies[:] {
Copy link
Member

Choose a reason for hiding this comment

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

Not sure [:] is necessary?

//
// Add dependencies from catalog
//
for _, d := range ctx.Project.Dependencies[:] {
Copy link
Member

Choose a reason for hiding this comment

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

Not sure [:] is necessary? I need to review my slices-fu so that may be a trick to work with adding items while iterating!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes [:] is because of the need to modify the underlying thing, I may be wrong too :)

continue
}

ctx.Project.AddDependency(item)
Copy link
Member

Choose a reason for hiding this comment

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

Are we sure it's correct to add dependencies while iterating on it?

@@ -149,5 +145,46 @@ func GenerateProject(ctx *builder.Context) error {
}
}

//
Copy link
Member

Choose a reason for hiding this comment

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

Wonder if that could be factored with the default builder?


catalogs = make(map[string]RuntimeCatalog)
}

// Runtime --
Copy link
Member

Choose a reason for hiding this comment

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

Comment is now wrong.

@@ -77,14 +78,15 @@ func (options *PublisherOptions) run(cmd *cobra.Command, args []string) {

started := options.StartWith == ""

keys := make([]string, 0, len(camel.Runtime.Artifacts))
for k := range camel.Runtime.Artifacts {
catalog := camel.Runtime(defaults.CamelVersion)
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't be p.Spec.Build.CamelVersion? I imagine it's the same physically, still may be better logically...

}

// Runtime --
func Runtime(camelVersion string) *RuntimeCatalog {
Copy link
Member

Choose a reason for hiding this comment

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

I wonder whether the logic should be reversed. From an end-user standpoint, being able to specify a version in the platform spec following semver, and best matching the corresponding catalog, instead of matching x.y.z version with catalog x.y or x. I would find it more logical, but just a thought :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes it make sense but I think it depends to the availability of different catalogs that we do not build by default now, do you mind rising an issue ?

@lburgazzoli
Copy link
Contributor Author

@astefanutti I've fixed your findings, the only letf over is the latest comment about semver & co which I'm gogin to address in a separate pr while working on #302

// Runtime --
var Runtime Catalog
func Runtime(camelVersion string) *RuntimeCatalog {
Copy link
Member

Choose a reason for hiding this comment

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

I wonder whether we should rename the method to something like RuntimeCatalog or Catalog?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

renamed to func Catalog(...) *RuntimeCatalog

@astefanutti
Copy link
Member

@lburgazzoli LGTM, just a nit-pick about the camel.Runtime method name.

@lburgazzoli
Copy link
Contributor Author

done

@lburgazzoli lburgazzoli merged commit f25d0c0 into apache:master Feb 8, 2019
@lburgazzoli lburgazzoli deleted the github-384 branch February 8, 2019 16:07
@lburgazzoli lburgazzoli removed the status/wip Work in progress label Feb 8, 2019
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.

None yet

2 participants