@@ -98,66 +98,65 @@ func run(ctx context.Context, cancel context.CancelFunc, fl *flags) []error {
98
98
enforceInclude := len (include ) > 0
99
99
100
100
artifactsToDownload := map [string ]string {}
101
+ fmt .Printf ("\n " )
101
102
for key , value := range artifactToPath {
102
- fmt .Printf ("%s - %s\n " , key , value )
103
103
if ignore [key ] {
104
+ fmt .Printf ("Ignoring as artifact explicitly excluded \" %s\" with path \" %s\" \n " , key , value )
104
105
continue
105
106
}
106
107
107
108
if enforceInclude && ! include [key ] {
109
+ fmt .Printf ("Ignoring as not artifact not explicitly included \" %s\" with path \" %s\" \n " , key , value )
108
110
continue
109
111
}
110
112
111
113
artifactsToDownload [key ] = value
112
114
}
113
115
114
- var errc = make (chan error )
115
- var done = make (chan struct {})
116
-
116
+ fmt .Printf ("\n " )
117
117
for sku , path := range artifactsToDownload {
118
-
119
- if strings .Contains (path , "AKSWindows" ) {
120
- go getReleaseNotesWindows (sku , path , fl , errc , done )
121
- } else {
122
- go getReleaseNotes (sku , path , fl , errc , done )
123
- }
118
+ fmt .Printf ("Including artifact \" %s\" with path \" %s\" \n " , sku , path )
124
119
}
125
120
126
121
var errs []error
127
122
128
- for i := 0 ; i < len (artifactsToDownload ); i ++ {
129
- select {
130
- case err := <- errc :
131
- errs = append (errs , err )
132
- case <- done :
133
- continue
123
+ // In theory, this could be done in parallel using a goroutine.
124
+ // In practice, the "az" command breaks if you call it in parallel.
125
+ for sku , path := range artifactsToDownload {
126
+ if strings .Contains (path , "AKSWindows" ) {
127
+ err := getReleaseNotesWindows (sku , path , fl )
128
+ if err != nil {
129
+ errs = append (errs , err )
130
+ }
131
+ } else {
132
+ err := getReleaseNotes (sku , path , fl )
133
+ if err != nil {
134
+ errs = append (errs , err )
135
+ }
134
136
}
135
137
}
136
138
137
139
return errs
138
140
}
139
141
140
- func getReleaseNotes (sku , path string , fl * flags , errc chan <- error , done chan <- struct {}) {
141
- defer func () { done <- struct {}{} }()
142
+ func getReleaseNotes (sku , path string , fl * flags ) error {
142
143
143
144
// working directory, need one per sku because the file name is
144
145
// always "release-notes.txt" so they all overwrite each other.
145
146
tmpdir , err := os .MkdirTemp ("" , "releasenotes" )
146
147
if err != nil {
147
- errc <- fmt .Errorf ("failed to create temp working directory: %w" , err )
148
+ return fmt .Errorf ("failed to create temp working directory: %w" , err )
148
149
}
149
150
defer os .RemoveAll (tmpdir )
150
151
151
152
artifactsDirOut := filepath .Join (fl .path , path )
152
153
153
154
if err := os .MkdirAll (filepath .Dir (artifactsDirOut ), 0644 ); err != nil {
154
- errc <- fmt .Errorf ("failed to create parent directory %s with error: %s" , artifactsDirOut , err )
155
- return
155
+ return fmt .Errorf ("failed to create parent directory %s with error: %s" , artifactsDirOut , err )
156
156
}
157
157
158
158
if err := os .MkdirAll (artifactsDirOut , 0644 ); err != nil {
159
- errc <- fmt .Errorf ("failed to create parent directory %s with error: %s" , artifactsDirOut , err )
160
- return
159
+ return fmt .Errorf ("failed to create parent directory %s with error: %s" , artifactsDirOut , err )
161
160
}
162
161
163
162
artifacts := []buildArtifact {
@@ -178,48 +177,47 @@ func getReleaseNotes(sku, path string, fl *flags, errc chan<- error, done chan<-
178
177
for _ , artifact := range artifacts {
179
178
if err := artifact .process (fl , artifactsDirOut , tmpdir ); err != nil {
180
179
fmt .Printf ("processing artifact %s for sku %s" , artifact .name , sku )
181
- errc <- fmt .Errorf ("failed to process VHD build artifact %s: %w" , artifact .name , err )
182
- return
180
+ return fmt .Errorf ("failed to process VHD build artifact %s: %w" , artifact .name , err )
183
181
}
184
182
}
185
- }
186
183
187
- func getReleaseNotesWindows ( sku , path string , fl * flags , errc chan <- error , done chan <- struct {}) {
188
- defer func () { done <- struct {}{} }()
184
+ return nil
185
+ }
189
186
187
+ func getReleaseNotesWindows (sku , path string , fl * flags ) error {
190
188
releaseNotesName := fmt .Sprintf ("vhd-release-notes-%s" , sku )
191
189
imageListName := fmt .Sprintf ("vhd-image-list-%s" , sku )
192
190
193
191
artifactsDirOut := filepath .Join (fl .path , path )
194
- if err := os .MkdirAll (filepath .Dir (artifactsDirOut ), 0644 ); err != nil {
195
- errc <- fmt .Errorf ("failed to create parent directory %s with error: %s" , artifactsDirOut , err )
196
- return
192
+ parentDirectory := filepath .Dir (artifactsDirOut )
193
+ fmt .Printf ("\n " )
194
+ fmt .Printf ("Creating parent directory for sku'%s': '%s'\n " , sku , parentDirectory )
195
+ if err := os .MkdirAll (parentDirectory , 0644 ); err != nil {
196
+ return fmt .Errorf ("failed to create parent directory %s with error: %s" , artifactsDirOut , err )
197
197
}
198
198
199
+ fmt .Printf ("Creating directory for sku '%s': '%s'\n " , sku , artifactsDirOut )
199
200
if err := os .MkdirAll (artifactsDirOut , 0644 ); err != nil {
200
- errc <- fmt .Errorf ("failed to create parent directory %s with error: %s" , artifactsDirOut , err )
201
- return
201
+ return fmt .Errorf ("failed to create directory %s with error: %s" , artifactsDirOut , err )
202
202
}
203
203
204
- fmt .Printf ("downloading releaseNotes '%s' from build '%s'\n " , releaseNotesName , fl .build )
204
+ fmt .Printf ("downloading releaseNotes '%s' from windows build '%s'\n " , releaseNotesName , fl .build )
205
205
206
206
cmd := exec .Command ("az" , "pipelines" , "runs" , "artifact" , "download" , "--run-id" , fl .build , "--path" , artifactsDirOut , "--artifact-name" , releaseNotesName )
207
207
if stdout , err := cmd .CombinedOutput (); err != nil {
208
- if err != nil {
209
- errc <- fmt .Errorf ("failed to download az devops releaseNotes for sku %s, err: %s, output: %s" , sku , err , string (stdout ))
210
- }
211
- return
208
+ fmt .Printf ("Failed downloading releaseNotes '%s' from windows build '%s'\n " , releaseNotesName , fl .build )
209
+ return fmt .Errorf ("failed to download az devops releaseNotes for sku %s, err: %s, output: %s" , sku , err , string (stdout ))
212
210
}
213
211
214
212
fmt .Printf ("downloading imageList '%s' from build '%s'\n " , imageListName , fl .build )
215
213
216
214
cmd = exec .Command ("az" , "pipelines" , "runs" , "artifact" , "download" , "--run-id" , fl .build , "--path" , artifactsDirOut , "--artifact-name" , imageListName )
217
215
if stdout , err := cmd .CombinedOutput (); err != nil {
218
- if err != nil {
219
- errc <- fmt .Errorf ("failed to download az devops imageList for sku %s, err: %s, output: %s" , sku , err , string (stdout ))
220
- }
221
- return
216
+ fmt .Printf ("failed downloading imageList '%s' from windows build '%s'\n " , imageListName , fl .build )
217
+ return fmt .Errorf ("failed to download az devops imageList for sku %s, err: %s, output: %s" , sku , err , string (stdout ))
222
218
}
219
+
220
+ return nil
223
221
}
224
222
225
223
func stripWhitespace (str string ) string {
0 commit comments