From a4d15bbbd5ce6e7b63cea69182a09bfc13aefd7c Mon Sep 17 00:00:00 2001 From: Duologic Date: Mon, 30 Dec 2024 16:50:53 +0100 Subject: [PATCH] fix: also include plural as this is used to configure policyRules --- generator/configurations.libsonnet | 43 ++++++++----- grafanaplane/zz/gvks.libsonnet | 96 ++++++++++++++++++++++++++++++ 2 files changed, 125 insertions(+), 14 deletions(-) diff --git a/generator/configurations.libsonnet b/generator/configurations.libsonnet index 0a2b3b3..c702899 100644 --- a/generator/configurations.libsonnet +++ b/generator/configurations.libsonnet @@ -1,4 +1,3 @@ -local namespaced = import './namespaced.libsonnet'; local crossplane = import 'github.com/jsonnet-libs/crossplane-libsonnet/crossplane/1.17/main.libsonnet'; local configuration(key, version) = @@ -6,28 +5,44 @@ local configuration(key, version) = conf.new(key) + conf.spec.withPackage('ghcr.io/grafana/crossplane/' + key + ':' + version); +local xrds = + std.map( + function(o) o.definition, + (import './namespaced.libsonnet'), + ); + +local crds = + std.filter( + function(crd) crd.spec.group != 'grafana.crossplane.io', + std.parseYaml(importstr './crds.yaml'), + ); + local gvkXRDs = std.flatMap( - function(def) [ + function(definition) [ { - group: def.definition.spec.group, + group: definition.spec.group, version: v.name, - kind: def.definition.spec.claimNames.kind, + kind: definition.spec.claimNames.kind, + plural: definition.spec.claimNames.plural, } - for v in def.definition.spec.versions + for v in definition.spec.versions ], - namespaced + xrds ); local gvkCRDs = - std.map( - function(def) { - local s = std.splitLimitR(def.composition.spec.pipeline[0].input.resources[0].base.apiVersion, '/', 1), - group: s[0], - version: s[1], - kind: def.composition.spec.pipeline[0].input.resources[0].base.kind, - }, - namespaced + std.flatMap( + function(definition) [ + { + group: definition.spec.group, + version: v.name, + kind: definition.spec.names.kind, + plural: definition.spec.names.plural, + } + for v in definition.spec.versions + ], + crds ); local groupSet(gvks) = diff --git a/grafanaplane/zz/gvks.libsonnet b/grafanaplane/zz/gvks.libsonnet index 60aa048..03efe80 100644 --- a/grafanaplane/zz/gvks.libsonnet +++ b/grafanaplane/zz/gvks.libsonnet @@ -4,26 +4,31 @@ { group: 'alerting.grafana.crossplane.io', kind: 'ContactPoint', + plural: 'contactpoints', version: 'v1alpha1', }, { group: 'alerting.grafana.crossplane.io', kind: 'MessageTemplate', + plural: 'messagetemplates', version: 'v1alpha1', }, { group: 'alerting.grafana.crossplane.io', kind: 'MuteTiming', + plural: 'mutetimings', version: 'v1alpha1', }, { group: 'alerting.grafana.crossplane.io', kind: 'NotificationPolicy', + plural: 'notificationpolicies', version: 'v1alpha1', }, { group: 'alerting.grafana.crossplane.io', kind: 'RuleGroup', + plural: 'rulegroups', version: 'v1alpha1', }, ], @@ -31,26 +36,31 @@ { group: 'alerting.grafana.net.namespaced', kind: 'ContactPoint', + plural: 'contactpoints', version: 'v1alpha1', }, { group: 'alerting.grafana.net.namespaced', kind: 'MessageTemplate', + plural: 'messagetemplates', version: 'v1alpha1', }, { group: 'alerting.grafana.net.namespaced', kind: 'MuteTiming', + plural: 'mutetimings', version: 'v1alpha1', }, { group: 'alerting.grafana.net.namespaced', kind: 'NotificationPolicy', + plural: 'notificationpolicies', version: 'v1alpha1', }, { group: 'alerting.grafana.net.namespaced', kind: 'RuleGroup', + plural: 'rulegroups', version: 'v1alpha1', }, ], @@ -60,31 +70,37 @@ { group: 'cloud.grafana.crossplane.io', kind: 'AccessPolicy', + plural: 'accesspolicies', version: 'v1alpha1', }, { group: 'cloud.grafana.crossplane.io', kind: 'AccessPolicyToken', + plural: 'accesspolicytokens', version: 'v1alpha1', }, { group: 'cloud.grafana.crossplane.io', kind: 'PluginInstallation', + plural: 'plugininstallations', version: 'v1alpha1', }, { group: 'cloud.grafana.crossplane.io', kind: 'Stack', + plural: 'stacks', version: 'v1alpha1', }, { group: 'cloud.grafana.crossplane.io', kind: 'StackServiceAccount', + plural: 'stackserviceaccounts', version: 'v1alpha1', }, { group: 'cloud.grafana.crossplane.io', kind: 'StackServiceAccountToken', + plural: 'stackserviceaccounttokens', version: 'v1alpha1', }, ], @@ -92,31 +108,37 @@ { group: 'cloud.grafana.net.namespaced', kind: 'AccessPolicy', + plural: 'accesspolicies', version: 'v1alpha1', }, { group: 'cloud.grafana.net.namespaced', kind: 'AccessPolicyToken', + plural: 'accesspolicytokens', version: 'v1alpha1', }, { group: 'cloud.grafana.net.namespaced', kind: 'PluginInstallation', + plural: 'plugininstallations', version: 'v1alpha1', }, { group: 'cloud.grafana.net.namespaced', kind: 'Stack', + plural: 'stacks', version: 'v1alpha1', }, { group: 'cloud.grafana.net.namespaced', kind: 'StackServiceAccount', + plural: 'stackserviceaccounts', version: 'v1alpha1', }, { group: 'cloud.grafana.net.namespaced', kind: 'StackServiceAccountToken', + plural: 'stackserviceaccounttokens', version: 'v1alpha1', }, ], @@ -126,26 +148,31 @@ { group: 'enterprise.grafana.crossplane.io', kind: 'DataSourcePermission', + plural: 'datasourcepermissions', version: 'v1alpha1', }, { group: 'enterprise.grafana.crossplane.io', kind: 'Report', + plural: 'reports', version: 'v1alpha1', }, { group: 'enterprise.grafana.crossplane.io', kind: 'RoleAssignment', + plural: 'roleassignments', version: 'v1alpha1', }, { group: 'enterprise.grafana.crossplane.io', kind: 'Role', + plural: 'roles', version: 'v1alpha1', }, { group: 'enterprise.grafana.crossplane.io', kind: 'TeamExternalGroup', + plural: 'teamexternalgroups', version: 'v1alpha1', }, ], @@ -153,26 +180,31 @@ { group: 'enterprise.grafana.net.namespaced', kind: 'DataSourcePermission', + plural: 'datasourcepermissions', version: 'v1alpha1', }, { group: 'enterprise.grafana.net.namespaced', kind: 'Report', + plural: 'reports', version: 'v1alpha1', }, { group: 'enterprise.grafana.net.namespaced', kind: 'RoleAssignment', + plural: 'roleassignments', version: 'v1alpha1', }, { group: 'enterprise.grafana.net.namespaced', kind: 'Role', + plural: 'roles', version: 'v1alpha1', }, { group: 'enterprise.grafana.net.namespaced', kind: 'TeamExternalGroup', + plural: 'teamexternalgroups', version: 'v1alpha1', }, ], @@ -182,16 +214,19 @@ { group: 'ml.grafana.crossplane.io', kind: 'Holiday', + plural: 'holidays', version: 'v1alpha1', }, { group: 'ml.grafana.crossplane.io', kind: 'Job', + plural: 'jobs', version: 'v1alpha1', }, { group: 'ml.grafana.crossplane.io', kind: 'OutlierDetector', + plural: 'outlierdetectors', version: 'v1alpha1', }, ], @@ -199,16 +234,19 @@ { group: 'ml.grafana.net.namespaced', kind: 'Holiday', + plural: 'holidays', version: 'v1alpha1', }, { group: 'ml.grafana.net.namespaced', kind: 'Job', + plural: 'jobs', version: 'v1alpha1', }, { group: 'ml.grafana.net.namespaced', kind: 'OutlierDetector', + plural: 'outlierdetectors', version: 'v1alpha1', }, ], @@ -218,41 +256,49 @@ { group: 'oncall.grafana.crossplane.io', kind: 'EscalationChain', + plural: 'escalationchains', version: 'v1alpha1', }, { group: 'oncall.grafana.crossplane.io', kind: 'Escalation', + plural: 'escalations', version: 'v1alpha1', }, { group: 'oncall.grafana.crossplane.io', kind: 'Integration', + plural: 'integrations', version: 'v1alpha1', }, { group: 'oncall.grafana.crossplane.io', kind: 'OnCallShift', + plural: 'oncallshifts', version: 'v1alpha1', }, { group: 'oncall.grafana.crossplane.io', kind: 'OutgoingWebhook', + plural: 'outgoingwebhooks', version: 'v1alpha1', }, { group: 'oncall.grafana.crossplane.io', kind: 'Route', + plural: 'routes', version: 'v1alpha1', }, { group: 'oncall.grafana.crossplane.io', kind: 'Schedule', + plural: 'schedules', version: 'v1alpha1', }, { group: 'oncall.grafana.crossplane.io', kind: 'UserNotificationRule', + plural: 'usernotificationrules', version: 'v1alpha1', }, ], @@ -260,41 +306,49 @@ { group: 'oncall.grafana.net.namespaced', kind: 'EscalationChain', + plural: 'escalationchains', version: 'v1alpha1', }, { group: 'oncall.grafana.net.namespaced', kind: 'Escalation', + plural: 'escalations', version: 'v1alpha1', }, { group: 'oncall.grafana.net.namespaced', kind: 'Integration', + plural: 'integrations', version: 'v1alpha1', }, { group: 'oncall.grafana.net.namespaced', kind: 'OnCallShift', + plural: 'oncallshifts', version: 'v1alpha1', }, { group: 'oncall.grafana.net.namespaced', kind: 'OutgoingWebhook', + plural: 'outgoingwebhooks', version: 'v1alpha1', }, { group: 'oncall.grafana.net.namespaced', kind: 'Route', + plural: 'routes', version: 'v1alpha1', }, { group: 'oncall.grafana.net.namespaced', kind: 'Schedule', + plural: 'schedules', version: 'v1alpha1', }, { group: 'oncall.grafana.net.namespaced', kind: 'UserNotificationRule', + plural: 'usernotificationrules', version: 'v1alpha1', }, ], @@ -304,86 +358,103 @@ { group: 'oss.grafana.crossplane.io', kind: 'Annotation', + plural: 'annotations', version: 'v1alpha1', }, { group: 'oss.grafana.crossplane.io', kind: 'DashboardPermission', + plural: 'dashboardpermissions', version: 'v1alpha1', }, { group: 'oss.grafana.crossplane.io', kind: 'DashboardPublic', + plural: 'dashboardpublics', version: 'v1alpha1', }, { group: 'oss.grafana.crossplane.io', kind: 'Dashboard', + plural: 'dashboards', version: 'v1alpha1', }, { group: 'oss.grafana.crossplane.io', kind: 'DataSource', + plural: 'datasources', version: 'v1alpha1', }, { group: 'oss.grafana.crossplane.io', kind: 'FolderPermission', + plural: 'folderpermissions', version: 'v1alpha1', }, { group: 'oss.grafana.crossplane.io', kind: 'Folder', + plural: 'folders', version: 'v1alpha1', }, { group: 'oss.grafana.crossplane.io', kind: 'LibraryPanel', + plural: 'librarypanels', version: 'v1alpha1', }, { group: 'oss.grafana.crossplane.io', kind: 'OrganizationPreferences', + plural: 'organizationpreferences', version: 'v1alpha1', }, { group: 'oss.grafana.crossplane.io', kind: 'Organization', + plural: 'organizations', version: 'v1alpha1', }, { group: 'oss.grafana.crossplane.io', kind: 'Playlist', + plural: 'playlists', version: 'v1alpha1', }, { group: 'oss.grafana.crossplane.io', kind: 'ServiceAccountPermission', + plural: 'serviceaccountpermissions', version: 'v1alpha1', }, { group: 'oss.grafana.crossplane.io', kind: 'ServiceAccount', + plural: 'serviceaccounts', version: 'v1alpha1', }, { group: 'oss.grafana.crossplane.io', kind: 'ServiceAccountToken', + plural: 'serviceaccounttokens', version: 'v1alpha1', }, { group: 'oss.grafana.crossplane.io', kind: 'SsoSettings', + plural: 'ssosettings', version: 'v1alpha1', }, { group: 'oss.grafana.crossplane.io', kind: 'Team', + plural: 'teams', version: 'v1alpha1', }, { group: 'oss.grafana.crossplane.io', kind: 'User', + plural: 'users', version: 'v1alpha1', }, ], @@ -391,86 +462,103 @@ { group: 'oss.grafana.net.namespaced', kind: 'Annotation', + plural: 'annotations', version: 'v1alpha1', }, { group: 'oss.grafana.net.namespaced', kind: 'DashboardPermission', + plural: 'dashboardpermissions', version: 'v1alpha1', }, { group: 'oss.grafana.net.namespaced', kind: 'DashboardPublic', + plural: 'dashboardpublics', version: 'v1alpha1', }, { group: 'oss.grafana.net.namespaced', kind: 'Dashboard', + plural: 'dashboards', version: 'v1alpha1', }, { group: 'oss.grafana.net.namespaced', kind: 'DataSource', + plural: 'datasources', version: 'v1alpha1', }, { group: 'oss.grafana.net.namespaced', kind: 'FolderPermission', + plural: 'folderpermissions', version: 'v1alpha1', }, { group: 'oss.grafana.net.namespaced', kind: 'Folder', + plural: 'folders', version: 'v1alpha1', }, { group: 'oss.grafana.net.namespaced', kind: 'LibraryPanel', + plural: 'librarypanels', version: 'v1alpha1', }, { group: 'oss.grafana.net.namespaced', kind: 'OrganizationPreferences', + plural: 'organizationpreferences', version: 'v1alpha1', }, { group: 'oss.grafana.net.namespaced', kind: 'Organization', + plural: 'organizations', version: 'v1alpha1', }, { group: 'oss.grafana.net.namespaced', kind: 'Playlist', + plural: 'playlists', version: 'v1alpha1', }, { group: 'oss.grafana.net.namespaced', kind: 'ServiceAccountPermission', + plural: 'serviceaccountpermissions', version: 'v1alpha1', }, { group: 'oss.grafana.net.namespaced', kind: 'ServiceAccount', + plural: 'serviceaccounts', version: 'v1alpha1', }, { group: 'oss.grafana.net.namespaced', kind: 'ServiceAccountToken', + plural: 'serviceaccounttokens', version: 'v1alpha1', }, { group: 'oss.grafana.net.namespaced', kind: 'SsoSettings', + plural: 'ssosettings', version: 'v1alpha1', }, { group: 'oss.grafana.net.namespaced', kind: 'Team', + plural: 'teams', version: 'v1alpha1', }, { group: 'oss.grafana.net.namespaced', kind: 'User', + plural: 'users', version: 'v1alpha1', }, ], @@ -480,6 +568,7 @@ { group: 'slo.grafana.crossplane.io', kind: 'SLO', + plural: 'slos', version: 'v1alpha1', }, ], @@ -487,6 +576,7 @@ { group: 'slo.grafana.net.namespaced', kind: 'SLO', + plural: 'slos', version: 'v1alpha1', }, ], @@ -496,16 +586,19 @@ { group: 'sm.grafana.crossplane.io', kind: 'Check', + plural: 'checks', version: 'v1alpha1', }, { group: 'sm.grafana.crossplane.io', kind: 'Installation', + plural: 'installations', version: 'v1alpha1', }, { group: 'sm.grafana.crossplane.io', kind: 'Probe', + plural: 'probes', version: 'v1alpha1', }, ], @@ -513,16 +606,19 @@ { group: 'sm.grafana.net.namespaced', kind: 'Check', + plural: 'checks', version: 'v1alpha1', }, { group: 'sm.grafana.net.namespaced', kind: 'Installation', + plural: 'installations', version: 'v1alpha1', }, { group: 'sm.grafana.net.namespaced', kind: 'Probe', + plural: 'probes', version: 'v1alpha1', }, ],