@@ -14,7 +14,11 @@ use crate::{
1414 operator:: { self , ChartSourceType , OperatorSpec } ,
1515 product,
1616 } ,
17- utils:: k8s:: { self , Client } ,
17+ utils:: {
18+ k8s:: { self , Client } ,
19+ path:: { IntoPathOrUrl as _, PathOrUrlParseError } ,
20+ } ,
21+ xfer:: { self , processor:: Text } ,
1822} ;
1923
2024type Result < T , E = Error > = std:: result:: Result < T , E > ;
@@ -24,6 +28,17 @@ pub enum Error {
2428 #[ snafu( display( "failed to parse operator spec" ) ) ]
2529 OperatorSpecParse { source : operator:: SpecParseError } ,
2630
31+ /// This error indicates that parsing a string into a path or URL failed.
32+ #[ snafu( display( "failed to parse '{path_or_url}' as path/url" ) ) ]
33+ ParsePathOrUrl {
34+ source : PathOrUrlParseError ,
35+ path_or_url : String ,
36+ } ,
37+
38+ /// This error indicates that receiving remote content failed.
39+ #[ snafu( display( "failed to receive remote content" ) ) ]
40+ FileTransfer { source : xfer:: Error } ,
41+
2742 #[ snafu( display( "failed to install release using Helm" ) ) ]
2843 HelmInstall { source : helm:: Error } ,
2944
@@ -35,15 +50,6 @@ pub enum Error {
3550
3651 #[ snafu( display( "failed to deploy manifests using the kube client" ) ) ]
3752 DeployManifest { source : k8s:: Error } ,
38-
39- #[ snafu( display( "failed to construct a valid request" ) ) ]
40- ConstructRequest { source : reqwest:: Error } ,
41-
42- #[ snafu( display( "failed to access the CRDs from source" ) ) ]
43- AccessCRDs { source : reqwest:: Error } ,
44-
45- #[ snafu( display( "failed to read CRD manifests" ) ) ]
46- ReadManifests { source : reqwest:: Error } ,
4753}
4854
4955#[ derive( Clone , Debug , Deserialize , Serialize ) ]
@@ -142,6 +148,7 @@ impl ReleaseSpec {
142148 exclude_products : & [ String ] ,
143149 namespace : & str ,
144150 k8s_client : & Client ,
151+ transfer_client : & xfer:: Client ,
145152 ) -> Result < ( ) > {
146153 info ! ( "Upgrading CRDs for release" ) ;
147154 Span :: current ( ) . pb_set_style ( & PROGRESS_BAR_STYLE ) ;
@@ -153,7 +160,6 @@ impl ReleaseSpec {
153160 Span :: current ( ) . record ( "product.excluded" , product) ;
154161 } ) ;
155162
156- let client = reqwest:: Client :: new ( ) ;
157163 let operators = self . filter_products ( include_products, exclude_products) ;
158164
159165 Span :: current ( ) . pb_set_length ( operators. len ( ) as u64 ) ;
@@ -162,7 +168,6 @@ impl ReleaseSpec {
162168 info ! ( "Upgrading CRDs for {product_name}-operator" ) ;
163169 let iter_span = tracing:: info_span!( "upgrade_crds_iter" , indicatif. pb_show = true ) ;
164170
165- let client = client. clone ( ) ;
166171 async move {
167172 Span :: current ( ) . pb_set_message ( format ! ( "Ugrading CRDs for {product_name}-operator" ) . as_str ( ) ) ;
168173
@@ -173,20 +178,18 @@ impl ReleaseSpec {
173178 }
174179 } ;
175180
176- let request_url = format ! (
181+ let request_url = & format ! (
177182 "https://raw.githubusercontent.com/stackabletech/{product_name}-operator/{release_branch}/deploy/helm/{product_name}-operator/crds/crds.yaml"
178183 ) ;
184+ let request_url = request_url. into_path_or_url ( ) . context ( ParsePathOrUrlSnafu {
185+ path_or_url : request_url. clone ( ) ,
186+ } ) ?;
179187
180188 // Get CRD manifests from request_url
181- let response = client
182- . get ( request_url)
183- . send ( )
189+ let crd_manifests: String = transfer_client
190+ . get ( & request_url, & Text )
184191 . await
185- . context ( ConstructRequestSnafu ) ?
186- . error_for_status ( )
187- . context ( AccessCRDsSnafu ) ?;
188-
189- let crd_manifests = response. text ( ) . await . context ( ReadManifestsSnafu ) ?;
192+ . context ( FileTransferSnafu ) ?;
190193
191194 // Upgrade CRDs
192195 k8s_client
0 commit comments