From 104017cde3fdbd8c3a6e43237481f4526b84e11d Mon Sep 17 00:00:00 2001 From: Sasha Bauer Date: Thu, 2 Jan 2025 13:47:04 -0500 Subject: [PATCH] fix(oncall): require names, rather than names or manifests --- grafanaplane/oncall/escalationchain.libsonnet | 11 +++++------ grafanaplane/oncall/integration.libsonnet | 11 +++++------ grafanaplane/oncall/schedule.libsonnet | 9 ++++----- grafanaplane/util.libsonnet | 17 ----------------- 4 files changed, 14 insertions(+), 34 deletions(-) delete mode 100644 grafanaplane/util.libsonnet diff --git a/grafanaplane/oncall/escalationchain.libsonnet b/grafanaplane/oncall/escalationchain.libsonnet index f4393c7..c7dc718 100644 --- a/grafanaplane/oncall/escalationchain.libsonnet +++ b/grafanaplane/oncall/escalationchain.libsonnet @@ -1,7 +1,6 @@ local d = import 'github.com/jsonnet-libs/docsonnet/doc-util/main.libsonnet'; local xtd = import 'github.com/jsonnet-libs/xtd/main.libsonnet'; -local util = import '../util.libsonnet'; local raw = import '../zz/main.libsonnet'; local escalationChain = raw.oncall.v1alpha1.escalationChain; local escalation = raw.oncall.v1alpha1.escalation; @@ -66,15 +65,15 @@ local escalation = raw.oncall.v1alpha1.escalation; '#notifyOnCallFromSchedule':: d.func.new( ||| `notifyOnCallFromSchedule` configures an Escalation step to notify - on-call persons from the given Schedule. `schedule` may be either a - Schedule resource name or a manifest. + on-call persons from the given Schedule. `scheduleName` must be the + Schedule resource name. |||, - [d.argument.new('schedule', 'string|object')] + [d.argument.new('schedule', 'string')] ), - notifyOnCallFromSchedule(schedule):: + notifyOnCallFromSchedule(scheduleName):: forProvider.withType('notify_on_call_from_schedule') + forProvider.withNotifyOnCallFromScheduleRef( - forProvider.notifyOnCallFromScheduleRef.withName(util.getName(schedule)) + forProvider.notifyOnCallFromScheduleRef.withName(scheduleName) ), '#notifyPersons':: d.func.new( diff --git a/grafanaplane/oncall/integration.libsonnet b/grafanaplane/oncall/integration.libsonnet index db9ff7e..4f549ec 100644 --- a/grafanaplane/oncall/integration.libsonnet +++ b/grafanaplane/oncall/integration.libsonnet @@ -1,7 +1,6 @@ local d = import 'github.com/jsonnet-libs/docsonnet/doc-util/main.libsonnet'; local xtd = import 'github.com/jsonnet-libs/xtd/main.libsonnet'; -local util = import '../util.libsonnet'; local raw = import '../zz/main.libsonnet'; local integration = raw.oncall.v1alpha1.integration; local route = raw.oncall.v1alpha1.route; @@ -32,17 +31,17 @@ forProvider '#withDefaultChain':: d.func.new( ||| `withDefaulChain` configures the default route of an Integration to use - an Escalation Chain. `escalationChain` is the resource name or manifest - of the desired Escalation Chain. + an Escalation Chain. `escalationChain` is the resource name of the + desired Escalation Chain. |||, [ - d.argument.new('escalationChain', d.T.string), + d.argument.new('escalationChainName', d.T.string), ] ), - withDefaultChain(escalationChain):: { + withDefaultChain(escalationChainName):: { integration+: forProvider.withDefaultRoute( - forProvider.defaultRoute.escalationChainRef.withName(util.getName(escalationChain)) + forProvider.defaultRoute.escalationChainRef.withName(escalationChainName) ), }, diff --git a/grafanaplane/oncall/schedule.libsonnet b/grafanaplane/oncall/schedule.libsonnet index 6ab7690..c60d7a1 100644 --- a/grafanaplane/oncall/schedule.libsonnet +++ b/grafanaplane/oncall/schedule.libsonnet @@ -1,7 +1,6 @@ local d = import 'github.com/jsonnet-libs/docsonnet/doc-util/main.libsonnet'; local xtd = import 'github.com/jsonnet-libs/xtd/main.libsonnet'; -local util = import '../util.libsonnet'; local raw = import '../zz/main.libsonnet'; local schedule = raw.oncall.v1alpha1.schedule; local forProvider = schedule.spec.parameters.forProvider; @@ -29,16 +28,16 @@ forProvider // raise forProvider functions to here ||| `withShifts` sets a Schedule to type `calendar` and configures shifts. Shifts are only applicable to `calendar` type Schedules. `shifts` is an - array of Shift resource names or entire Shift manifests. + array of Shift resource names. |||, [ - d.argument.new('shifts', d.T.array, default='null'), + d.argument.new('shifts', d.T.array), ] ), - withShifts(shifts=null):: + withShifts(shifts):: super.withType('calendar') + super.withShiftsRef([ - super.shiftsRef.withName(util.getName(shift)) + super.shiftsRef.withName(shift) for shift in shifts ]), } diff --git a/grafanaplane/util.libsonnet b/grafanaplane/util.libsonnet deleted file mode 100644 index 1c1b8c4..0000000 --- a/grafanaplane/util.libsonnet +++ /dev/null @@ -1,17 +0,0 @@ -local d = import 'github.com/jsonnet-libs/docsonnet/doc-util/main.libsonnet'; - -{ - '#':: d.package.newSub('util', 'internal utilities'), - - '#getName':: d.func.new( - ||| - `getName` is supplied either a name or a manifest, and returns just the - name as a string. - |||, - [d.argument.new('nameOrManifest', 'string|object')] - ), - getName(nameOrManifest):: - if std.isString(nameOrManifest) - then nameOrManifest - else nameOrManifest.metadata.name, -}