@@ -171,10 +171,10 @@ pub struct SparkApplicationSpec {
171
171
pub image : Option < String > ,
172
172
#[ serde( default , skip_serializing_if = "Option::is_none" ) ]
173
173
pub spark_image : Option < String > ,
174
- #[ serde( default , skip_serializing_if = "Option::is_none" ) ]
175
- pub spark_image_pull_policy : Option < ImagePullPolicy > ,
176
- #[ serde( default , skip_serializing_if = "Option::is_none" ) ]
177
- pub spark_image_pull_secrets : Option < Vec < LocalObjectReference > > ,
174
+ #[ serde( default ) ]
175
+ pub spark_image_pull_policy : ImagePullPolicy ,
176
+ #[ serde( default ) ]
177
+ pub spark_image_pull_secrets : Vec < LocalObjectReference > ,
178
178
/// Name of the Vector aggregator discovery ConfigMap.
179
179
/// It must contain the key `ADDRESS` with the address of the Vector aggregator.
180
180
#[ serde( skip_serializing_if = "Option::is_none" ) ]
@@ -205,9 +205,12 @@ pub struct SparkApplicationSpec {
205
205
pub log_file_directory : Option < LogFileDirectorySpec > ,
206
206
}
207
207
208
- #[ derive( Clone , Debug , Deserialize , Eq , JsonSchema , PartialEq , Serialize , Display , EnumString ) ]
208
+ #[ derive(
209
+ Clone , Debug , Default , Deserialize , Eq , JsonSchema , PartialEq , Serialize , Display , EnumString ,
210
+ ) ]
209
211
pub enum ImagePullPolicy {
210
212
Always ,
213
+ #[ default]
211
214
IfNotPresent ,
212
215
Never ,
213
216
}
@@ -250,11 +253,11 @@ impl SparkApplication {
250
253
self . spec . image . as_deref ( )
251
254
}
252
255
253
- pub fn spark_image_pull_policy ( & self ) -> Option < ImagePullPolicy > {
256
+ pub fn spark_image_pull_policy ( & self ) -> ImagePullPolicy {
254
257
self . spec . spark_image_pull_policy . clone ( )
255
258
}
256
259
257
- pub fn spark_image_pull_secrets ( & self ) -> Option < Vec < LocalObjectReference > > {
260
+ pub fn spark_image_pull_secrets ( & self ) -> Vec < LocalObjectReference > {
258
261
self . spec . spark_image_pull_secrets . clone ( )
259
262
}
260
263
@@ -466,6 +469,7 @@ impl SparkApplication {
466
469
format!( "--conf spark.kubernetes.executor.podTemplateContainerName={container_name}" , container_name = SparkContainer :: Spark ) ,
467
470
format!( "--conf spark.kubernetes.namespace={}" , self . metadata. namespace. as_ref( ) . context( NoNamespaceSnafu ) ?) ,
468
471
format!( "--conf spark.kubernetes.driver.container.image={}" , self . spec. spark_image. as_ref( ) . context( NoSparkImageSnafu ) ?) ,
472
+ format!( "--conf spark.kubernetes.container.image.pullPolicy={}" , self . spark_image_pull_policy( ) ) ,
469
473
format!( "--conf spark.kubernetes.executor.container.image={}" , self . spec. spark_image. as_ref( ) . context( NoSparkImageSnafu ) ?) ,
470
474
format!( "--conf spark.kubernetes.authenticate.driver.serviceAccountName={}" , serviceaccount_name) ,
471
475
format!( "--conf spark.driver.defaultJavaOptions=-Dlog4j.configurationFile={VOLUME_MOUNT_PATH_LOG_CONFIG}/{LOG4J2_CONFIG_FILE}" ) ,
@@ -1129,13 +1133,13 @@ spec:
1129
1133
. unwrap ( ) ;
1130
1134
1131
1135
assert_eq ! (
1132
- Some ( vec![ LocalObjectReference {
1136
+ vec![ LocalObjectReference {
1133
1137
name: Some ( "myregistrykey" . to_string( ) )
1134
- } ] ) ,
1138
+ } ] ,
1135
1139
spark_application. spark_image_pull_secrets( )
1136
1140
) ;
1137
1141
assert_eq ! (
1138
- Some ( ImagePullPolicy :: Always ) ,
1142
+ ImagePullPolicy :: Always ,
1139
1143
spark_application. spark_image_pull_policy( )
1140
1144
) ;
1141
1145
}
0 commit comments