Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 1 addition & 5 deletions python/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,4 @@ lint-fix:

.PHONY: default help pkg-test-all pkg-ty-all build generate sync \
clean clean-venv clean-build clean-test test test-report ty \
lint lint-fix \
pkg-ty-jumpstarter \
pkg-ty-jumpstarter-cli-admin \
pkg-ty-jumpstarter-kubernetes \
pkg-ty-jumpstarter-protocol
lint lint-fix
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from jumpstarter_imagehash import ImageHash
from jumpstarter_testing.pytest import JumpstarterTest

log = logging.getLogger(__file__)
log = logging.getLogger(__name__)


class TestResource(JumpstarterTest):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,5 @@ def ecu_client(mock_ecu):
with patch(
"jumpstarter_driver_xcp.driver._create_xcp_master",
return_value=mock_ecu,
):
with serve(driver) as client:
yield client
), serve(driver) as client:
yield client
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ def initialize(self, version, build_data):
req.specifier &= SpecifierSet(f"=={self.metadata.version}")
metadata["project"]["dependencies"][i] = str(req)

f = NamedTemporaryFile(delete=False)
tomli_w.dump(metadata, f)
f.close()
with NamedTemporaryFile(delete=False) as f: # pragma: no cover
tomli_w.dump(metadata, f)

build_data["__hatch_pin_jumpstarter_tempfile"] = f
build_data["force_include"][f.name] = "pyproject.toml"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from http import HTTPStatus
from typing import IO, Optional
from typing import IO

import click
from jumpstarter_cli_common.blocking import blocking
Expand Down Expand Up @@ -53,8 +53,8 @@ async def apply(
force_conflicts: bool,
dry_run: bool,
namespace: str,
kubeconfig: Optional[str],
context: Optional[str],
kubeconfig: str | None,
context: str | None,
output: OutputType,
):
"""Apply Jumpstarter manifests to a Kubernetes cluster
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@

def applied(kind: str, name: str, action: str, api_version: str = "jumpstarter.dev/v1alpha1"):
return V1Alpha1AppliedResource(
apiVersion=api_version,
apiVersion=api_version, # type: ignore[call-arg]
kind=kind,
name=name,
namespace="default",
action=action,
action=action, # type: ignore[arg-type]
resource={"apiVersion": api_version, "kind": kind, "metadata": {"name": name}},
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from typing import Optional

import click
from jumpstarter_cli_common.alias import AliasedGroup
Expand Down Expand Up @@ -76,16 +75,16 @@ def create():
@opt_output_all
@blocking
async def create_client(
name: Optional[str],
kubeconfig: Optional[str],
context: Optional[str],
name: str | None,
kubeconfig: str | None,
context: str | None,
insecure_tls: bool,
namespace: str,
labels: dict[str, str],
save: bool,
allow: Optional[str],
allow: str | None,
unsafe: bool,
out: Optional[str],
out: str | None,
oidc_username: str | None,
nointeractive: bool,
output: OutputType,
Expand Down Expand Up @@ -154,14 +153,14 @@ async def create_client(
@opt_output_all
@blocking
async def create_exporter(
name: Optional[str],
kubeconfig: Optional[str],
context: Optional[str],
name: str | None,
kubeconfig: str | None,
context: str | None,
insecure_tls: bool,
namespace: str,
labels: dict[str, str],
save: bool,
out: Optional[str],
out: str | None,
oidc_username: str | None,
nointeractive: bool,
output: OutputType,
Expand Down Expand Up @@ -244,23 +243,23 @@ async def create_exporter(
@blocking
async def create_cluster(
name: str,
kind: Optional[str],
minikube: Optional[str],
k3s: Optional[str],
kind: str | None,
minikube: str | None,
k3s: str | None,
force_recreate: bool,
kind_extra_args: str,
minikube_extra_args: str,
extra_certs: Optional[str],
extra_certs: str | None,
skip_install: bool,
operator_installer: Optional[str],
operator_installer: str | None,
namespace: str,
ip: Optional[str],
basedomain: Optional[str],
grpc_endpoint: Optional[str],
router_endpoint: Optional[str],
version: Optional[str],
kubeconfig: Optional[str],
context: Optional[str],
ip: str | None,
basedomain: str | None,
grpc_endpoint: str | None,
router_endpoint: str | None,
version: str | None,
kubeconfig: str | None,
context: str | None,
nointeractive: bool,
output: OutputType,
):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,35 +40,35 @@
),
)

CLIENT_JSON = """{{
CLIENT_JSON = f"""{{
"apiVersion": "jumpstarter.dev/v1alpha1",
"kind": "Client",
"metadata": {{
"creationTimestamp": "2024-01-01T21:00:00Z",
"name": "{name}",
"name": "{CLIENT_NAME}",
"namespace": "default"
}},
"status": {{
"credential": {{
"name": "{name}-credential"
"name": "{CLIENT_NAME}-credential"
}},
"endpoint": "{endpoint}"
"endpoint": "{CLIENT_ENDPOINT}"
}}
}}
""".format(name=CLIENT_NAME, endpoint=CLIENT_ENDPOINT)
"""

CLIENT_YAML = """apiVersion: jumpstarter.dev/v1alpha1
CLIENT_YAML = f"""apiVersion: jumpstarter.dev/v1alpha1
kind: Client
metadata:
creationTimestamp: '2024-01-01T21:00:00Z'
name: {name}
name: {CLIENT_NAME}
namespace: default
status:
credential:
name: {name}-credential
endpoint: {endpoint}
name: {CLIENT_NAME}-credential
endpoint: {CLIENT_ENDPOINT}

""".format(name=CLIENT_NAME, endpoint=CLIENT_ENDPOINT)
"""

UNSAFE_CLIENT_CONFIG = ClientConfigV1Alpha1(
alias=CLIENT_NAME,
Expand Down Expand Up @@ -217,45 +217,45 @@ def test_create_client(
kind="Exporter",
metadata=V1ObjectMeta(namespace="default", name=EXPORTER_NAME, creation_timestamp="2024-01-01T21:00:00Z"),
status=V1Alpha1ExporterStatus(
endpoint=EXPORTER_ENDPOINT, credential=V1ObjectReference(name=f"{EXPORTER_NAME}-credential"), devices=[]
endpoint=EXPORTER_ENDPOINT, credential=V1ObjectReference(name=f"{EXPORTER_NAME}-credential"), devices=[] # type: ignore[call-arg]
),
)

EXPORTER_JSON = """{{
EXPORTER_JSON = f"""{{
"apiVersion": "jumpstarter.dev/v1alpha1",
"kind": "Exporter",
"metadata": {{
"creationTimestamp": "2024-01-01T21:00:00Z",
"name": "{name}",
"name": "{EXPORTER_NAME}",
"namespace": "default"
}},
"status": {{
"credential": {{
"name": "{name}-credential"
"name": "{EXPORTER_NAME}-credential"
}},
"devices": [],
"endpoint": "{endpoint}",
"endpoint": "{EXPORTER_ENDPOINT}",
"exporterStatus": null,
"statusMessage": null
}}
}}
""".format(name=EXPORTER_NAME, endpoint=EXPORTER_ENDPOINT)
"""

EXPORTER_YAML = """apiVersion: jumpstarter.dev/v1alpha1
EXPORTER_YAML = f"""apiVersion: jumpstarter.dev/v1alpha1
kind: Exporter
metadata:
creationTimestamp: '2024-01-01T21:00:00Z'
name: {name}
name: {EXPORTER_NAME}
namespace: default
status:
credential:
name: {name}-credential
name: {EXPORTER_NAME}-credential
devices: []
endpoint: {endpoint}
endpoint: {EXPORTER_ENDPOINT}
exporterStatus: null
statusMessage: null

""".format(name=EXPORTER_NAME, endpoint=EXPORTER_ENDPOINT)
"""

EXPORTER_CONFIG = ExporterConfigV1Alpha1(
alias=EXPORTER_NAME,
Expand Down Expand Up @@ -399,7 +399,7 @@ def test_create_cluster_kind_minimal(self, mock_validate, mock_create):
mock_create.assert_called_once()

# Verify the arguments passed to create_cluster_and_install
args, kwargs = mock_create.call_args
args, _kwargs = mock_create.call_args
assert args[0] == "kind" # cluster_type
assert args[1] is False # force_recreate_cluster
assert args[2] == "test-cluster" # cluster_name
Expand All @@ -423,7 +423,7 @@ def test_create_cluster_minikube_minimal(self, mock_validate, mock_create):
mock_create.assert_called_once()

# Verify the arguments passed to create_cluster_and_install
args, kwargs = mock_create.call_args
args, _kwargs = mock_create.call_args
assert args[0] == "minikube" # cluster_type
assert args[1] is False # force_recreate_cluster
assert args[2] == "test-cluster" # cluster_name
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from typing import Optional

import click
from jumpstarter_cli_common.alias import AliasedGroup
Expand Down Expand Up @@ -48,16 +47,17 @@ def delete():
@opt_nointeractive
@blocking
async def delete_client(
name: Optional[str],
kubeconfig: Optional[str],
context: Optional[str],
name: str | None,
kubeconfig: str | None,
context: str | None,
namespace: str,
delete: bool,
output: NameOutputType,
nointeractive: bool,
):
"""Delete a client object in the Kubernetes cluster"""
validate_name(name)
assert name is not None
try:
async with ClientsV1Alpha1Api(namespace, kubeconfig, context) as api:
await api.delete_client(name)
Expand Down Expand Up @@ -100,16 +100,17 @@ async def delete_client(
@opt_nointeractive
@blocking
async def delete_exporter(
name: Optional[str],
kubeconfig: Optional[str],
context: Optional[str],
name: str | None,
kubeconfig: str | None,
context: str | None,
namespace: str,
delete: bool,
output: NameOutputType,
nointeractive: bool,
):
"""Delete an exporter object in the Kubernetes cluster"""
validate_name(name)
assert name is not None
try:
async with ExportersV1Alpha1Api(namespace, kubeconfig, context) as api:
await api.delete_exporter(name)
Expand Down Expand Up @@ -153,8 +154,8 @@ async def delete_exporter(
@blocking
async def delete_cluster(
name: str,
kind: Optional[str],
minikube: Optional[str],
kind: str | None,
minikube: str | None,
force: bool,
output: NameOutputType,
):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def test_delete_client(
kind="Exporter",
metadata=V1ObjectMeta(namespace="default", name=EXPORTER_NAME, creation_timestamp="2024-01-01T21:00:00Z"),
status=V1Alpha1ExporterStatus(
endpoint=EXPORTER_ENDPOINT, credential=V1ObjectReference(name=f"{EXPORTER_NAME}-credential"), devices=[]
endpoint=EXPORTER_ENDPOINT, credential=V1ObjectReference(name=f"{EXPORTER_NAME}-credential"), devices=[] # type: ignore[call-arg]
),
)
EXPORTER_CONFIG = ExporterConfigV1Alpha1(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from typing import Optional

import click
from jumpstarter_cli_common.alias import AliasedGroup
Expand Down Expand Up @@ -40,7 +39,7 @@ def get():
@opt_output_all
@blocking
async def get_client(
name: Optional[str], kubeconfig: Optional[str], context: Optional[str], namespace: str, output: OutputType
name: str | None, kubeconfig: str | None, context: str | None, namespace: str, output: OutputType
):
"""Get the client objects in a Kubernetes cluster"""
try:
Expand All @@ -66,9 +65,9 @@ async def get_client(
@click.option("-d", "--devices", is_flag=True, help="Display the devices hosted by the exporter(s)")
@blocking
async def get_exporter(
name: Optional[str],
kubeconfig: Optional[str],
context: Optional[str],
name: str | None,
kubeconfig: str | None,
context: str | None,
namespace: str,
devices: bool,
output: OutputType,
Expand Down Expand Up @@ -96,7 +95,7 @@ async def get_exporter(
@opt_output_all
@blocking
async def get_lease(
name: Optional[str], kubeconfig: Optional[str], context: Optional[str], namespace: str, output: OutputType
name: str | None, kubeconfig: str | None, context: str | None, namespace: str, output: OutputType
):
"""Get the lease objects in a Kubernetes cluster"""
try:
Expand All @@ -123,7 +122,7 @@ async def get_lease(
@opt_output_all
@blocking
async def get_cluster(
name: Optional[str], type: str, kubectl: str, minikube: str, output: OutputType
name: str | None, type: str, kubectl: str, minikube: str, output: OutputType
):
"""Get information about a specific cluster or list all clusters"""
try:
Expand Down
Loading
Loading