Skip to content

Commit ad3241c

Browse files
committed
fix: helpful hint to use kubectl://
1 parent e4065ee commit ad3241c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

alpacloud/crdvis/crd.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,14 @@ def read_path(path: str) -> CustomResourceDefinition:
7474

7575
try:
7676
doc = yaml.safe_load(content)
77-
return CustomResourceDefinition.model_validate(doc)
7877
except yaml.YAMLError as e:
7978
raise CRDReadError(f"CRD could not be loaded as YAML: {e}")
79+
80+
try:
81+
return CustomResourceDefinition.model_validate(doc)
8082
except ValidationError as e:
83+
if isinstance(doc, str) and doc.count(".") >= 3:
84+
raise CRDReadError(f"CRD content looks like a name, did you mean `kubectl://{content}`")
8185
# escaping pydantic help message
8286
# like "Input should be a valid dictionary or instance of CustomResourceDefinition [type=model_type, input_value='applications.argoproj.io', input_type=str]"
8387
# for rich

0 commit comments

Comments
 (0)