@@ -111,9 +111,8 @@ impl ProductImage {
111
111
ProductImageSelection :: Custom ( image_selection) => {
112
112
let image = ImageRef :: parse ( & image_selection. custom ) ;
113
113
let image_tag_or_hash = image. tag . or ( image. hash ) . unwrap_or ( "latest" . to_string ( ) ) ;
114
- let mut app_version_label = format ! ( "{}-{}" , product_version, image_tag_or_hash) ;
115
- // TODO Use new label mechanism once added
116
- app_version_label. truncate ( 63 ) ;
114
+ let app_version_label =
115
+ Self :: build_app_version_label ( & product_version, & image_tag_or_hash) ;
117
116
118
117
ResolvedProductImage {
119
118
product_version,
@@ -174,6 +173,26 @@ impl ProductImage {
174
173
} ) => pv,
175
174
}
176
175
}
176
+
177
+ /// Format the `image_tag_or_hash` for special characters not allowed in labels and build the
178
+ /// full app_version_label with a max length of 63 characters.
179
+ ///
180
+ /// A docker image with hash usually looks like:
181
+ ///
182
+ /// Without product or stackable version:
183
+ /// oci.stackable.tech/sdp/spark-k8s@sha256:c8b77ba72de6f8ddb99cb484b5ee79c43623cc2514d1448243f7d65d0ef66212
184
+ ///
185
+ /// With product and stackable version:
186
+ /// oci.stackable.tech/sdp/spark-k8s:3.5.6-stackable25.7.0@sha256:c8b77ba72de6f8ddb99cb484b5ee79c43623cc2514d1448243f7d65d0ef66212
187
+ ///
188
+ /// Using the hash we have to avoid adding characters like ":" to the image with is against Kubernetes policy.
189
+ fn build_app_version_label ( product_version : & str , image_tag_or_hash : & str ) -> String {
190
+ let formatted_image_tag_or_hash = image_tag_or_hash. replace ( ":" , "-" ) ;
191
+ let mut app_version_label = format ! ( "{}-{}" , product_version, formatted_image_tag_or_hash) ;
192
+ // TODO Use new label mechanism once added
193
+ app_version_label. truncate ( 63 ) ;
194
+ app_version_label
195
+ }
177
196
}
178
197
179
198
#[ cfg( test) ]
0 commit comments