@@ -50,7 +50,8 @@ def __init__(self, config: ClientConfig):
5050 self .k8s_client = FluidK8sClient (config .namespace , config .runtime_kind , config .kube_config_file ,
5151 config .kube_context , config .kube_client_configuration )
5252
53- def create_dataset (self , dataset_name : str , mount_name : str , mount_point : str , mount_path = "" , mode = "ReadOnly" ,
53+ def create_dataset (self , dataset_name : str , mount_name : str = None , mount_point : str = None , mount_path = "" ,
54+ mode = "ReadOnly" ,
5455 options = None ,
5556 cred_secret_name = None ,
5657 cred_secret_options = None , namespace = None ,
@@ -71,7 +72,22 @@ def create_dataset(self, dataset_name: str, mount_name: str, mount_point: str, m
7172 models .EncryptOption (opt_key , models .EncryptOptionSource (
7273 models .SecretKeySelector (secret_key , cred_secret_name ))))
7374
75+ if (mount_name is None ) != (mount_point is None ):
76+ raise ValueError ("mount_name and mount_point must be set together" )
77+
78+ if mount_name is None :
79+ mount_items = None
80+ else :
81+ mount_items = [models .Mount (
82+ mount_point = mount_point ,
83+ path = mount_path ,
84+ name = mount_name ,
85+ options = options ,
86+ encrypt_options = encrypt_options
87+ )]
88+
7489 access_mode = "ReadOnlyMany" if mode == "ReadOnly" else "ReadWriteMany"
90+
7591 ds = models .Dataset (
7692 api_version = constants .API_VERSION ,
7793 kind = constants .DATASET_KIND ,
@@ -80,13 +96,7 @@ def create_dataset(self, dataset_name: str, mount_name: str, mount_point: str, m
8096 namespace = namespace or self .config .namespace ,
8197 ),
8298 spec = models .DatasetSpec (
83- mounts = [models .Mount (
84- mount_point = mount_point ,
85- path = mount_path ,
86- name = mount_name ,
87- options = options ,
88- encrypt_options = encrypt_options
89- )],
99+ mounts = mount_items ,
90100 access_modes = [access_mode ],
91101 ** kwargs
92102 )
0 commit comments