Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add checks to OpenSearch in auto-generated manifests. #519

Merged
merged 1 commit into from
Sep 17, 2021
Merged
Show file tree
Hide file tree
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: 14 additions & 1 deletion bundle-workflow/src/manifests_workflow/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,28 @@
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.

from manifests.manifest import Manifest


class Component:
def __init__(self, name, repo, snapshot=False):
def __init__(self, name, repo, snapshot=False, checks=[]):
self.name = name
self.git_repo = repo
self.snapshot = snapshot
self.checks = checks

@classmethod
def gradle_cmd(self, target, props={}):
cmd = [f"./gradlew {target}"]
cmd.extend([f"-D{k}={v}" for k, v in props.items()])
return " ".join(cmd)

def to_dict(self):
return Manifest.compact(
{
"name": self.name,
"repository": self.git_repo.url,
"ref": self.git_repo.ref,
"checks": self.checks,
}
)
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@

class ComponentOpenSearchMin(Component):
def __init__(self, repo, snapshot=False):
super().__init__("OpenSearch", repo, snapshot)
super().__init__(
"OpenSearch",
repo,
snapshot,
["gradle:publish", "gradle:properties:version"],
)

@classmethod
def get_branches(self):
Expand Down
8 changes: 1 addition & 7 deletions bundle-workflow/src/manifests_workflow/input_manifests.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,7 @@ def update(self, keep=False):
# TODO: copy OpenSearch and common-utils from the previous manifest
for component in main_versions[release_version]:
logging.info(f" Adding {component.name}")
data["components"].append(
{
"name": component.name,
"repository": component.git_repo.url,
"ref": component.git_repo.ref,
}
)
data["components"].append(component.to_dict())

manifest = InputManifest(data)
manifest_path = os.path.join(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,12 @@ def test_properties(self):
repo.output.return_value = "version=2.1"
component = ComponentOpenSearch("common-utils", repo, "1.1.0")
self.assertEqual(component.properties.get_value("version"), "2.1")

def test_to_dict(self):
repo = MagicMock(ref="ref", url="repo")
repo.output.return_value = "version=2.1"
component = ComponentOpenSearch("common-utils", repo, "1.1.0")
self.assertEqual(
component.to_dict(),
{"name": "common-utils", "ref": "ref", "repository": "repo"},
)
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,17 @@ def test_properties(self):
repo.output.return_value = "version=2.1"
component = ComponentOpenSearchMin(repo)
self.assertEqual(component.properties.get_value("version"), "2.1")

def test_to_dict(self):
repo = MagicMock(ref="ref", url="repo")
repo.output.return_value = "version=2.1"
component = ComponentOpenSearchMin(repo)
self.assertEqual(
component.to_dict(),
{
"checks": ["gradle:publish", "gradle:properties:version"],
"name": "OpenSearch",
"ref": "ref",
"repository": "repo",
},
)