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

KOGITO-7579: Knative Workflow - Specify Kogito version #1114

Merged
merged 26 commits into from
Jul 27, 2022

Conversation

ljmotta
Copy link
Contributor

@ljmotta ljmotta commented Jul 21, 2022

JIRAS

KOGITO-7579: Specify Kogito version
KOGITO-7485: macOS ARM build
KOGITO-7573: Verify image name
KOGITO-7607: Use Maven instead of Maven wrapper

On this PR

This PR adds the possibility to tweak the Kogito and Quarkus versions. Also, it adds some general improvements:

  • Removed the use of the mvnw and mvnw.cmd.
  • Check image name during build.
  • Build improvements:
    • Added macOS ARM cross-compilation.
    • Simplified staging and release build.

Specify Kogito and Quarkus version

During the project creation, it's possible to pass a --quarkus-version or the --kogito-version flags in the create command to set a specific Quarkus version and a Kogito version for the project.

The create command now generates a workflow.config.yml file containing the versions, and those versions can be tweaked at any time.

New commands

  • version
    Show the plugin version:
kn workflow version
  • config
    Tweak the config file and apply those changes in the pom.xml:
kn workflow config --quarkus-version=2.10.0.Final --kogito-version=1.24.0.Final

Apply manual changes in the pom.xml:

kn workflow config --apply

@ljmotta
Copy link
Contributor Author

ljmotta commented Jul 22, 2022

Hi @spolti ! I've added you as a reviewer as I think you can add insightful feedback.

@ricardozanini If you could take a look too, it would be great.

@ljmotta ljmotta requested review from spolti and barboras7 July 22, 2022 12:02
Copy link
Member

@ricardozanini ricardozanini left a comment

Choose a reason for hiding this comment

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

Great work!

I might be missing something, but I'm missing the repository configuration. If the user sets the version like quarkus-redhat-000x, how will maven download it?

Copy link
Member

@spolti spolti left a comment

Choose a reason for hiding this comment

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

very nice, just a few things.

}

func RunExtensionCommand(verbose bool, extensionCommand string, friendlyMessages []string, extensions string) error {
command := exec.Command("mvn", extensionCommand, fmt.Sprintf("-Dextensions=%s", extensions))
Copy link
Member

Choose a reason for hiding this comment

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

how to check if the mvn is available in the path?

Copy link
Contributor Author

@ljmotta ljmotta Jul 22, 2022

Choose a reason for hiding this comment

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

Good catch. I should have checked the mvn and Java before the command starts with the CheckJavaDependencies function that is in the check.go file. I've forgotten to add this function call in the config command.

func checkImageName(name string) (err error) {
matched, err := regexp.MatchString("[a-z]([-a-z0-9]*[a-z0-9])?", name)
if !matched {
fmt.Println("ERROR: Image name should match [a-z]([-a-z0-9]*[a-z0-9])?")
Copy link
Member

Choose a reason for hiding this comment

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

Do you mind to add a example about what this regex should match? Users might find it difficult to read regex.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure

"github.com/spf13/cobra"
)

type ConfigCmdConfig struct {
Copy link
Member

Choose a reason for hiding this comment

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

maybe rename to CmdConfig only?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've adopt the "CmdConfig" name pattern. So the other commands names are "BuildCmdConfig", "CreateCmdConfig", etc. ConfigCmdConfig it's not pretty, but it's what it is for this case.

return nil
}

func runConfigCmdConfig(cmd *cobra.Command) (cfg ConfigCmdConfig, err error) {
Copy link
Member

Choose a reason for hiding this comment

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

maybe rename?

return
}

func getUpdateExtensionFriendlyMessages() []string {
Copy link
Member

Choose a reason for hiding this comment

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

isn't this duplicated?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. I'm going to centralize all messages, I think it's going to be better to maintain it.

@ederign
Copy link
Member

ederign commented Jul 22, 2022

" might be missing something, but I'm missing the repository configuration. If the user sets the version like quarkus-redhat-000x, how will maven download it?"

@ricardozanini , for now, to overcomplicate it, the user will have to have global settings configured. (This is probably the case if they use an RH distribution in their company).

@ljmotta
Copy link
Contributor Author

ljmotta commented Jul 25, 2022

@spolti Hi, I believe I've covered all raised topics, do you have any other additional comment?

@barboras7 Could you please take a look into this PR?

@barboras7
Copy link
Contributor

Hi @ljmotta,
sure. Sorry for the delay, Mondays are mostly meetings for me. I'm on it now!

Copy link
Contributor

@barboras7 barboras7 left a comment

Choose a reason for hiding this comment

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

Hi @ljmotta,
great work! I am leaving some minor comments below.

Also, one thing I noticed when testing the plugin manually:
When I create a project using kn workflow create --name myTesting, I am able to do so. However, when I want to build this, I need to use mytesting instead of myTesting to succeed. Do you think you could add a validation for project creation to avoid such issues?

QuarkusVersion: quarkusVersion,
KogitoVersion: kogitoVersion,
},
Version: version,
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be difficult in the future to understand what version is. Would it be possible to use a more specific variable name?

}

fmt.Println("✅ Quarkus extension was successfully add to the project")
fmt.Println("✅ Quarkus extension was successfully add to the project pom.xml")
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
fmt.Println("✅ Quarkus extension was successfully add to the project pom.xml")
fmt.Println("✅ Quarkus extension was successfully added to the project pom.xml")

return
}

// check if quarkus and kogito versions in the config file
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
// check if quarkus and kogito versions in the config file
// check if quarkus and kogito versions are in the config file

@ljmotta
Copy link
Contributor Author

ljmotta commented Jul 26, 2022

@barboras7 Sure thing. I'm going to add the validation and make the suggested changes. Thanks for reviewing.

@ljmotta
Copy link
Contributor Author

ljmotta commented Jul 26, 2022

@barboras7 Actually, after I've started making the changes, I've realized that adding this validation in the create command wouldn't be the ideal. The create command creates a local folder for the user and each user have their own organization. The build generates a container image, therefore has its own name limitations and patterns, and don't need to follow the folder/project name.

@barboras7
Copy link
Contributor

Thanks @ljmotta, I understand why you don't feel like the validation would be ideal. Maybe just a small suggestion - a log message at a warning level, when project name does not follow a correct image name pattern like To build an image, you need to use an image name matching the following regex .... or something similar. Anyway, that's just a suggestion. Great work! 🥳

@tiagobento tiagobento merged commit db857a3 into apache:main Jul 27, 2022
zdrapela pushed a commit to zdrapela/kie-tools that referenced this pull request Aug 8, 2022
* Parametrize Kogito version

* Remove versions from staging and release build, and minor fixes

* Add version and config file

* Use env to set a custom quarkus and kogito version

* Check env in main

* Fix env

* Add config file

* Create version env

* Extract file names to const

* Cross compile to arm (macOS M1)

* Add arm build script

* Fix readme

* Update the build extension version

* Minor tweaks

* Clean up

* Remove both build extensions

* Update dependencies versions in the config command

* Add apply option

* Update project version

* Bumb up golang version

* Update go.mod

* PR review

* Explain runAddExtension

* Review
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants