@@ -27,7 +27,6 @@ import (
2727 "github.com/databricks/databricks-sdk-go/service/pipelines"
2828 "github.com/spf13/cobra"
2929 "golang.org/x/exp/maps"
30- "golang.org/x/exp/slices"
3130)
3231
3332type PipelineUpdateData struct {
@@ -37,7 +36,7 @@ type PipelineUpdateData struct {
3736 LastEventTime string
3837}
3938
40- const pipelineUpdateTemplate = `Update {{ .Update.UpdateId }} for pipeline {{- if .Update.Config }}{{ .Update.Config.Name }}{{ end }} {{- if .Update.Config }}{{ .Update.Config.Id }}{{ end }} completed successfully.
39+ const pipelineUpdateTemplate = `Update {{ .Update.UpdateId }} for pipeline {{- if .Update.Config }} {{ .Update.Config.Name }}{{ end }} {{- if .Update.Config }} {{ .Update.Config.Id }}{{ end }} completed successfully.
4140{{- if .Update.Cause }}
4241Cause: {{ .Update.Cause }}
4342{{- end }}
@@ -90,30 +89,6 @@ func getRefreshSelectionString(update pipelines.UpdateInfo) string {
9089 return "default refresh-all"
9190}
9291
93- func fetchUpdateProgressEventsForUpdateAscending (ctx context.Context , bundle * bundle.Bundle , pipelineId , updateId string ) ([]pipelines.PipelineEvent , error ) {
94- w := bundle .WorkspaceClient ()
95-
96- req := pipelines.ListPipelineEventsRequest {
97- PipelineId : pipelineId ,
98- Filter : fmt .Sprintf ("update_id='%s' AND event_type='update_progress'" , updateId ),
99- // OrderBy: []string{"timestamp asc"}, TODO: Add this back in when the API is fixed
100- }
101-
102- iterator := w .Pipelines .ListPipelineEvents (ctx , req )
103- var events []pipelines.PipelineEvent
104-
105- for iterator .HasNext (ctx ) {
106- event , err := iterator .Next (ctx )
107- if err != nil {
108- return nil , err
109- }
110- events = append (events , event )
111- }
112- slices .Reverse (events )
113-
114- return events , nil
115- }
116-
11792func fetchAndDisplayPipelineUpdate (ctx context.Context , bundle * bundle.Bundle , ref bundleresources.Reference , updateId string ) error {
11893 w := bundle .WorkspaceClient ()
11994
@@ -137,12 +112,17 @@ func fetchAndDisplayPipelineUpdate(ctx context.Context, bundle *bundle.Bundle, r
137112
138113 latestUpdate := * getUpdateResponse .Update
139114
140- if latestUpdate .State == pipelines .UpdateInfoStateCompleted {
141- events , err := fetchUpdateProgressEventsForUpdateAscending (ctx , bundle , pipelineID , updateId )
142- if err != nil {
143- return err
144- }
115+ params := & PipelineEventsQueryParams {
116+ Filter : fmt .Sprintf ("update_id='%s' AND event_type='update_progress'" , updateId ),
117+ OrderBy : "timestamp asc" ,
118+ }
145119
120+ events , err := fetchAllPipelineEvents (ctx , w , pipelineID , params )
121+ if err != nil {
122+ return err
123+ }
124+
125+ if latestUpdate .State == pipelines .UpdateInfoStateCompleted {
146126 err = displayPipelineUpdate (ctx , latestUpdate , pipelineID , events )
147127 if err != nil {
148128 return err
@@ -165,7 +145,6 @@ func getLastEventTime(events []pipelines.PipelineEvent) string {
165145 return parsedTime .Format ("2006-01-02T15:04:05Z" )
166146}
167147
168- // displayPipelineUpdate displays pipeline update information
169148func displayPipelineUpdate (ctx context.Context , update pipelines.UpdateInfo , pipelineID string , events []pipelines.PipelineEvent ) error {
170149 data := PipelineUpdateData {
171150 PipelineId : pipelineID ,
0 commit comments