@@ -12,14 +12,17 @@ use crate::constants::{HELM_REPO_URL_DEV, HELM_REPO_URL_STABLE, HELM_REPO_URL_TE
1212
1313#[ derive( Debug , Snafu ) ]
1414pub enum Error {
15- #[ snafu( display( "failed to transfer values file" ) ) ]
16- FileTransfer { source : xfer:: Error } ,
15+ #[ snafu( display( "failed to open or transfer values file '{path}'" ) ) ]
16+ FileTransfer {
17+ source : xfer:: Error ,
18+ path : String ,
19+ } ,
1720
18- #[ snafu( display( "operator values file must be a YAML mapping at the top level" ) ) ]
19- InvalidValueType ,
21+ #[ snafu( display( "operator values file '{path}' must be a YAML mapping at the top level" ) ) ]
22+ InvalidValueType { path : String } ,
2023
21- #[ snafu( display( "value for key '{key}' must be a YAML mapping" ) ) ]
22- InvalidEntryType { key : String } ,
24+ #[ snafu( display( "value for key '{key}' in operator values file '{path}' must be a YAML mapping" ) ) ]
25+ InvalidEntryType { key : String , path : String } ,
2326}
2427
2528#[ derive( Debug , Snafu ) ]
@@ -73,23 +76,36 @@ pub async fn load_operator_values(
7376 values_file : Option < & PathOrUrl > ,
7477 transfer_client : & xfer:: Client ,
7578) -> Result < Mapping , Error > {
76- let value = match values_file {
77- Some ( file) => transfer_client
78- . get ( file, & Yaml :: < Value > :: default ( ) )
79- . await
80- . context ( FileTransferSnafu ) ?,
79+ let file = match values_file {
80+ Some ( file) => file,
8181 None => return Ok ( Mapping :: new ( ) ) ,
8282 } ;
8383
84+ let path = match file {
85+ PathOrUrl :: Path ( p) => p. display ( ) . to_string ( ) ,
86+ PathOrUrl :: Url ( u) => u. to_string ( ) ,
87+ } ;
88+
89+ let value = transfer_client
90+ . get ( file, & Yaml :: < Value > :: default ( ) )
91+ . await
92+ . context ( FileTransferSnafu { path : path. clone ( ) } ) ?;
93+
8494 let mapping = match value {
8595 Value :: Mapping ( mapping) => mapping,
86- _ => return InvalidValueTypeSnafu . fail ( ) ,
96+ _ => {
97+ return InvalidValueTypeSnafu {
98+ path : path. clone ( ) ,
99+ }
100+ . fail ( )
101+ }
87102 } ;
88103
89104 for ( key, value) in & mapping {
90105 if !value. is_mapping ( ) {
91106 return InvalidEntryTypeSnafu {
92107 key : key. as_str ( ) . unwrap_or ( "<non-string key>" ) . to_string ( ) ,
108+ path : path. clone ( ) ,
93109 }
94110 . fail ( ) ;
95111 }
0 commit comments