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

Maven plugin implementation #1049

Merged
merged 27 commits into from
May 24, 2021
Merged

Maven plugin implementation #1049

merged 27 commits into from
May 24, 2021

Conversation

andreaTP
Copy link
Contributor

@andreaTP andreaTP commented May 11, 2021

This is the first implementation of a Maven plugin to use with Cloudflow applications.

Note:

projectId: String,
version: String,
blueprintStr: String,
streamlets: Map[String, com.typesafe.config.Config],
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: avoiding fully qualified path name : see last comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

version: String,
blueprintStr: String,
streamlets: Map[String, com.typesafe.config.Config],
dockerImages: Map[String, String]): String = {
Copy link
Contributor

Choose a reason for hiding this comment

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

May be return a Try[String] instead of throwing exceptions ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The error messages are quite nice from Maven in case we directly throw exceptions!

Copy link
Contributor

Choose a reason for hiding this comment

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

But what happens if downstream fails to catch those nice exceptions ? :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

downstream fails to catch those nice exceptions

I'm expecting downstream to NOT catch those exceptions and to be propagated up to the JVM (which craches), this is the contract, isn't it?

Copy link
Contributor

@debasishg debasishg left a comment

Choose a reason for hiding this comment

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

some minor suggestions

projectId: String,
version: String,
blueprintStr: String,
streamlets: Map[String, com.typesafe.config.Config],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

version: String,
blueprintStr: String,
streamlets: Map[String, com.typesafe.config.Config],
dockerImages: Map[String, String]): String = {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The error messages are quite nice from Maven in case we directly throw exceptions!

core/cloudflow-it/kafka-cluster.yaml Outdated Show resolved Hide resolved
@andreaTP andreaTP marked this pull request as ready for review May 14, 2021 14:58
@andreaTP andreaTP changed the title Initial maven plugin implementation Maven plugin implementation May 14, 2021
val c = getClass().getClassLoader()
Thread.currentThread().setContextClassLoader(c)

val k = new KafkaContainer(tcutility.DockerImageName.parse("confluentinc/cp-kafka:5.4.3"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe externalize the image name ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Can the parse fail / throw exceptions ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not with a fixed string, if it succeeds once it succeed always I assume

Comment on lines 18 to 19
def getDescriptorsOrFail[T](descriptors: Iterable[(T, Try[RuntimeDescriptor])])(
error: String => Unit): Iterable[(T, RuntimeDescriptor)] = {
Copy link
Contributor

Choose a reason for hiding this comment

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

The function has no semantics of failure as part of its type signature. Should we name the function getDescriptorsOrFail or change it simply to getDescriptors ? It throws but usually we don't add that as a semantics in the name of the function. One option would be to change the signature to Try[Iterable[.. and wrap the exception in a Try ..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Those functions have been extracted all "as-is" from the sbt plugin.
This is not fresh new code being added to the code-base.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

also is good to throw the exception to the user in those cases, not much we can do with it.
By handling it gracefully we are going just to mask the original error

localFile
}

def createDirs(prefix: String): (Path, Path) = {
Copy link
Contributor

Choose a reason for hiding this comment

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

directory creation can fail. Should we do Try[(Path, Path)] ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This looks really aggressive defensive programming 😛
If directory creation fails I think is correct to send to the user a stack-trace with the original exception (that is what happens here)

@andreaTP
Copy link
Contributor Author

Blocked by the release of docker-maven-plugin 0.36.0:
fabric8io/docker-maven-plugin#1472

Copy link
Contributor

@debasishg debasishg left a comment

Choose a reason for hiding this comment

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

LGTM

.gitignore Outdated
@@ -59,6 +59,7 @@ binaries
.cache/
docs-source/test-ui-site.yml
output/
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is output dir in gitignore anyway?

* Copyright (C) 2021 Lightbend Inc. <https://www.lightbend.com>
*/

package com.lightbend.cloudflow.buildtool
Copy link
Contributor

Choose a reason for hiding this comment

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

why not stick with cloudflow as root package?

import scala.collection.JavaConverters._
import scala.util.Try

object CloudflowAggregator {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
object CloudflowAggregator {
object CloudflowProjectAggregator {

Copy link
Contributor

@RayRoestenburg RayRoestenburg left a comment

Choose a reason for hiding this comment

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

Some suggestions for the docs. We should also be a bit more clear about the fact that the user has to write their 'dockerfile in maven xml' at this point, as is shown in the examples, (and we likely need to improve this in the future)

@andreaTP andreaTP merged commit 4c5deb0 into master May 24, 2021
@andreaTP andreaTP deleted the initial-maven branch May 24, 2021 10: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.

None yet

3 participants