Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a73aba935f | |||
| 948504bde2 |
@@ -31,7 +31,6 @@ from __future__ import annotations
|
||||
import dataclasses
|
||||
import json
|
||||
import secrets
|
||||
import socket
|
||||
import string
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
@@ -88,14 +87,6 @@ def bottle_identity(agent_name: str) -> str:
|
||||
return f"{slug}-{suffix}"
|
||||
|
||||
|
||||
def globalize_slug(slug: str) -> str:
|
||||
"""Return a globally-unique slug qualified with the current hostname.
|
||||
|
||||
Assumes slug is a value returned from mint_slug. Use wherever a slug
|
||||
must be unique across hosts (e.g. deploy-key titles)."""
|
||||
return f"{socket.gethostname()}-{slug}"
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class BottleMetadata:
|
||||
"""Persistent record of how a bottle was launched, written at
|
||||
@@ -349,7 +340,6 @@ __all__ = [
|
||||
"BottleMetadata",
|
||||
"agent_state_dir",
|
||||
"bottle_identity",
|
||||
"globalize_slug",
|
||||
"bottle_state_dir",
|
||||
"cleanup_state",
|
||||
"clear_preserve_marker",
|
||||
|
||||
@@ -13,7 +13,6 @@ import dataclasses
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from .bottle_state import globalize_slug
|
||||
from .errors import MissingEnvVarError
|
||||
from .log import info
|
||||
from .manifest import ManifestBottle, ManifestGitEntry
|
||||
@@ -47,7 +46,7 @@ def _provision_dynamic_key(
|
||||
owner_repo = entry.UpstreamPath
|
||||
if owner_repo.endswith(".git"):
|
||||
owner_repo = owner_repo[:-4]
|
||||
title = f"bot-bottle:{globalize_slug(slug)}:{entry.Name}"
|
||||
title = f"bot-bottle:{slug}:{entry.Name}"
|
||||
|
||||
info(f"provisioning deploy key for git-gate.repos[{entry.Name!r}]")
|
||||
key_id, private_key_bytes = provisioner.create(owner_repo, title)
|
||||
|
||||
@@ -6,7 +6,6 @@ Covers the pure `git_gate_render_gitconfig` renderer and the dynamic
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import socket
|
||||
import tempfile
|
||||
import types
|
||||
import unittest
|
||||
@@ -127,9 +126,8 @@ class TestProvisionDynamicKey(unittest.TestCase):
|
||||
self.assertEqual(b"PRIVATE-KEY-BYTES", key_file.read_bytes())
|
||||
id_file = Path(d) / "repo-deploy-key-id"
|
||||
self.assertEqual("kid123", id_file.read_text())
|
||||
# owner_repo had .git stripped; title carries globalize_slug(slug) + name
|
||||
hostname = socket.gethostname()
|
||||
self.assertEqual([("o/r", f"bot-bottle:{hostname}-myslug:repo")], fake.created)
|
||||
# owner_repo had .git stripped; title carries slug + name
|
||||
self.assertEqual([("o/r", "bot-bottle:myslug:repo")], fake.created)
|
||||
|
||||
def test_missing_token_raises(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as d, \
|
||||
|
||||
Reference in New Issue
Block a user