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

Support local deployment's param version matching #404

Merged
merged 5 commits into from
Sep 1, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import com.aws.iot.evergreen.util.CrashableFunction;
import com.aws.iot.evergreen.util.Pair;
import com.aws.iot.evergreen.util.Utils;
import com.vdurmont.semver4j.Requirement;
import com.vdurmont.semver4j.Semver;

import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -295,8 +297,12 @@ private Optional<DeploymentPackageConfiguration> getMatchingPackageConfigFromDep
String packageName,
String packageVersion) {
return document.getDeploymentPackageConfigurationList().stream()
.filter(packageConfig -> packageName.equals(packageConfig.getPackageName()) && packageVersion
.equals(packageConfig.getResolvedVersion())).findAny();
.filter(packageConfig ->
packageName.equals(packageConfig.getPackageName())
// TODO packageConfig.getResolvedVersion() should be strongly typed when created
&& Requirement.buildNPM(packageConfig.getResolvedVersion())
.isSatisfiedBy(new Semver(packageVersion, Semver.SemverType.NPM)))
.findAny();
Copy link
Contributor

Choose a reason for hiding this comment

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

Is findAny() still correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question. findAny and findFirst might both be correct, as a deployment doc could have multiple entries that satisfy the resolved version (which might change). Let's keep it for now I guess.

}

private Set<PackageParameter> resolveParameterValuesToUseWithCache(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ void GIVEN_deployment_with_parameters_set_WHEN_config_resolution_requested_THEN_
getSimpleParameterMap(TEST_INPUT_PACKAGE_A), TEST_INPUT_PACKAGE_A);

DeploymentPackageConfiguration rootPackageDeploymentConfig =
new DeploymentPackageConfiguration(TEST_INPUT_PACKAGE_A, true, "1.2", new HashMap<String, Object>() {{
new DeploymentPackageConfiguration(TEST_INPUT_PACKAGE_A, true, ">=1.2", new HashMap<String, Object>() {{
put("PackageA_Param_1", "PackageA_Param_1_value");
}});
DeploymentDocument document = DeploymentDocument.builder()
Expand Down