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 553 resource level annotations #644

Merged

Conversation

iocanel
Copy link
Member

@iocanel iocanel commented Oct 1, 2020

Resolves: #553

This pull request introduces a new fields kinds on @Label and @Annotation. The use of these fields will limit the application of Labels/Annotations only to the listed kinds. If omitted, all kinds are asumed.

@iocanel iocanel requested a review from geoand October 1, 2020 04:47
Copy link
Collaborator

@geoand geoand left a comment

Choose a reason for hiding this comment

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

I would like to know what this means in terms of backward compatibility

Comment on lines +56 to +57
Arrays.asList(instance.labels()).stream().map(i -> new io.dekorate.kubernetes.config.Label(i.key(), i.value(),
i.kinds())).collect(Collectors.toList()).toArray(new io.dekorate.kubernetes.config.Label[0]),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Formatting looks messed up

Copy link
Member Author

Choose a reason for hiding this comment

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

Weird as we now use a maven plugin for formatiing. Will look closer.

Copy link
Member Author

Choose a reason for hiding this comment

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

Formatter is not used by default. I will address this in a separate issue.

@@ -25,9 +25,7 @@ public void testGeneratedCode() {
.withName("myapp")
.withVersion("1.0.0")
.withExpose(true)
.addNewLabel("key1", "val1")
.addNewLabel("key1", "val1", new String[0])
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we really need to do this? Can't the existing addNewLabel continue to exist?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, it can't.

Possible alternatives:

.addNewLabel().withKey("key1").withValue("val1").endLabel()

Given that this change is not user facing, I'd say its no biggie.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sure yeah, it just looks ugly

Copy link
Member Author

Choose a reason for hiding this comment

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

@geoand: The main thing with these methods is that they are generated.

The logic is the following:
if the object is flat and has less than five 5 fields generate a with method with all fields.

In theory we could create a method for each possible field combination. In the current case it would look like:

withNewLabel(String key);
withNewLabel(String key, String value); 
withNewlabel(String key, String value, String[] kinds);

However, this would mean that we would also get methods that don't make sense.
Now, since to original object is an annotation and fields without default values are considered mandatory we could possibly work soemthing out.

I think that this would be one or two days work. and I'd like to avoid it at the moment.
Created: sundrio/sundrio#177

Copy link
Member Author

Choose a reason for hiding this comment

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

@geoand if this sounds reasonable can we approve this?

@iocanel
Copy link
Member Author

iocanel commented Oct 1, 2020

I would like to know what this means in terms of backward compatibility

There will be no backwards compatibility, but will be forward compatibility (partially).
By partially I mean that dekorate user can upgrade without issues.
Downstream projects may need to perform minor changes.

So, most probably this will require a 0.13.0 release.

@geoand
Copy link
Collaborator

geoand commented Oct 1, 2020

CI seems to be failing

@iocanel iocanel force-pushed the feat-553-resource-level-annotations branch from 08afd82 to 74b374f Compare October 1, 2020 05:48
@sonarqubecloud
Copy link

sonarqubecloud bot commented Oct 1, 2020

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

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.

Array values in application.yml are not handled correctly. Support for resource level annotations
2 participants