Skip to content

Commit

Permalink
fix(generator): trim group name for CompositeResourceDefinitions (#16)
Browse files Browse the repository at this point in the history
* fix(generator): trim group name for CompositeResourceDefinitions

* chore: generate files
  • Loading branch information
Duologic authored Dec 20, 2024
1 parent 74dcda6 commit 493b1f1
Show file tree
Hide file tree
Showing 146 changed files with 267 additions and 243 deletions.
4 changes: 2 additions & 2 deletions generator/main.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ local mergeDocstring(group, version, name, obj, help='') =
local compositions =
std.foldl(
function(acc, def)
local render = crdsonnet.xrd.render(def.definition, 'grafana.crossplane.io', processor);
local render = crdsonnet.xrd.render(def.definition, 'grafana.net', processor);

local group = helpers.getGroupKey(def.definition.spec.group, 'grafana.crossplane.io');
local group = helpers.getGroupKey(def.definition.spec.group, 'grafana.net');
local version = 'v1alpha1';
local kind = helpers.camelCaseKind(crdsonnet.xrd.getKind(def.definition));

Expand Down
26 changes: 25 additions & 1 deletion generator/namespaced.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,28 @@ local crds =
std.parseYaml(importstr './crds.yaml'),
);

std.map(cngen.fromCRD, crds)
// XRD metadata.name consists of `plural+group`, for some resources this became longer than 63 characters, which resulted in this error:
// 'cannot establish control of object: Composition.apiextensions.crossplane.io "stackserviceaccounttoken-namespaced" is invalid: metadata.labels: Invalid value:"xstackserviceaccounttokens.cloud.grafana.crossplane.io.namespaced": must be no more than 63 characters'
local renameGroup(obj) =
assert std.trace(std.manifestJson(obj.definition.metadata), true);
local name = std.strReplace(obj.definition.metadata.name, 'crossplane.io', 'net');
assert std.length(name) <= 63 : 'CompositeResourceDefinition names must be no more than 63 characters';
obj + {
definition+: {
metadata+: {
name: name,
},
spec+: {
group: std.strReplace(super.group, 'crossplane.io', 'net'),
},
},
};

std.foldr(
std.map,
[
renameGroup,
cngen.fromCRD,
],
crds,
)
2 changes: 1 addition & 1 deletion grafanaplane/alerting/v1alpha1/contactPoint/main.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
+ self.metadata.withName(name),
'#withApiVersion': { 'function': { args: [], help: '' } },
withApiVersion(): {
apiVersion: 'alerting.grafana.crossplane.io.namespaced/v1alpha1',
apiVersion: 'alerting.grafana.net.namespaced/v1alpha1',
},
'#withKind': { 'function': { args: [], help: '' } },
withKind(): {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
+ self.metadata.withName(name),
'#withApiVersion': { 'function': { args: [], help: '' } },
withApiVersion(): {
apiVersion: 'alerting.grafana.crossplane.io.namespaced/v1alpha1',
apiVersion: 'alerting.grafana.net.namespaced/v1alpha1',
},
'#withKind': { 'function': { args: [], help: '' } },
withKind(): {
Expand Down
2 changes: 1 addition & 1 deletion grafanaplane/alerting/v1alpha1/muteTiming/main.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
+ self.metadata.withName(name),
'#withApiVersion': { 'function': { args: [], help: '' } },
withApiVersion(): {
apiVersion: 'alerting.grafana.crossplane.io.namespaced/v1alpha1',
apiVersion: 'alerting.grafana.net.namespaced/v1alpha1',
},
'#withKind': { 'function': { args: [], help: '' } },
withKind(): {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
+ self.metadata.withName(name),
'#withApiVersion': { 'function': { args: [], help: '' } },
withApiVersion(): {
apiVersion: 'alerting.grafana.crossplane.io.namespaced/v1alpha1',
apiVersion: 'alerting.grafana.net.namespaced/v1alpha1',
},
'#withKind': { 'function': { args: [], help: '' } },
withKind(): {
Expand Down
2 changes: 1 addition & 1 deletion grafanaplane/alerting/v1alpha1/ruleGroup/main.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
+ self.metadata.withName(name),
'#withApiVersion': { 'function': { args: [], help: '' } },
withApiVersion(): {
apiVersion: 'alerting.grafana.crossplane.io.namespaced/v1alpha1',
apiVersion: 'alerting.grafana.net.namespaced/v1alpha1',
},
'#withKind': { 'function': { args: [], help: '' } },
withKind(): {
Expand Down
2 changes: 1 addition & 1 deletion grafanaplane/cloud/v1alpha1/accessPolicy/main.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
+ self.metadata.withName(name),
'#withApiVersion': { 'function': { args: [], help: '' } },
withApiVersion(): {
apiVersion: 'cloud.grafana.crossplane.io.namespaced/v1alpha1',
apiVersion: 'cloud.grafana.net.namespaced/v1alpha1',
},
'#withKind': { 'function': { args: [], help: '' } },
withKind(): {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
+ self.metadata.withName(name),
'#withApiVersion': { 'function': { args: [], help: '' } },
withApiVersion(): {
apiVersion: 'cloud.grafana.crossplane.io.namespaced/v1alpha1',
apiVersion: 'cloud.grafana.net.namespaced/v1alpha1',
},
'#withKind': { 'function': { args: [], help: '' } },
withKind(): {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
+ self.metadata.withName(name),
'#withApiVersion': { 'function': { args: [], help: '' } },
withApiVersion(): {
apiVersion: 'cloud.grafana.crossplane.io.namespaced/v1alpha1',
apiVersion: 'cloud.grafana.net.namespaced/v1alpha1',
},
'#withKind': { 'function': { args: [], help: '' } },
withKind(): {
Expand Down
2 changes: 1 addition & 1 deletion grafanaplane/cloud/v1alpha1/stack/main.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
+ self.metadata.withName(name),
'#withApiVersion': { 'function': { args: [], help: '' } },
withApiVersion(): {
apiVersion: 'cloud.grafana.crossplane.io.namespaced/v1alpha1',
apiVersion: 'cloud.grafana.net.namespaced/v1alpha1',
},
'#withKind': { 'function': { args: [], help: '' } },
withKind(): {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
+ self.metadata.withName(name),
'#withApiVersion': { 'function': { args: [], help: '' } },
withApiVersion(): {
apiVersion: 'cloud.grafana.crossplane.io.namespaced/v1alpha1',
apiVersion: 'cloud.grafana.net.namespaced/v1alpha1',
},
'#withKind': { 'function': { args: [], help: '' } },
withKind(): {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
+ self.metadata.withName(name),
'#withApiVersion': { 'function': { args: [], help: '' } },
withApiVersion(): {
apiVersion: 'cloud.grafana.crossplane.io.namespaced/v1alpha1',
apiVersion: 'cloud.grafana.net.namespaced/v1alpha1',
},
'#withKind': { 'function': { args: [], help: '' } },
withKind(): {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
+ self.metadata.withName(name),
'#withApiVersion': { 'function': { args: [], help: '' } },
withApiVersion(): {
apiVersion: 'enterprise.grafana.crossplane.io.namespaced/v1alpha1',
apiVersion: 'enterprise.grafana.net.namespaced/v1alpha1',
},
'#withKind': { 'function': { args: [], help: '' } },
withKind(): {
Expand Down
2 changes: 1 addition & 1 deletion grafanaplane/enterprise/v1alpha1/report/main.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
+ self.metadata.withName(name),
'#withApiVersion': { 'function': { args: [], help: '' } },
withApiVersion(): {
apiVersion: 'enterprise.grafana.crossplane.io.namespaced/v1alpha1',
apiVersion: 'enterprise.grafana.net.namespaced/v1alpha1',
},
'#withKind': { 'function': { args: [], help: '' } },
withKind(): {
Expand Down
2 changes: 1 addition & 1 deletion grafanaplane/enterprise/v1alpha1/role/main.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
+ self.metadata.withName(name),
'#withApiVersion': { 'function': { args: [], help: '' } },
withApiVersion(): {
apiVersion: 'enterprise.grafana.crossplane.io.namespaced/v1alpha1',
apiVersion: 'enterprise.grafana.net.namespaced/v1alpha1',
},
'#withKind': { 'function': { args: [], help: '' } },
withKind(): {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
+ self.metadata.withName(name),
'#withApiVersion': { 'function': { args: [], help: '' } },
withApiVersion(): {
apiVersion: 'enterprise.grafana.crossplane.io.namespaced/v1alpha1',
apiVersion: 'enterprise.grafana.net.namespaced/v1alpha1',
},
'#withKind': { 'function': { args: [], help: '' } },
withKind(): {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
+ self.metadata.withName(name),
'#withApiVersion': { 'function': { args: [], help: '' } },
withApiVersion(): {
apiVersion: 'enterprise.grafana.crossplane.io.namespaced/v1alpha1',
apiVersion: 'enterprise.grafana.net.namespaced/v1alpha1',
},
'#withKind': { 'function': { args: [], help: '' } },
withKind(): {
Expand Down
2 changes: 1 addition & 1 deletion grafanaplane/ml/v1alpha1/holiday/main.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
+ self.metadata.withName(name),
'#withApiVersion': { 'function': { args: [], help: '' } },
withApiVersion(): {
apiVersion: 'ml.grafana.crossplane.io.namespaced/v1alpha1',
apiVersion: 'ml.grafana.net.namespaced/v1alpha1',
},
'#withKind': { 'function': { args: [], help: '' } },
withKind(): {
Expand Down
2 changes: 1 addition & 1 deletion grafanaplane/ml/v1alpha1/job/main.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
+ self.metadata.withName(name),
'#withApiVersion': { 'function': { args: [], help: '' } },
withApiVersion(): {
apiVersion: 'ml.grafana.crossplane.io.namespaced/v1alpha1',
apiVersion: 'ml.grafana.net.namespaced/v1alpha1',
},
'#withKind': { 'function': { args: [], help: '' } },
withKind(): {
Expand Down
2 changes: 1 addition & 1 deletion grafanaplane/ml/v1alpha1/outlierDetector/main.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
+ self.metadata.withName(name),
'#withApiVersion': { 'function': { args: [], help: '' } },
withApiVersion(): {
apiVersion: 'ml.grafana.crossplane.io.namespaced/v1alpha1',
apiVersion: 'ml.grafana.net.namespaced/v1alpha1',
},
'#withKind': { 'function': { args: [], help: '' } },
withKind(): {
Expand Down
2 changes: 1 addition & 1 deletion grafanaplane/oncall/v1alpha1/escalation/main.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
+ self.metadata.withName(name),
'#withApiVersion': { 'function': { args: [], help: '' } },
withApiVersion(): {
apiVersion: 'oncall.grafana.crossplane.io.namespaced/v1alpha1',
apiVersion: 'oncall.grafana.net.namespaced/v1alpha1',
},
'#withKind': { 'function': { args: [], help: '' } },
withKind(): {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
+ self.metadata.withName(name),
'#withApiVersion': { 'function': { args: [], help: '' } },
withApiVersion(): {
apiVersion: 'oncall.grafana.crossplane.io.namespaced/v1alpha1',
apiVersion: 'oncall.grafana.net.namespaced/v1alpha1',
},
'#withKind': { 'function': { args: [], help: '' } },
withKind(): {
Expand Down
2 changes: 1 addition & 1 deletion grafanaplane/oncall/v1alpha1/integration/main.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
+ self.metadata.withName(name),
'#withApiVersion': { 'function': { args: [], help: '' } },
withApiVersion(): {
apiVersion: 'oncall.grafana.crossplane.io.namespaced/v1alpha1',
apiVersion: 'oncall.grafana.net.namespaced/v1alpha1',
},
'#withKind': { 'function': { args: [], help: '' } },
withKind(): {
Expand Down
2 changes: 1 addition & 1 deletion grafanaplane/oncall/v1alpha1/onCallShift/main.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
+ self.metadata.withName(name),
'#withApiVersion': { 'function': { args: [], help: '' } },
withApiVersion(): {
apiVersion: 'oncall.grafana.crossplane.io.namespaced/v1alpha1',
apiVersion: 'oncall.grafana.net.namespaced/v1alpha1',
},
'#withKind': { 'function': { args: [], help: '' } },
withKind(): {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
+ self.metadata.withName(name),
'#withApiVersion': { 'function': { args: [], help: '' } },
withApiVersion(): {
apiVersion: 'oncall.grafana.crossplane.io.namespaced/v1alpha1',
apiVersion: 'oncall.grafana.net.namespaced/v1alpha1',
},
'#withKind': { 'function': { args: [], help: '' } },
withKind(): {
Expand Down
2 changes: 1 addition & 1 deletion grafanaplane/oncall/v1alpha1/route/main.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
+ self.metadata.withName(name),
'#withApiVersion': { 'function': { args: [], help: '' } },
withApiVersion(): {
apiVersion: 'oncall.grafana.crossplane.io.namespaced/v1alpha1',
apiVersion: 'oncall.grafana.net.namespaced/v1alpha1',
},
'#withKind': { 'function': { args: [], help: '' } },
withKind(): {
Expand Down
2 changes: 1 addition & 1 deletion grafanaplane/oncall/v1alpha1/schedule/main.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
+ self.metadata.withName(name),
'#withApiVersion': { 'function': { args: [], help: '' } },
withApiVersion(): {
apiVersion: 'oncall.grafana.crossplane.io.namespaced/v1alpha1',
apiVersion: 'oncall.grafana.net.namespaced/v1alpha1',
},
'#withKind': { 'function': { args: [], help: '' } },
withKind(): {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
+ self.metadata.withName(name),
'#withApiVersion': { 'function': { args: [], help: '' } },
withApiVersion(): {
apiVersion: 'oncall.grafana.crossplane.io.namespaced/v1alpha1',
apiVersion: 'oncall.grafana.net.namespaced/v1alpha1',
},
'#withKind': { 'function': { args: [], help: '' } },
withKind(): {
Expand Down
2 changes: 1 addition & 1 deletion grafanaplane/oss/v1alpha1/annotation/main.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
+ self.metadata.withName(name),
'#withApiVersion': { 'function': { args: [], help: '' } },
withApiVersion(): {
apiVersion: 'oss.grafana.crossplane.io.namespaced/v1alpha1',
apiVersion: 'oss.grafana.net.namespaced/v1alpha1',
},
'#withKind': { 'function': { args: [], help: '' } },
withKind(): {
Expand Down
2 changes: 1 addition & 1 deletion grafanaplane/oss/v1alpha1/dashboard/main.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
+ self.metadata.withName(name),
'#withApiVersion': { 'function': { args: [], help: '' } },
withApiVersion(): {
apiVersion: 'oss.grafana.crossplane.io.namespaced/v1alpha1',
apiVersion: 'oss.grafana.net.namespaced/v1alpha1',
},
'#withKind': { 'function': { args: [], help: '' } },
withKind(): {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
+ self.metadata.withName(name),
'#withApiVersion': { 'function': { args: [], help: '' } },
withApiVersion(): {
apiVersion: 'oss.grafana.crossplane.io.namespaced/v1alpha1',
apiVersion: 'oss.grafana.net.namespaced/v1alpha1',
},
'#withKind': { 'function': { args: [], help: '' } },
withKind(): {
Expand Down
2 changes: 1 addition & 1 deletion grafanaplane/oss/v1alpha1/dashboardPublic/main.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
+ self.metadata.withName(name),
'#withApiVersion': { 'function': { args: [], help: '' } },
withApiVersion(): {
apiVersion: 'oss.grafana.crossplane.io.namespaced/v1alpha1',
apiVersion: 'oss.grafana.net.namespaced/v1alpha1',
},
'#withKind': { 'function': { args: [], help: '' } },
withKind(): {
Expand Down
2 changes: 1 addition & 1 deletion grafanaplane/oss/v1alpha1/dataSource/main.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
+ self.metadata.withName(name),
'#withApiVersion': { 'function': { args: [], help: '' } },
withApiVersion(): {
apiVersion: 'oss.grafana.crossplane.io.namespaced/v1alpha1',
apiVersion: 'oss.grafana.net.namespaced/v1alpha1',
},
'#withKind': { 'function': { args: [], help: '' } },
withKind(): {
Expand Down
2 changes: 1 addition & 1 deletion grafanaplane/oss/v1alpha1/folder/main.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
+ self.metadata.withName(name),
'#withApiVersion': { 'function': { args: [], help: '' } },
withApiVersion(): {
apiVersion: 'oss.grafana.crossplane.io.namespaced/v1alpha1',
apiVersion: 'oss.grafana.net.namespaced/v1alpha1',
},
'#withKind': { 'function': { args: [], help: '' } },
withKind(): {
Expand Down
2 changes: 1 addition & 1 deletion grafanaplane/oss/v1alpha1/folderPermission/main.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
+ self.metadata.withName(name),
'#withApiVersion': { 'function': { args: [], help: '' } },
withApiVersion(): {
apiVersion: 'oss.grafana.crossplane.io.namespaced/v1alpha1',
apiVersion: 'oss.grafana.net.namespaced/v1alpha1',
},
'#withKind': { 'function': { args: [], help: '' } },
withKind(): {
Expand Down
2 changes: 1 addition & 1 deletion grafanaplane/oss/v1alpha1/libraryPanel/main.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
+ self.metadata.withName(name),
'#withApiVersion': { 'function': { args: [], help: '' } },
withApiVersion(): {
apiVersion: 'oss.grafana.crossplane.io.namespaced/v1alpha1',
apiVersion: 'oss.grafana.net.namespaced/v1alpha1',
},
'#withKind': { 'function': { args: [], help: '' } },
withKind(): {
Expand Down
2 changes: 1 addition & 1 deletion grafanaplane/oss/v1alpha1/organization/main.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
+ self.metadata.withName(name),
'#withApiVersion': { 'function': { args: [], help: '' } },
withApiVersion(): {
apiVersion: 'oss.grafana.crossplane.io.namespaced/v1alpha1',
apiVersion: 'oss.grafana.net.namespaced/v1alpha1',
},
'#withKind': { 'function': { args: [], help: '' } },
withKind(): {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
+ self.metadata.withName(name),
'#withApiVersion': { 'function': { args: [], help: '' } },
withApiVersion(): {
apiVersion: 'oss.grafana.crossplane.io.namespaced/v1alpha1',
apiVersion: 'oss.grafana.net.namespaced/v1alpha1',
},
'#withKind': { 'function': { args: [], help: '' } },
withKind(): {
Expand Down
2 changes: 1 addition & 1 deletion grafanaplane/oss/v1alpha1/playlist/main.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
+ self.metadata.withName(name),
'#withApiVersion': { 'function': { args: [], help: '' } },
withApiVersion(): {
apiVersion: 'oss.grafana.crossplane.io.namespaced/v1alpha1',
apiVersion: 'oss.grafana.net.namespaced/v1alpha1',
},
'#withKind': { 'function': { args: [], help: '' } },
withKind(): {
Expand Down
2 changes: 1 addition & 1 deletion grafanaplane/oss/v1alpha1/serviceAccount/main.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
+ self.metadata.withName(name),
'#withApiVersion': { 'function': { args: [], help: '' } },
withApiVersion(): {
apiVersion: 'oss.grafana.crossplane.io.namespaced/v1alpha1',
apiVersion: 'oss.grafana.net.namespaced/v1alpha1',
},
'#withKind': { 'function': { args: [], help: '' } },
withKind(): {
Expand Down
Loading

0 comments on commit 493b1f1

Please sign in to comment.