Skip to content

Conversation

@abayer
Copy link
Member

@abayer abayer commented Jul 10, 2017

Yes, this is admittedly kind of a shortcut for a combination of
readProperties and withEnv, but hey, no harm in simplification.

Also moved to newer versions of various dependencies because I wanted
to use modern stuff and style.

cc @reviewbybees

Yes, this is admittedly kind of a shortcut for a combination of
readProperties and withEnv, but hey, no harm in simplification.

Also moved to newer versions of various dependencies because I wanted
to use modern stuff and style.
@abayer abayer requested review from batmat, jtnord and rsandell July 10, 2017 15:38
@ghost
Copy link

ghost commented Jul 10, 2017

This pull request originates from a CloudBees employee. At CloudBees, we require that all pull requests be reviewed by other CloudBees employees before we seek to have the change accepted. If you want to learn more about our process please see this explanation.

<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.609.1</version>
<version>2.29</version> <!-- TODO: Move to 2.31 or later once https://youtrack.jetbrains.com/issue/IDEA-175538 is resolved -->
Copy link
Member

Choose a reason for hiding this comment

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

please make pom version bumps in a separate PR, since there are more to it than just bumping the versions.
For example in the same swoop I wan't to get rid of all the @Inject et.al. stuff. And have this plugin be as much of a model example of how to do pipeline steps as possible.

Copy link
Member Author

Choose a reason for hiding this comment

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

nod. I'll do that first and redo this on top of it.

Copy link
Member

Choose a reason for hiding this comment

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

See #36

static Map<String,String> toStringMap(@Nonnull Map<String,Object> inMap) {
Map<String,String> result = new TreeMap<>();
for (Map.Entry<String,Object> e : inMap.entrySet()) {
result.put(e.getKey(), e.getValue().toString());
Copy link
Member

Choose a reason for hiding this comment

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

e.getValue() could return null. Use String.valueOf(e.getValue()) instead, unless that returns the string "null":)

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch.


if (!StringUtils.isBlank(step.getText())) {
result.putAll(ConfReaderUtils.toStringMap(ConfReaderUtils.readProperties(step.getText(),
step.getDefaults())));
Copy link
Member

Choose a reason for hiding this comment

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

The "defaults" here should be the result of reading the file iirc.

Copy link
Member

Choose a reason for hiding this comment

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

Otherwise you'll risk overwriting what was read from disk with what was specified as defaults

Copy link
Member Author

Choose a reason for hiding this comment

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

Okiedokie.

public static class DescriptorImpl extends StepDescriptor {
@Override
public String getFunctionName() {
return "propertiesWrapper"; // TODO: Probably a better name is needed
Copy link
Member

Choose a reason for hiding this comment

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

withProperties?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice!

public abstract class AbstractPropertiesStep extends Step {
public abstract String getFile();

public abstract void setFile(String file);
Copy link
Member

Choose a reason for hiding this comment

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

why having these 'abstract'? Would be less code duplication in the other classes if the fields and annotations where in this class instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

Durrr. Brain fart.

}
for (Map.Entry<Object, Object> entry : properties.entrySet()) {
result.put(entry.getKey() != null ? entry.getKey().toString(): null, entry.getValue());
result.putAll(ConfReaderUtils.readProperties(step.getText(), step.getDefaults()));
Copy link
Member

Choose a reason for hiding this comment

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

dito

@rsandell
Copy link
Member

@abayer also see #25

if (f.exists() && !f.isDirectory()) {
properties.load(f.read());
} else if (f.isDirectory()) {
logger.print("warning: ");
Copy link
Member

Choose a reason for hiding this comment

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

is it really just a warning? listener.error() ?

@batmat
Copy link
Member

batmat commented Aug 25, 2017

@abayer do you plan to have another look? That would be awesome, thanks!

@jetersen
Copy link
Member

jetersen commented Jan 16, 2018

@abayer I tried bumping the same dependencies to use some of the newer things but started fighting the upper bound requirements and got stuck unable to run unit tests. 😭

@batmat
Copy link
Member

batmat commented Jan 16, 2018

@abayer this is conflicted FYI.

Copy link
Member

@jglick jglick left a comment

Choose a reason for hiding this comment

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

Is this really necessary? Seems like something you can already write for yourself without a lot of hassle.

@batmat
Copy link
Member

batmat commented Feb 6, 2018

@jglick well I can show you the code we wrote for that, maybe this can be simplified, but right now I think this is a bit too complicated for what it does. Also Declarative is IMO about making things work as much OOTB as possible nicely and concisely in an expressive way. And that feature would look like definitely contributing to this.

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.

6 participants