Skip to content

Fix IsIncludedOutOfTheBox to account for snapshots #45

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

Merged
merged 1 commit into from
Jul 5, 2022
Merged
Changes from all 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
15 changes: 13 additions & 2 deletions src/Elastic.Stack.ArtifactsApi/Products/SubProduct.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,19 @@ public SubProduct(string subProject, Func<ElasticVersion, bool> isValid = null,
public string GetExistsMoniker(ElasticVersion version) => _getExistsMoniker(version);

/// <summary>Whether the sub project is included in the distribution out of the box for the given version</summary>
public bool IsIncludedOutOfTheBox(ElasticVersion version) =>
ShippedByDefaultAsOf != null && version >= ShippedByDefaultAsOf;
public bool IsIncludedOutOfTheBox(ElasticVersion version)
{
if (ShippedByDefaultAsOf is null)
return false;

// When we are using a snapshot version of Elasticsearch compare on base version.
// This ensures that when testing with a snapshot, we install plugins correctly.
// e.g. When testing with 8.4.0-SNAPSHOT of elasticsearch, we don't expect to ingest-attachment,
// added in-box in 8.4.0 to be installed.
return version.ArtifactBuildState == ArtifactBuildState.Snapshot
? version.BaseVersion() >= ShippedByDefaultAsOf.BaseVersion()
: version >= ShippedByDefaultAsOf;
}

/// <summary>Whether the subProject is valid for the given version</summary>
public bool IsValid(ElasticVersion version) => IsIncludedOutOfTheBox(version) || _isValid(version);
Expand Down