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

New module parameters live-<xyz> #249

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

Yavor16
Copy link
Contributor

@Yavor16 Yavor16 commented Jan 30, 2024

LMCROSSITXSADEPLOY-1187

@Yavor16
Copy link
Contributor Author

Yavor16 commented Jan 30, 2024

This PR must be merged at the same as the one in the multiapps-controller

return idleToLiveParameterPairs.entrySet()
.stream()
.filter(idleToLiveParameterPair -> replaceableString.contains(idleToLiveParameterPair.getKey()))
.findFirst()
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

they are resolved correctly

@IvanBorislavovDimitrov
Copy link
Contributor

General question, is this new resolver really needed?
Why the current PropertiesResolver does not do the trick?

Why are you resolving only the "config" section of the resource?

Copy link

sonarcloud bot commented Feb 20, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
27.3% Coverage on New Code (required ≥ 80%)
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarCloud

idea Catch issues before they fail your Quality Gate with our IDE extension SonarLint SonarLint

}

private String castToString(Object object) {
return String.valueOf(object);
Copy link
Contributor

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?

Copy link
Contributor

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";
Copy link
Contributor

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

Comment on lines +31 to +33
public Resource resolve() {
if (resource.getParameters()
.containsKey(RESOURCE_PARAMETER_KEY_CONFIG)) {
Copy link
Contributor

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}

Copy link
Contributor

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

Copy link
Contributor Author

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

Copy link
Contributor

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

Comment on lines +46 to +48
.forEach(this::resolveResourceParameter);
} else if (entry.getValue() instanceof String) {
resolveConfigParameter(entry);
Copy link
Contributor

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?

Comment on lines +23 to +25
public ResourceLiveParameterResolver(DeploymentDescriptor deploymentDescriptor, Resource resource,
Map<String, String> idleToLiveParameterPairs) {
this.deploymentDescriptor = deploymentDescriptor;
Copy link
Contributor

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

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.

4 participants