@@ -5,7 +5,7 @@ use crate::plugin::{
55 DEFAULT_IMAGE_REGISTRY , DEFAULT_RELEASE_NAME , IO_ENGINE_POD_LABEL , MAX_RETRY_ATTEMPTS ,
66 UPGRADE_CONFIG_MAP_MOUNT_PATH , UPGRADE_CONFIG_MAP_NAME_SUFFIX ,
77 UPGRADE_JOB_CLUSTERROLEBINDING_NAME_SUFFIX , UPGRADE_JOB_CLUSTERROLE_NAME_SUFFIX ,
8- UPGRADE_JOB_IMAGE_REPO , UPGRADE_JOB_NAME_SUFFIX , UPGRADE_JOB_SERVICEACCOUNT_NAME_SUFFIX ,
8+ UPGRADE_JOB_NAME_SUFFIX , UPGRADE_JOB_SERVICEACCOUNT_NAME_SUFFIX ,
99 } ,
1010 error, objects,
1111 user_prompt:: {
@@ -83,6 +83,10 @@ pub struct UpgradeArgs {
8383 #[ clap( global = true , long) ]
8484 registry : Option < String > ,
8585
86+ /// Specify the container namespace for the upgrade-job image.
87+ #[ clap( global = true , long) ]
88+ repo_namespace : Option < String > ,
89+
8690 /// Allow upgrade from stable versions to unstable versions. This is implied when the
8791 /// '--skip-upgrade-path-validation-for-unsupported-version' option is used.
8892 #[ clap( global = true , long, hide = true ) ]
@@ -138,6 +142,7 @@ impl UpgradeArgs {
138142 pub fn new ( ) -> Self {
139143 Self {
140144 registry : None ,
145+ repo_namespace : None ,
141146 allow_unstable : false ,
142147 dry_run : false ,
143148 skip_data_plane_restart : false ,
@@ -710,17 +715,21 @@ impl UpgradeResources {
710715 let img = ImageProperties :: try_from ( rest_deployment) ?;
711716 let set_file = create_helm_set_file_args ( args, set_file_map) . await ?;
712717
713- // Image registry override check.
718+ // Image registry/namespace override check.
714719 let registry: & str = match args. registry {
715720 Some ( ref registry_override) => registry_override,
716721 None => img. registry ( ) ,
717722 } ;
723+ let namespace: & str = match args. repo_namespace {
724+ Some ( ref namespace) => namespace,
725+ None => img. namespace ( ) ,
726+ } ;
718727
719728 let upgrade_deploy = objects:: upgrade_job (
720729 ns,
721730 upgrade_image_concat (
722731 registry,
723- UPGRADE_JOB_IMAGE_REPO ,
732+ namespace ,
724733 & upgrade_job_img ( ) ,
725734 upgrade_job_image_tag. as_str ( ) ,
726735 ) ,
@@ -884,6 +893,7 @@ pub(crate) async fn is_upgrade_job_completed(ns: &str) -> error::Result<bool> {
884893struct ImageProperties {
885894 pull_secrets : Option < Vec < k8s_openapi:: api:: core:: v1:: LocalObjectReference > > ,
886895 registry : String ,
896+ namespace : String ,
887897 pull_policy : Option < String > ,
888898}
889899
@@ -912,16 +922,18 @@ impl TryFrom<Deployment> for ImageProperties {
912922 if image_sections. is_empty ( ) || image_sections. len ( ) == 1 {
913923 return error:: ReferenceDeploymentInvalidImage . fail ( ) ;
914924 }
915-
916- let registry = match image_sections. len ( ) {
917- 3 => image_sections[ 0 ] ,
918- _ => DEFAULT_IMAGE_REGISTRY ,
919- }
920- . to_string ( ) ;
925+ // todo: isn't the registry always explicitly shown anyway?
926+ let ( registry, namespace) = if image_sections. len ( ) >= 3 {
927+ let namespace = image_sections[ 1 ..image_sections. len ( ) - 1 ] . join ( "/" ) ;
928+ ( image_sections[ 0 ] , namespace)
929+ } else {
930+ ( DEFAULT_IMAGE_REGISTRY , image_sections[ 0 ] . to_string ( ) )
931+ } ;
921932
922933 Ok ( Self {
923934 pull_secrets : pod_spec. image_pull_secrets . clone ( ) ,
924- registry,
935+ registry : registry. to_string ( ) ,
936+ namespace,
925937 pull_policy : container. image_pull_policy . clone ( ) ,
926938 } )
927939 }
@@ -936,6 +948,10 @@ impl ImageProperties {
936948 self . registry . as_str ( )
937949 }
938950
951+ fn namespace ( & self ) -> & str {
952+ self . namespace . as_str ( )
953+ }
954+
939955 fn pull_policy ( & self ) -> Option < String > {
940956 self . pull_policy . clone ( )
941957 }
0 commit comments