-
Notifications
You must be signed in to change notification settings - Fork 27
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
New module parameters live-<xyz> #249
base: master
Are you sure you want to change the base?
Conversation
This PR must be merged at the same as the one in the multiapps-controller |
...src/main/java/org/cloudfoundry/multiapps/mta/resolvers/v2/DescriptorPlaceholderResolver.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/cloudfoundry/multiapps/mta/resolvers/v2/DescriptorPlaceholderResolver.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/cloudfoundry/multiapps/mta/resolvers/v2/DescriptorPlaceholderResolver.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/cloudfoundry/multiapps/mta/resolvers/v2/DescriptorPlaceholderResolver.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/cloudfoundry/multiapps/mta/resolvers/v2/DescriptorPlaceholderResolver.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/cloudfoundry/multiapps/mta/resolvers/v2/DescriptorPlaceholderResolver.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/cloudfoundry/multiapps/mta/resolvers/v2/DescriptorPlaceholderResolver.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/cloudfoundry/multiapps/mta/resolvers/v2/DescriptorPlaceholderResolver.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/cloudfoundry/multiapps/mta/resolvers/v2/DescriptorPlaceholderResolver.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/cloudfoundry/multiapps/mta/resolvers/v2/DescriptorPlaceholderResolver.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/cloudfoundry/multiapps/mta/resolvers/v2/DescriptorPlaceholderResolver.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/cloudfoundry/multiapps/mta/resolvers/v2/ResourceLiveParameterResolver.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/cloudfoundry/multiapps/mta/resolvers/v2/ResourceLiveParameterResolver.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/cloudfoundry/multiapps/mta/resolvers/v2/ResourceLiveParameterResolver.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/cloudfoundry/multiapps/mta/resolvers/v2/ResourceLiveParameterResolver.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/cloudfoundry/multiapps/mta/resolvers/v2/ResourceLiveParameterResolver.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/cloudfoundry/multiapps/mta/resolvers/v2/ResourceLiveParameterResolver.java
Show resolved
Hide resolved
...src/main/java/org/cloudfoundry/multiapps/mta/resolvers/v2/ResourceLiveParameterResolver.java
Show resolved
Hide resolved
return idleToLiveParameterPairs.entrySet() | ||
.stream() | ||
.filter(idleToLiveParameterPair -> replaceableString.contains(idleToLiveParameterPair.getKey())) | ||
.findFirst() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a style comment: What would happen if a parameter references 2 placeholders at once? e.g. '${default-host}-something-${default-uri}'; Not sure if this is even a real case but still
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
they are resolved correctly
...src/main/java/org/cloudfoundry/multiapps/mta/resolvers/v2/ResourceLiveParameterResolver.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/cloudfoundry/multiapps/mta/resolvers/v2/ResourceLiveParameterResolver.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/cloudfoundry/multiapps/mta/resolvers/v2/ResourceLiveParameterResolver.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/cloudfoundry/multiapps/mta/resolvers/v2/DescriptorPlaceholderResolver.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/cloudfoundry/multiapps/mta/resolvers/v2/ResourceLiveParameterResolver.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/cloudfoundry/multiapps/mta/resolvers/v2/ResourceLiveParameterResolver.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/cloudfoundry/multiapps/mta/resolvers/v2/ResourceLiveParameterResolver.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/cloudfoundry/multiapps/mta/resolvers/v2/ResourceLiveParameterResolver.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/cloudfoundry/multiapps/mta/resolvers/v2/ResourceLiveParameterResolver.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/cloudfoundry/multiapps/mta/resolvers/v2/DescriptorPlaceholderResolver.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/cloudfoundry/multiapps/mta/resolvers/v2/ResourceLiveParameterResolver.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/cloudfoundry/multiapps/mta/resolvers/v2/ResourceLiveParameterResolver.java
Show resolved
Hide resolved
General question, is this new resolver really needed? Why are you resolving only the "config" section of the resource? |
Quality Gate failedFailed conditions See analysis details on SonarCloud Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
...src/main/java/org/cloudfoundry/multiapps/mta/resolvers/v2/ResourceLiveParameterResolver.java
Show resolved
Hide resolved
...a/src/main/java/org/cloudfoundry/multiapps/mta/resolvers/v2/ResourcePlaceholderResolver.java
Show resolved
Hide resolved
} | ||
|
||
private String castToString(Object object) { | ||
return String.valueOf(object); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible to remove this method and use MiscUtils?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if not, you make create a static util method in MiscUtils
|
||
public class ResourceLiveParameterResolver implements Resolver<Resource> { | ||
|
||
private static final String RESOURCE_PARAMETER_KEY_CONFIG = "config"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's ok to resolve all of the parameters, not only config
public Resource resolve() { | ||
if (resource.getParameters() | ||
.containsKey(RESOURCE_PARAMETER_KEY_CONFIG)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need to require the module from the resource in order for this resolution to work?
I think in the internal example, there is a missing requires section:
modules:
- name: foo
path: ./ui5Provider/buildresults.zip
type: custom
provides:
- name: foo
properties:
url: ~{default-url}
resources:
- name: bar
type: org.cloudfoundry.managed-service
requires:
- name: foo
parameters:
service: finch
service-plan: white
config:
foo-url: ~{foo/url}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And if there is no requires to the provider module we should fail
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will fail. If we don't fail here the next steps fails for sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have a check if the module is really required, and fail with a descriptive message
.forEach(this::resolveResourceParameter); | ||
} else if (entry.getValue() instanceof String) { | ||
resolveConfigParameter(entry); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What will happen if this is an Array?
public ResourceLiveParameterResolver(DeploymentDescriptor deploymentDescriptor, Resource resource, | ||
Map<String, String> idleToLiveParameterPairs) { | ||
this.deploymentDescriptor = deploymentDescriptor; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also do not see if the resource properties are getting resolved?
A resource can have properties that are getting injected in env of the module that requires it
LMCROSSITXSADEPLOY-1187