@@ -83,21 +83,34 @@ func resourceGitlabPipelineScheduleRead(d *schema.ResourceData, meta interface{}
83
83
84
84
log .Printf ("[DEBUG] read gitlab PipelineSchedule %s/%d" , project , pipelineScheduleID )
85
85
86
- pipelineSchedules , _ , err := client . PipelineSchedules . ListPipelineSchedules ( project , nil )
87
- if err != nil {
88
- return err
86
+ opt := & gitlab. ListPipelineSchedulesOptions {
87
+ Page : 1 ,
88
+ PerPage : 20 ,
89
89
}
90
+
90
91
found := false
91
- for _ , pipelineSchedule := range pipelineSchedules {
92
- if pipelineSchedule .ID == pipelineScheduleID {
93
- d .Set ("description" , pipelineSchedule .Description )
94
- d .Set ("ref" , pipelineSchedule .Ref )
95
- d .Set ("cron" , pipelineSchedule .Cron )
96
- d .Set ("cron_timezone" , pipelineSchedule .CronTimezone )
97
- d .Set ("active" , pipelineSchedule .Active )
98
- found = true
92
+ for {
93
+ pipelineSchedules , resp , err := client .PipelineSchedules .ListPipelineSchedules (project , opt )
94
+ if err != nil {
95
+ return err
96
+ }
97
+ for _ , pipelineSchedule := range pipelineSchedules {
98
+ if pipelineSchedule .ID == pipelineScheduleID {
99
+ d .Set ("description" , pipelineSchedule .Description )
100
+ d .Set ("ref" , pipelineSchedule .Ref )
101
+ d .Set ("cron" , pipelineSchedule .Cron )
102
+ d .Set ("cron_timezone" , pipelineSchedule .CronTimezone )
103
+ d .Set ("active" , pipelineSchedule .Active )
104
+ found = true
105
+ break
106
+ }
107
+ }
108
+
109
+ if found || resp .CurrentPage >= resp .TotalPages {
99
110
break
100
111
}
112
+
113
+ opt .Page = resp .NextPage
101
114
}
102
115
if ! found {
103
116
return errors .New (fmt .Sprintf ("PipelineSchedule %d no longer exists in gitlab" , pipelineScheduleID ))
0 commit comments