@@ -83,9 +83,24 @@ func (d *runnerDataSource) Schema(_ context.Context, _ datasource.SchemaRequest,
8383 "metrics" : schema.SingleNestedAttribute {
8484 Computed : true ,
8585 Attributes : map [string ]schema.Attribute {
86- "enabled" : schema.BoolAttribute {Computed : true },
87- "url" : schema.StringAttribute {Computed : true },
88- "username" : schema.StringAttribute {Computed : true },
86+ "enabled" : schema.BoolAttribute {Computed : true },
87+ "managed_metrics_enabled" : schema.BoolAttribute {Computed : true , MarkdownDescription : "When true, the runner pushes metrics to the management plane instead of directly to the remote_write endpoint." },
88+ "url" : schema.StringAttribute {Computed : true },
89+ "username" : schema.StringAttribute {Computed : true },
90+ },
91+ },
92+ "update_window" : schema.SingleNestedAttribute {
93+ Computed : true ,
94+ MarkdownDescription : "Daily time window (UTC) during which auto-updates are allowed." ,
95+ Attributes : map [string ]schema.Attribute {
96+ "start_hour" : schema.Int64Attribute {
97+ Computed : true ,
98+ MarkdownDescription : "Start of the update window as a UTC hour (0-23)." ,
99+ },
100+ "end_hour" : schema.Int64Attribute {
101+ Computed : true ,
102+ MarkdownDescription : "End of the update window as a UTC hour (0-23)." ,
103+ },
89104 },
90105 },
91106 },
@@ -158,20 +173,9 @@ func mapRunnerToDataSourceModel(runner gitpod.Runner) runnerDataSourceModel {
158173 }
159174
160175 m .Spec = & runnerDataSourceSpecModel {
161- DesiredPhase : stringValueOrNull (string (runner .Spec .DesiredPhase )),
162- Variant : stringValueOrNull (string (runner .Spec .Variant )),
163- Configuration : & runnerDataSourceConfigModel {
164- AutoUpdate : types .BoolValue (runner .Spec .Configuration .AutoUpdate ),
165- DevcontainerImageCacheEnabled : types .BoolValue (runner .Spec .Configuration .DevcontainerImageCacheEnabled ),
166- Region : stringValueOrNull (runner .Spec .Configuration .Region ),
167- ReleaseChannel : stringValueOrNull (string (runner .Spec .Configuration .ReleaseChannel )),
168- LogLevel : stringValueOrNull (string (runner .Spec .Configuration .LogLevel )),
169- Metrics : & runnerDataSourceMetricsModel {
170- Enabled : types .BoolValue (runner .Spec .Configuration .Metrics .Enabled ),
171- URL : stringValueOrNull (runner .Spec .Configuration .Metrics .URL ),
172- Username : stringValueOrNull (runner .Spec .Configuration .Metrics .Username ),
173- },
174- },
176+ DesiredPhase : stringValueOrNull (string (runner .Spec .DesiredPhase )),
177+ Variant : stringValueOrNull (string (runner .Spec .Variant )),
178+ Configuration : mapRunnerConfigToDataSourceModel (runner ),
175179 }
176180
177181 statusAttrTypes := map [string ]attr.Type {
@@ -191,6 +195,29 @@ func mapRunnerToDataSourceModel(runner gitpod.Runner) runnerDataSourceModel {
191195 return m
192196}
193197
198+ func mapRunnerConfigToDataSourceModel (runner gitpod.Runner ) * runnerDataSourceConfigModel {
199+ cfg := & runnerDataSourceConfigModel {
200+ AutoUpdate : types .BoolValue (runner .Spec .Configuration .AutoUpdate ),
201+ DevcontainerImageCacheEnabled : types .BoolValue (runner .Spec .Configuration .DevcontainerImageCacheEnabled ),
202+ Region : stringValueOrNull (runner .Spec .Configuration .Region ),
203+ ReleaseChannel : stringValueOrNull (string (runner .Spec .Configuration .ReleaseChannel )),
204+ LogLevel : stringValueOrNull (string (runner .Spec .Configuration .LogLevel )),
205+ Metrics : & runnerDataSourceMetricsModel {
206+ Enabled : types .BoolValue (runner .Spec .Configuration .Metrics .Enabled ),
207+ ManagedMetricsEnabled : types .BoolValue (runner .Spec .Configuration .Metrics .ManagedMetricsEnabled ),
208+ URL : stringValueOrNull (runner .Spec .Configuration .Metrics .URL ),
209+ Username : stringValueOrNull (runner .Spec .Configuration .Metrics .Username ),
210+ },
211+ }
212+ if startHour , endHour , ok := mapUpdateWindowValues (runner .Spec .Configuration .UpdateWindow ); ok {
213+ cfg .UpdateWindow = & runnerDataSourceUpdateWindowModel {
214+ StartHour : startHour ,
215+ EndHour : endHour ,
216+ }
217+ }
218+ return cfg
219+ }
220+
194221// Data source models — separate from resource models since all fields
195222// are computed and there's no password field (API doesn't return it).
196223
@@ -210,16 +237,23 @@ type runnerDataSourceSpecModel struct {
210237}
211238
212239type runnerDataSourceConfigModel struct {
213- AutoUpdate types.Bool `tfsdk:"auto_update"`
214- DevcontainerImageCacheEnabled types.Bool `tfsdk:"devcontainer_image_cache_enabled"`
215- Region types.String `tfsdk:"region"`
216- ReleaseChannel types.String `tfsdk:"release_channel"`
217- LogLevel types.String `tfsdk:"log_level"`
218- Metrics * runnerDataSourceMetricsModel `tfsdk:"metrics"`
240+ AutoUpdate types.Bool `tfsdk:"auto_update"`
241+ DevcontainerImageCacheEnabled types.Bool `tfsdk:"devcontainer_image_cache_enabled"`
242+ Region types.String `tfsdk:"region"`
243+ ReleaseChannel types.String `tfsdk:"release_channel"`
244+ LogLevel types.String `tfsdk:"log_level"`
245+ Metrics * runnerDataSourceMetricsModel `tfsdk:"metrics"`
246+ UpdateWindow * runnerDataSourceUpdateWindowModel `tfsdk:"update_window"`
247+ }
248+
249+ type runnerDataSourceUpdateWindowModel struct {
250+ StartHour types.Int64 `tfsdk:"start_hour"`
251+ EndHour types.Int64 `tfsdk:"end_hour"`
219252}
220253
221254type runnerDataSourceMetricsModel struct {
222- Enabled types.Bool `tfsdk:"enabled"`
223- URL types.String `tfsdk:"url"`
224- Username types.String `tfsdk:"username"`
255+ Enabled types.Bool `tfsdk:"enabled"`
256+ ManagedMetricsEnabled types.Bool `tfsdk:"managed_metrics_enabled"`
257+ URL types.String `tfsdk:"url"`
258+ Username types.String `tfsdk:"username"`
225259}
0 commit comments