19
19
20
20
import click
21
21
22
- from feast .file_utils import replace_str_in_file , write_setting_or_remove
22
+ from feast .file_utils import (
23
+ remove_lines_from_file ,
24
+ replace_str_in_file ,
25
+ write_setting_or_remove ,
26
+ )
23
27
24
28
25
29
def collect_hazelcast_online_store_settings ():
26
- c_cluster_name = ""
30
+ c_cluster_name = None
27
31
c_members = None
28
32
c_ca_path = None
29
33
c_cert_path = None
30
34
c_key_path = None
31
- c_ssl_password = None
32
35
c_discovery_token = None
33
- c_ttl_seconds = 0
36
+ c_ttl_seconds = None
34
37
35
38
cluster_type = click .prompt (
36
39
"Would you like to connect a [L]ocal cluster or [V]iridian cluster?" ,
@@ -46,23 +49,20 @@ def collect_hazelcast_online_store_settings():
46
49
c_ca_path = click .prompt ("CA file path: " )
47
50
c_cert_path = click .prompt ("CERT file path: " )
48
51
c_key_path = click .prompt ("Key file path: " )
49
- c_ssl_password = click .prompt ("SSL password: " )
50
52
else :
51
53
c_cluster_name = click .prompt (
52
- "Cluster_name : " ,
54
+ "Cluster name : " ,
53
55
default = "dev" ,
54
56
)
55
57
c_members = click .prompt (
56
58
"Cluster members:" ,
57
59
default = "localhost:5701" ,
58
60
)
59
-
60
61
needs_ssl = click .confirm ("Use TLS/SSL?" , default = False )
61
62
if needs_ssl :
62
63
c_ca_path = click .prompt ("CA file path: " )
63
64
c_cert_path = click .prompt ("CERT file path: " )
64
65
c_key_path = click .prompt ("Key file path: " )
65
- c_ssl_password = click .prompt ("SSL password: " )
66
66
67
67
c_ttl_seconds = click .prompt (
68
68
"Key TTL seconds: " ,
@@ -74,14 +74,12 @@ def collect_hazelcast_online_store_settings():
74
74
"c_ca_path" : c_ca_path ,
75
75
"c_cert_path" : c_cert_path ,
76
76
"c_key_path" : c_key_path ,
77
- "c_ssl_password" : c_ssl_password ,
78
77
"c_discovery_token" : c_discovery_token ,
79
78
"c_ttl_seconds" : c_ttl_seconds ,
80
79
}
81
80
82
81
83
- def apply_cassandra_store_settings (config_file , settings ):
84
-
82
+ def apply_hazelcast_store_settings (config_file , settings ):
85
83
write_setting_or_remove (
86
84
config_file ,
87
85
settings ["c_cluster_name" ],
@@ -91,16 +89,18 @@ def apply_cassandra_store_settings(config_file, settings):
91
89
#
92
90
write_setting_or_remove (
93
91
config_file ,
94
- "[" + settings ["c_members" ] + "]" ,
95
- "cluster_members " ,
96
- "c_members " ,
92
+ settings ["c_discovery_token" ] ,
93
+ "discovery_token " ,
94
+ "c_discovery_token " ,
97
95
)
98
96
#
97
+ if settings ["c_members" ] is not None :
98
+ settings ["c_members" ] = "[" + settings ["c_members" ] + "]"
99
99
write_setting_or_remove (
100
100
config_file ,
101
- settings ["c_discovery_token " ],
102
- "discovery_token " ,
103
- "c_discovery_token " ,
101
+ settings ["c_members " ],
102
+ "cluster_members " ,
103
+ "c_members " ,
104
104
)
105
105
#
106
106
write_setting_or_remove (
@@ -123,13 +123,12 @@ def apply_cassandra_store_settings(config_file, settings):
123
123
"ssl_keyfile_path" ,
124
124
"c_key_path" ,
125
125
)
126
- #
127
- write_setting_or_remove (
128
- config_file ,
129
- settings ["c_ssl_password" ],
130
- "ssl_password" ,
131
- "c_ssl_password" ,
132
- )
126
+ if settings ["c_ca_path" ] is None :
127
+ remove_lines_from_file (
128
+ config_file ,
129
+ "ssl_password: ${SSL_PASSWORD}" ,
130
+ True ,
131
+ )
133
132
#
134
133
replace_str_in_file (
135
134
config_file ,
@@ -170,7 +169,7 @@ def bootstrap():
170
169
171
170
# store config yaml, interact with user and then customize file:
172
171
settings = collect_hazelcast_online_store_settings ()
173
- apply_cassandra_store_settings (config_file , settings )
172
+ apply_hazelcast_store_settings (config_file , settings )
174
173
175
174
176
175
if __name__ == "__main__" :
0 commit comments