Skip to content

Commit 6615fc4

Browse files
authored
Fix IsIncludedOutOfTheBox to account for snapshots (#45)
1 parent e94a88c commit 6615fc4

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/Elastic.Stack.ArtifactsApi/Products/SubProduct.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,19 @@ public SubProduct(string subProject, Func<ElasticVersion, bool> isValid = null,
3535
public string GetExistsMoniker(ElasticVersion version) => _getExistsMoniker(version);
3636

3737
/// <summary>Whether the sub project is included in the distribution out of the box for the given version</summary>
38-
public bool IsIncludedOutOfTheBox(ElasticVersion version) =>
39-
ShippedByDefaultAsOf != null && version >= ShippedByDefaultAsOf;
38+
public bool IsIncludedOutOfTheBox(ElasticVersion version)
39+
{
40+
if (ShippedByDefaultAsOf is null)
41+
return false;
42+
43+
// When we are using a snapshot version of Elasticsearch compare on base version.
44+
// This ensures that when testing with a snapshot, we install plugins correctly.
45+
// e.g. When testing with 8.4.0-SNAPSHOT of elasticsearch, we don't expect to ingest-attachment,
46+
// added in-box in 8.4.0 to be installed.
47+
return version.ArtifactBuildState == ArtifactBuildState.Snapshot
48+
? version.BaseVersion() >= ShippedByDefaultAsOf.BaseVersion()
49+
: version >= ShippedByDefaultAsOf;
50+
}
4051

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

0 commit comments

Comments
 (0)