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

feat (jkube-kit/generator) : Add configuration option in BaseGenerator to add tags (#1188) #1462

Merged
merged 1 commit into from
May 6, 2022

Conversation

rohanKanojia
Copy link
Member

Description

Fix #1188

Right now there isn't a way to add tags to BuildConfiguration while
using zero config mode in generators. Adding a configuration field in
BaseGenerator which would expect comma separated tags which can be
picked up by Generator while building opinionated Image configuration

Signed-off-by: Rohan Kumar rohaan@redhat.com

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change
  • Chore (non-breaking change which doesn't affect codebase;
    test, version modification, documentation, etc.)

Checklist

@codecov
Copy link

codecov bot commented Apr 20, 2022

Codecov Report

Merging #1462 (1d626c6) into master (0401297) will increase coverage by 0.00%.
The diff coverage is 91.66%.

@@            Coverage Diff            @@
##             master    #1462   +/-   ##
=========================================
  Coverage     51.34%   51.34%           
  Complexity     3812     3812           
=========================================
  Files           458      458           
  Lines         20681    20692   +11     
  Branches       2807     2808    +1     
=========================================
+ Hits          10618    10624    +6     
- Misses         8947     8952    +5     
  Partials       1116     1116           
Impacted Files Coverage Δ
...pse/jkube/generator/api/support/BaseGenerator.java 66.37% <88.88%> (+1.56%) ⬆️
...se/jkube/generator/javaexec/JavaExecGenerator.java 91.66% <100.00%> (+0.07%) ⬆️
.../eclipse/jkube/generator/karaf/KarafGenerator.java 94.54% <100.00%> (+0.10%) ⬆️
...clipse/jkube/generator/webapp/WebAppGenerator.java 93.40% <100.00%> (+0.07%) ⬆️
...it/config/service/portforward/PortForwardTask.java 60.00% <0.00%> (-4.00%) ⬇️
...e/jkube/kit/config/service/PortForwardService.java 70.10% <0.00%> (-3.10%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0401297...1d626c6. Read the comment docs.

@rohanKanojia rohanKanojia marked this pull request as ready for review April 20, 2022 14:49
@rohanKanojia rohanKanojia requested review from sunix and manusa and removed request for sunix April 20, 2022 14:49
protected void addTagsFromConfig(BuildConfiguration.BuildConfigurationBuilder buildConfigurationBuilder) {
String commaSeparatedTags = getConfig(Config.TAGS);
if (StringUtils.isNotBlank(commaSeparatedTags)) {
String[] tags = commaSeparatedTags.split(",");
Copy link
Contributor

@adriannowak adriannowak Apr 21, 2022

Choose a reason for hiding this comment

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

Shouldn't we trim whitespaces here?

@@ -227,6 +231,14 @@ protected void addLatestTagIfSnapshot(BuildConfiguration.BuildConfigurationBuild
}
}

protected void addTagsFromConfig(BuildConfiguration.BuildConfigurationBuilder buildConfigurationBuilder) {
Copy link
Contributor

@adriannowak adriannowak Apr 23, 2022

Choose a reason for hiding this comment

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

Tags should be consistent with the requirements from https://docs.docker.com/engine/reference/commandline/tag/
A tag name must be valid ASCII and may contain lowercase and uppercase letters, digits, underscores, periods and dashes. A tag name may not start with a period or a dash and may contain a maximum of 128 characters.
Please consider adding into code and cover them with unit tests

Copy link
Member Author

Choose a reason for hiding this comment

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

Tag validation is currently by docker APIServer while processing tag request submitted by jkube.

Is it necessary to do validation again on our side?


| *tags*
| A comma separated list of additional tags you want to tag your image with
| `jkube.generator.tags`
Copy link
Member

Choose a reason for hiding this comment

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

Reminder to create a new Issue:

These property names are misleading, they should be renamed to:
jkube.generator.${generatorName}.tags or applicable

Then add a note indicating that the ${generatorName} placeholder should be changed

Copy link
Member

Choose a reason for hiding this comment

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

Or does it work without the generator?

Copy link
Member

Choose a reason for hiding this comment

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

The question was meant so that we tested it and create an issue, I'm not sure you did.
However, you have changed the documentation...

I'm sure that jkube.generator.from and others work when not specifying the generator name. We need to verify and make sure which properties need to be changed, and decide the approach.
Please, provide feedback before doing any action.

Copy link
Member Author

@rohanKanojia rohanKanojia May 6, 2022

Choose a reason for hiding this comment

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

You're right. In BaseGenerator there is a method getConfigWithFallback which checks system and project properties with given key for config field value:

https://github.com/eclipse/jkube/blob/0401297d4bcea783a94fc178af376c7a8a5a185d/jkube-kit/generator/api/src/main/java/org/eclipse/jkube/generator/api/support/BaseGenerator.java#L185

BaseGenerator config fields name, alias, from, fromMode, registry seems to be using getConfigWithFallback method so they seem to work with jkube.generator prefix with and without generator name.

add and tags(added in this PR) don't seems to be aligned with this approach. Right now they don't work with jkube.generator prefix and require generator name

Copy link
Member Author

Choose a reason for hiding this comment

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

I've reverted my doc changes and created #1489

Copy link
Member

@manusa manusa left a comment

Choose a reason for hiding this comment

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

See trimming comment

@manusa manusa marked this pull request as draft May 6, 2022 13:54
@manusa manusa marked this pull request as ready for review May 6, 2022 13:54
…r to add tags (eclipse-jkube#1188)

Right now there isn't a way to add tags to BuildConfiguration while
using zero config mode in generators. Adding a configuration field in
BaseGenerator which would expect comma separated tags which can be
picked up by Generator while building opinionated Image configuration

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
@sonarcloud
Copy link

sonarcloud bot commented May 6, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

92.9% 92.9% Coverage
0.0% 0.0% Duplication

@manusa manusa merged commit c6cca9e into eclipse-jkube:master May 6, 2022
@rohanKanojia rohanKanojia deleted the pr/generator-option-tags branch May 6, 2022 16:35
@manusa manusa added this to the 1.8.0 milestone May 23, 2022
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.

Add Support for specifying multiple tags in Zero Configuration mode
3 participants