Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.

Commit 04d7b42

Browse files
NickCaomangelajo
authored andcommitted
Harmonize client config format with exporter config
1 parent 6c157b8 commit 04d7b42

9 files changed

Lines changed: 122 additions & 180 deletions

File tree

examples/soc-pytest/jumpstarter_example_soc_pytest/test_on_rpi4.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414

1515
log = logging.getLogger(__file__)
1616

17+
1718
class TestResource(JumpstarterTest):
18-
filter_labels = {"board":"rpi4"}
19+
filter_labels = {"board": "rpi4"}
1920

2021
@classmethod
2122
def teardown_class(cls):
@@ -52,8 +53,9 @@ def test_setup_device(self, client, console):
5253
try:
5354
client.dutlink.storage.write_local_file("image/images/latest.raw")
5455
except opendal.exceptions.NotFound:
55-
pytest.exit("No image found, please enter the image directory and run `make`, "
56-
"more details in the README.md")
56+
pytest.exit(
57+
"No image found, please enter the image directory and run `make`, " "more details in the README.md"
58+
)
5759
return
5860
client.dutlink.storage.dut()
5961
client.dutlink.power.on()
@@ -66,13 +68,15 @@ def test_setup_device(self, client, console):
6668
def test_tpm2_device(self, shell):
6769
shell.logfile_read = sys.stdout.buffer
6870

69-
lines = ["apt-get install -y tpm2-tools",
70-
"tpm2_createprimary -C e -c primary.ctx",
71-
"tpm2_create -G rsa -u key.pub -r key.priv -C primary.ctx",
72-
"tpm2_load -C primary.ctx -u key.pub -r key.priv -c key.ctx",
73-
"echo my message > message.dat",
74-
"tpm2_sign -c key.ctx -g sha256 -o sig.rssa message.dat",
75-
"tpm2_verifysignature -c key.ctx -g sha256 -s sig.rssa -m message.dat"]
71+
lines = [
72+
"apt-get install -y tpm2-tools",
73+
"tpm2_createprimary -C e -c primary.ctx",
74+
"tpm2_create -G rsa -u key.pub -r key.priv -C primary.ctx",
75+
"tpm2_load -C primary.ctx -u key.pub -r key.priv -c key.ctx",
76+
"echo my message > message.dat",
77+
"tpm2_sign -c key.ctx -g sha256 -o sig.rssa message.dat",
78+
"tpm2_verifysignature -c key.ctx -g sha256 -s sig.rssa -m message.dat",
79+
]
7680

7781
for line in lines:
7882
log.info(f"Running command: {line}")

jumpstarter/cli/client.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from jumpstarter.common.utils import launch_shell
77
from jumpstarter.config import (
88
ClientConfigV1Alpha1,
9-
ClientConfigV1Alpha1Client,
109
ClientConfigV1Alpha1Drivers,
1110
UserConfigV1Alpha1,
1211
)
@@ -105,9 +104,9 @@ def client_create(
105104

106105
config = ClientConfigV1Alpha1(
107106
name=name,
108-
client=ClientConfigV1Alpha1Client(
109-
endpoint=endpoint, token=token, drivers=ClientConfigV1Alpha1Drivers(allow=allow.split(","), unsafe=unsafe)
110-
),
107+
endpoint=endpoint,
108+
token=token,
109+
drivers=ClientConfigV1Alpha1Drivers(allow=allow.split(","), unsafe=unsafe),
111110
)
112111
ClientConfigV1Alpha1.save(config, out)
113112

@@ -158,7 +157,7 @@ def make_row(c: ClientConfigV1Alpha1):
158157
return {
159158
"CURRENT": "*" if current_name == c.name else "",
160159
"NAME": c.name,
161-
"ENDPOINT": c.client.endpoint,
160+
"ENDPOINT": c.endpoint,
162161
"PATH": str(c.path),
163162
}
164163

jumpstarter/config/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from .client import (
22
ClientConfigV1Alpha1,
3-
ClientConfigV1Alpha1Client,
43
ClientConfigV1Alpha1Drivers,
54
)
65
from .common import CONFIG_API_VERSION, CONFIG_PATH
@@ -18,6 +17,5 @@
1817
"UserConfigV1Alpha1",
1918
"UserConfigV1Alpha1Config",
2019
"ClientConfigV1Alpha1",
21-
"ClientConfigV1Alpha1Client",
2220
"ClientConfigV1Alpha1Drivers",
2321
]

jumpstarter/config/client.py

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,6 @@ class ClientConfigV1Alpha1Drivers(BaseModel):
3333
unsafe: bool = Field(default=False)
3434

3535

36-
class ClientConfigV1Alpha1Client(BaseModel):
37-
endpoint: str
38-
token: str
39-
drivers: ClientConfigV1Alpha1Drivers
40-
41-
4236
class ClientConfigV1Alpha1(BaseModel):
4337
CLIENT_CONFIGS_PATH: ClassVar[Path] = CONFIG_PATH / "clients"
4438

@@ -47,15 +41,19 @@ class ClientConfigV1Alpha1(BaseModel):
4741

4842
apiVersion: Literal["jumpstarter.dev/v1alpha1"] = Field(default="jumpstarter.dev/v1alpha1")
4943
kind: Literal["ClientConfig"] = Field(default="ClientConfig")
50-
client: ClientConfigV1Alpha1Client = Field(default_factory=ClientConfigV1Alpha1Client)
44+
45+
endpoint: str
46+
token: str
47+
48+
drivers: ClientConfigV1Alpha1Drivers
5149

5250
async def channel(self):
5351
credentials = grpc.composite_channel_credentials(
54-
ssl_channel_credentials(self.client.endpoint),
55-
grpc.access_token_call_credentials(self.client.token),
52+
ssl_channel_credentials(self.endpoint),
53+
grpc.access_token_call_credentials(self.token),
5654
)
5755

58-
return grpc.aio.secure_channel(self.client.endpoint, credentials)
56+
return grpc.aio.secure_channel(self.endpoint, credentials)
5957

6058
@contextmanager
6159
def lease(self, metadata_filter: MetadataFilter):
@@ -111,14 +109,12 @@ def try_from_env(cls):
111109
@classmethod
112110
def from_env(cls):
113111
return cls(
114-
client=ClientConfigV1Alpha1Client(
115-
endpoint=os.environ.get(JMP_ENDPOINT),
116-
token=os.environ.get(JMP_TOKEN),
117-
drivers=ClientConfigV1Alpha1Drivers(
118-
allow=_allow_from_env(),
119-
unsafe=os.environ.get(JMP_DRIVERS_ALLOW) == "UNSAFE",
120-
),
121-
)
112+
endpoint=os.environ.get(JMP_ENDPOINT),
113+
token=os.environ.get(JMP_TOKEN),
114+
drivers=ClientConfigV1Alpha1Drivers(
115+
allow=_allow_from_env(),
116+
unsafe=os.environ.get(JMP_DRIVERS_ALLOW) == "UNSAFE",
117+
),
122118
)
123119

124120
@classmethod

jumpstarter/config/exporter_test.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from jumpstarter.common import MetadataFilter
66

7-
from .client import ClientConfigV1Alpha1, ClientConfigV1Alpha1Client, ClientConfigV1Alpha1Drivers
7+
from .client import ClientConfigV1Alpha1, ClientConfigV1Alpha1Drivers
88
from .exporter import ExporterConfigV1Alpha1, ExporterConfigV1Alpha1DriverInstance
99

1010
pytestmark = pytest.mark.anyio
@@ -36,11 +36,9 @@ async def test_exporter_serve(mock_controller):
3636

3737
client = ClientConfigV1Alpha1(
3838
name="testclient",
39-
client=ClientConfigV1Alpha1Client(
40-
endpoint=mock_controller,
41-
token="dummy-client-token",
42-
drivers=ClientConfigV1Alpha1Drivers(allow=[], unsafe=True),
43-
),
39+
endpoint=mock_controller,
40+
token="dummy-client-token",
41+
drivers=ClientConfigV1Alpha1Drivers(allow=[], unsafe=True),
4442
)
4543

4644
async with create_task_group() as tg:

jumpstarter/testing/pytest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def test_setup_device(self, client, console):
3535
client.dutlink.power.on()
3636
```
3737
"""
38+
3839
@classmethod
3940
def setup_class(cls):
4041
try:
@@ -58,4 +59,3 @@ def teardown_class(cls):
5859
@pytest.fixture()
5960
def client(self):
6061
return self._client
61-

jumpstarter/testing/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
log = logging.getLogger(__name__)
44

5+
56
def wait_and_login(pexpect_console, username, password, prompt, timeout=240):
67
"""
78
Wait for login prompt and login

0 commit comments

Comments
 (0)