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

feat: add git repo fragments #19

Merged
merged 1 commit into from
Sep 17, 2024
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: 14 additions & 1 deletion gittyup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,14 @@ class GitOpsRepository:
url: str
branch: str


def get_device_type():
return subprocess.check_output(["tedge", "config", "get", "device.type"]).decode("utf-8").strip()
return (
subprocess.check_output(["tedge", "config", "get", "device.type"])
.decode("utf-8")
.strip()
)


class GittyUpClient:
"""GittyUp client
Expand Down Expand Up @@ -125,6 +131,8 @@ def on_message(self, client, userdata, message):

if status == "successful":
commit = (payload_dict.get("commit", ""),)
branch = (payload_dict.get("branch", ""),)
url = (payload_dict.get("url", ""),)
self.publish_tedge_command(message.topic, "")

event_payload = {
Expand All @@ -137,6 +145,8 @@ def on_message(self, client, userdata, message):
json.dumps(
{
"commit": commit,
"branch": branch,
"url": url,
}
),
retain=True,
Expand Down Expand Up @@ -261,6 +271,9 @@ def clone_or_pull_repo(repo: GitOpsRepository, clone_dir="repo") -> Optional[str
if profile.exists():
payload = json.loads(profile.read_text(encoding="utf-8"))
payload["commit"] = commit
payload["branch"] = repo.branch
payload["url"] = repo.url

cmd_id = f"gittyup-{int(time.time())}"
client.publish_tedge_command(
f"te/device/main///cmd/device_profile/{cmd_id}",
Expand Down