1- use std:: collections:: HashMap ;
1+ use std:: { collections:: HashMap , time :: Duration } ;
22
33use indicatif:: ProgressStyle ;
44use snafu:: { ResultExt , Snafu } ;
55use stackable_operator:: kvp:: Labels ;
6- use tracing:: { debug , info , info_span , instrument , Instrument as _ , Span } ;
6+ use tracing:: { Instrument as _ , Span , debug , info , info_span , instrument } ;
77use tracing_indicatif:: span_ext:: IndicatifSpanExt as _;
88
99use crate :: {
10+ PROGRESS_BAR_STYLE ,
1011 common:: manifest:: ManifestSpec ,
1112 helm,
1213 utils:: {
@@ -64,7 +65,7 @@ pub enum Error {
6465
6566pub trait InstallManifestsExt {
6667 // TODO (Techassi): This step shouldn't care about templating the manifests nor fetching them from remote
67- #[ instrument( skip_all, fields( %namespace) ) ]
68+ #[ instrument( skip_all, fields( %namespace, indicatif . pb_show = true ) ) ]
6869 #[ allow( async_fn_in_trait) ]
6970 async fn install_manifests (
7071 manifests : & [ ManifestSpec ] ,
@@ -76,18 +77,21 @@ pub trait InstallManifestsExt {
7677 ) -> Result < ( ) , Error > {
7778 debug ! ( "Installing manifests" ) ;
7879
79- Span :: current ( ) . pb_set_style (
80- & ProgressStyle :: with_template ( "Progress: {wide_bar} {pos}/{len}" ) . expect ( "valid progress template" )
81- ) ;
80+ Span :: current ( ) . pb_set_style ( & PROGRESS_BAR_STYLE ) ;
8281 Span :: current ( ) . pb_set_length ( manifests. len ( ) as u64 ) ;
8382
83+ tokio:: time:: sleep ( Duration :: from_secs ( 2 ) ) . await ;
84+
8485 let mut parameters = parameters. clone ( ) ;
8586 // We add the NAMESPACE parameter, so that stacks/demos can use that to render e.g. the
8687 // fqdn service names [which contain the namespace].
8788 parameters. insert ( "NAMESPACE" . to_owned ( ) , namespace. to_owned ( ) ) ;
8889
8990 for manifest in manifests {
90- let span = info_span ! ( "install_manifests_iter" ) ;
91+ let span = tracing:: warn_span!( "install_manifests_iter" , indicatif. pb_show = true ) ;
92+ span. pb_set_style (
93+ & ProgressStyle :: with_template ( "{span_child_prefix} boo {span_name}" ) . unwrap ( ) ,
94+ ) ;
9195
9296 let parameters = parameters. clone ( ) ;
9397 let labels = labels. clone ( ) ;
@@ -97,18 +101,27 @@ pub trait InstallManifestsExt {
97101 debug ! ( helm_file, "Installing manifest from Helm chart" ) ;
98102
99103 // Read Helm chart YAML and apply templating
100- let helm_file = helm_file. into_path_or_url ( ) . context ( ParsePathOrUrlSnafu {
101- path_or_url : helm_file. clone ( ) ,
102- } ) ?;
104+ let helm_file =
105+ helm_file. into_path_or_url ( ) . context ( ParsePathOrUrlSnafu {
106+ path_or_url : helm_file. clone ( ) ,
107+ } ) ?;
103108
104109 let helm_chart: helm:: Chart = transfer_client
105110 . get ( & helm_file, & Template :: new ( & parameters) . then ( Yaml :: new ( ) ) )
106111 . await
107112 . context ( FileTransferSnafu ) ?;
108113
109- info ! ( helm_chart. name, helm_chart. version, "Installing Helm chart" , ) ;
110- Span :: current ( ) . pb_set_message ( format ! ( "Installing {name} Helm chart" , name = helm_chart. name) . as_str ( ) ) ;
111- Span :: current ( ) . pb_set_style ( & ProgressStyle :: with_template ( "{spinner} {msg}" ) . expect ( "valid progress template" ) ) ;
114+ info ! ( helm_chart. name, helm_chart. version, "Installing Helm chart" ) ;
115+ Span :: current ( ) . pb_set_message (
116+ format ! ( "Installing {name} Helm chart" , name = helm_chart. name)
117+ . as_str ( ) ,
118+ ) ;
119+ // Span::current().pb_set_style(
120+ // &ProgressStyle::with_template(
121+ // "{span_child_prefix:.bold.dim} {spinner} {span_name}",
122+ // )
123+ // .expect("valid progress template"),
124+ // );
112125
113126 // Assumption: that all manifest helm charts refer to repos not registries
114127 helm:: add_repo ( & helm_chart. repo . name , & helm_chart. repo . url ) . context (
@@ -139,7 +152,13 @@ pub trait InstallManifestsExt {
139152 }
140153 ManifestSpec :: PlainYaml ( manifest_file) => {
141154 debug ! ( manifest_file, "Installing YAML manifest" ) ;
142- Span :: current ( ) . pb_set_style ( & ProgressStyle :: with_template ( "{spinner} Installing YAML manifest" ) . expect ( "valid progress template" ) ) ;
155+ // TODO (@NickLarsenNZ): This span already has a style.
156+ // Span::current().pb_set_style(
157+ // &ProgressStyle::with_template(
158+ // "{span_child_prefix:.bold.dim} {spinner} {span_name} Installing YAML manifest",
159+ // )
160+ // .expect("valid progress template"),
161+ // );
143162
144163 // Read YAML manifest and apply templating
145164 let path_or_url =
@@ -162,8 +181,9 @@ pub trait InstallManifestsExt {
162181 }
163182
164183 Ok :: < ( ) , Error > ( ( ) )
165-
166- } . instrument ( span) . await ?;
184+ }
185+ . instrument ( span)
186+ . await ?;
167187
168188 Span :: current ( ) . pb_inc ( 1 ) ;
169189 }
0 commit comments