-
Notifications
You must be signed in to change notification settings - Fork 126
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
feat: Dump resources command for debuggability #6635
Conversation
cli/pkg/printer/resources.go
Outdated
switch r.Meta.Name.Kind { | ||
case runtime.ResourceKindSource: | ||
spec, specErr = protojson.MarshalOptions{Indent: " "}.Marshal(r.GetSource().Spec) | ||
state, stateErr = protojson.MarshalOptions{Indent: " "}.Marshal(r.GetSource().State) | ||
case runtime.ResourceKindModel: |
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.
All these cases seem excessive for an internal dump tool. Did you consider just doing a JSON roundtrip to avoid handling each type specifically? E.g. (pseudocode):
rowJSON := protojson.Marshal(r)
row := json.Unmarshal(rowJSON)
for k, v := range row {
if k != "meta" {
row["spec"] = row[k]["spec"]
row["state"] = row[k]["state"]
delete(row, k)
break
}
}
row["org"] = org
row["project"] = project
row["resource_type"] = runtime.PrettifyResourceKind(r.Meta.Name.Kind)
row["resource_name"] = r.Meta.Name.Name
return row
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.
No I did not consider handling via JSON but sounds like a better idea. Modified the code.
subtask for https://github.com/rilldata/rill-private-issues/issues/854
Checklist: