Skip to content
This repository has been archived by the owner on Oct 10, 2023. It is now read-only.

Add second tag for spring framework #169

Merged
merged 8 commits into from
Apr 11, 2023

Conversation

thepetk
Copy link
Collaborator

@thepetk thepetk commented Apr 2, 2023

What does this PR do?

Adds a second item inside the SpringDetector.GetSupportedFrameworks func. As a result, when the Spring Boot framework is identified inside a project, it adds two tags inside the language.Frameworks

func (s SpringDetector) GetSupportedFrameworks() []string {
	return []string{"Spring", "Spring Boot"}
}

func (s SpringDetector) DoFrameworkDetection(language *model.Language, config string) {
	if hasFwk, _ := hasFramework(config, "org.springframework"); hasFwk {
		language.Frameworks = append(language.Frameworks, s.GetSupportedFrameworks()...)
	}
}

Finally, it will be able to match the given tag of "Spring Boot" whenever it is updated from the registry side. Note, that this solution is backwards compatible. Once the update of the "Spring" tag to "Spring Boot" is done, we can iterate and have only "Spring Boot" as supported network.

Which issue(s) this PR fixes:

fixes #136

Test outputs

I've forced updated locally the tag "Spring" to "Spring Boot" and tested this solution:

// go/pkg/apis/recognizer/devfile_recognizer.go#L151
for _, tag := range devFile.Tags {
  if tag == "Spring" {
	  tag = "Spring Boot"
  }
  if frw := matches(language.Frameworks, tag); frw != "" {
	  frameworkPerDevfileTmp[frw] = nil
	  score += utils.FRAMEWORK_WEIGHT
  }
  if matches(language.Tools, tag) != "" {
	  score += utils.TOOL_WEIGHT
  }
}

And the output is:

[
	{
		"Name": "java-springboot",
		"Language": "Java",
		"ProjectType": "springboot",
		"Tags": [
			"Java",
			"Spring"
		]
	}
]

Signed-off-by: thepetk <thepetk@gmail.com>
@thepetk thepetk requested review from yangcao77 and mike-hoang April 2, 2023 16:28
@thepetk thepetk self-assigned this Apr 2, 2023
Copy link
Collaborator

@yangcao77 yangcao77 left a comment

Choose a reason for hiding this comment

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

Can we add a unit test for this change?

Signed-off-by: thepetk <thepetk@gmail.com>
@thepetk thepetk requested a review from yangcao77 April 3, 2023 09:50
@thepetk
Copy link
Collaborator Author

thepetk commented Apr 3, 2023

@yangcao77 I've updated the mocked values of getDevFileTypes in order to provide Spring Boot as tag

thepetk added 6 commits April 3, 2023 15:26
Signed-off-by: thepetk <thepetk@gmail.com>
Signed-off-by: thepetk <thepetk@gmail.com>
Signed-off-by: thepetk <thepetk@gmail.com>
Signed-off-by: thepetk <thepetk@gmail.com>
Signed-off-by: thepetk <thepetk@gmail.com>
Signed-off-by: thepetk <thepetk@gmail.com>
Copy link
Collaborator

@yangcao77 yangcao77 left a comment

Choose a reason for hiding this comment

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

Thanks for the change. Look good to me.

@thepetk thepetk merged commit db5b043 into redhat-developer:main Apr 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Alizer should support devfile tag as Spring Boot
2 participants