Skip to content

Commit

Permalink
feat(oncall): add newCalendar constructor for Schedules
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-bauer committed Dec 30, 2024
1 parent 02b30a7 commit 55a3b12
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions grafanaplane/oncall/schedule.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ local xtd = import 'github.com/jsonnet-libs/xtd/main.libsonnet';
local raw = import '../zz/main.libsonnet';

{
local this = self,
local schedule = raw.oncall.v1alpha1.schedule,
'#new': d.func.new(
|||
Expand All @@ -25,4 +26,34 @@ local raw = import '../zz/main.libsonnet';
+ schedule.spec.parameters.providerConfigRef.withName(providerName)
+ schedule.spec.parameters.forProvider.withName(name)
+ schedule.spec.parameters.forProvider.withType(type),

'#newCalendar': d.func.new(
|||
`newCalendar` creates a Schedule with type `calendar`. The `name` is a
display-friendly string, and `resourceId` defaults to a slug-ified
version of it. `providerName` is the resource name
(`myprovider.metadata.name`) of the Provider. If supplied, `shiftNames`
are supplied to `withShiftsRef` to associate an array of shifts by
resource name.
|||,
[
d.argument.new('name', d.T.string),
d.argument.new('providerName', d.T.string),
d.argument.new('shiftNames', d.T.array, default='[]'),
d.argument.new('resourceId', d.T.string, default='rfc1123(name)'),
]
),
newCalendar(name, providerName, shiftNames=[], resourceId=null)::
this.new(name, 'calendar', providerName, resourceId)
+ this.withShiftsRef(shiftNames),

'#withShifts': d.func.new(|||
`withShifts` sets an array of `shiftsRef` objects on a Schedule. `names` is
an array of OnCallShift resource names.
|||),
withShiftsRef(names)::
schedule.spec.parameters.forProvider.withShiftsRef([
schedule.spec.parameters.forProvider.shiftsRef.withName(name)
for name in names
]),
}

0 comments on commit 55a3b12

Please sign in to comment.