-
Notifications
You must be signed in to change notification settings - Fork 2.1k
chore: Replace gojsontoyaml with gojq #2660
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
verbs: | ||
- list | ||
- watch | ||
- apiGroups: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: should it have this space?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the way lists are treated with gojq is different from gojsontoyaml, it should still apply though, doesn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find most YAMLs in k/k repo use gojsontoyaml style. I would prefer gojsontoyaml style a little.
https://github.com/search?q=repo%3Akubernetes%2Fkubernetes+yaml+language%3AYAML&type=code&l=YAML
cc @dgrisonnet to share more opinions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a very strong opinion. I was checking if we could somehow get rid of that conversion, and it turns we might be able to. I tried with the following patch and it was generating valid yaml files:
diff --git a/Makefile b/Makefile
index 47948b1e7..f5c0d9700 100644
--- a/Makefile
+++ b/Makefile
@@ -158,8 +158,7 @@ examples: examples/standard examples/autosharding examples/daemonsetsharding mix
examples/standard: jsonnet $(shell find jsonnet | grep ".libsonnet") scripts/standard.jsonnet scripts/vendor
mkdir -p examples/standard
- ${JSONNET_CLI}} -J scripts/vendor -m examples/standard --ext-str version="$(VERSION)" scripts/standard.jsonnet | xargs -I{} sh -c 'cat {} | ${GOJSONTOYAML_CLI} > `echo {} | sed "s/\(.\)\([A-Z]\)/\1-\2/g" | tr "[:upper:]" "[:lower:]"`.yaml' -- {}
- find examples -type f ! -name '*.yaml' -delete
+ ${JSONNET_CLI} -J scripts/vendor -m examples/standard --ext-str version="$(VERSION)" -S scripts/standard.jsonnet
examples/autosharding: jsonnet $(shell find jsonnet | grep ".libsonnet") scripts/autosharding.jsonnet scripts/vendor
mkdir -p examples/autosharding
diff --git a/scripts/standard.jsonnet b/scripts/standard.jsonnet
index 0839cecf5..24b5df25b 100644
--- a/scripts/standard.jsonnet
+++ b/scripts/standard.jsonnet
@@ -1,9 +1,17 @@
local ksm = import 'kube-state-metrics/kube-state-metrics.libsonnet';
local version = std.extVar('version');
-ksm {
- name:: 'kube-state-metrics',
- namespace:: 'kube-system',
- version:: version,
- image:: 'registry.k8s.io/kube-state-metrics/kube-state-metrics:v' + version,
+{
+ local k = ksm {
+ name:: 'kube-state-metrics',
+ namespace:: 'kube-system',
+ version:: version,
+ image:: 'registry.k8s.io/kube-state-metrics/kube-state-metrics:v' + version,
+ },
+
+ 'cluster-role-binding.yaml': std.manifestYamlDoc(k.clusterRoleBinding),
+ 'cluster-role.yaml': std.manifestYamlDoc(k.clusterRole),
+ 'deployment.yaml': std.manifestYamlDoc(k.deployment),
+ 'service-account.yaml': std.manifestYamlDoc(k.serviceAccount),
+ 'service.yaml': std.manifestYamlDoc(k.service),
}
But I haven't looked at any jsonnet code in a while so that might be incorrect
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really know jsonnet and my interest in learning it is limited (I'm also fine with dropping jsonnet completely and see if we have anyone interested in maintaining it). My primary goal is to remove an unmaintained dependency here.
/lgtm To give time to other discussion(s) here, feel free to unhold. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mrueg, rexagod The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/triage accepted |
What this PR does / why we need it:
https://github.com/brancz/gojsontoyaml hasn't had a commit since 4 years +, replace it with a maintained alternative.
How does this change affect the cardinality of KSM: (increases, decreases or does not change cardinality)
None
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #