Skip to content
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

pull command is using |4- notation in yaml, which is not compatible with the list or apply commands #245

Open
basvdl opened this issue Jun 2, 2023 · 1 comment

Comments

@basvdl
Copy link

basvdl commented Jun 2, 2023

If the query starts with an blank line, grr pull will generate a yaml file using the |4- notation. Although this is valid yaml, the list and apply commands do not work when this notation is present in the yaml files.

Query that starts with a blank line:
image

Will result in this expression when using grr pull

              expr: |4-
                rate(
                    node_cpu_seconds_total{mode="system"}[$__rate_interval]
                )

In this case grr list will fail:

grr list resources/dashboards/general/dashboard-mwwg8CQVk.yaml
INFO[0000] Listing 0 resources
API VERSION    KIND    UID

If I simply change |4- to |- in the yaml and rerun the list command:

grr list resources/dashboards/general/dashboard-mwwg8CQVk.yaml
INFO[0000] Listing 1 resources
API VERSION                     KIND         UID
grizzly.grafana.com/v1alpha1    Dashboard    mwwg8CQVk

Version info:
Grizzly: 2023-06-02 09:33:31.610732 I | grr version v0.2.0
Grafana: 9.2.15

K-Phoen added a commit that referenced this issue Jun 12, 2023
Fixes #245

There is currently a bug in [go-yaml/yaml](https://github.com/go-yaml/yaml) causing indentation hints on scalar blocks to be set incorrectly.
As a result, they can not be unmarshalled.

[A PR has been open upstream](go-yaml/yaml#643) a few years ago but hasn't seen any meaningful activity recently.

This PR is an attempt at fixing this (un)marshalling issue by using an
alternative, regurlarly maintained, YAML library: [goccy/go-yaml](https://github.com/goccy/go-yaml)

Some quick manual testing showed that goccy/go-yaml resolves #245, but
there is more validation needed to decide if switching to a new
dependency is viable:

* goccy/go-yaml is highly likely to marshal resources differently. While
  some degree of change is *probably* acceptable, I currently don't know
  how different marshalled resources are.
* there isn't any unit test covering the issue, I will add one.
K-Phoen added a commit that referenced this issue Jun 12, 2023
Fixes #245

There is currently a bug in [go-yaml/yaml](https://github.com/go-yaml/yaml) causing indentation hints on scalar blocks to be set incorrectly.
As a result, they can not be unmarshalled.

[A PR has been open upstream](go-yaml/yaml#643) a few years ago but hasn't seen any meaningful activity recently.

This PR is an attempt at fixing this (un)marshalling issue by using an
alternative, regurlarly maintained, YAML library: [goccy/go-yaml](https://github.com/goccy/go-yaml)

Some quick manual testing showed that goccy/go-yaml resolves #245, but
there is more validation needed to decide if switching to a new
dependency is viable:

* goccy/go-yaml is highly likely to marshal resources differently. While
  some degree of change is *probably* acceptable, I currently don't know
  how different marshalled resources are.
* there isn't any unit test covering the issue, I will add one.
K-Phoen added a commit that referenced this issue Jun 12, 2023
Fixes #245

There is currently a bug in [go-yaml/yaml](https://github.com/go-yaml/yaml) causing indentation hints on scalar blocks to be set incorrectly.
As a result, they can not be unmarshalled.

zsh:1: command not found: qa

This PR is an attempt at fixing this (un)marshalling issue by using an
alternative, regurlarly maintained, YAML library: [goccy/go-yaml](https://github.com/goccy/go-yaml)

Some quick manual testing showed that goccy/go-yaml resolves #245, but
there is more validation needed to decide if switching to a new
dependency is viable:

* goccy/go-yaml is highly likely to marshal resources differently. While
  some degree of change is *probably* acceptable, I currently don't know
  how different marshalled resources are.
* there isn't any unit test covering the issue, I will add one.
K-Phoen added a commit that referenced this issue Jun 12, 2023
Fixes #245

There is currently a bug in [go-yaml/yaml](https://github.com/go-yaml/yaml) causing indentation hints on scalar blocks to be set incorrectly.
As a result, they can not be unmarshalled.

This PR is an attempt at fixing this (un)marshalling issue by using an
alternative, regurlarly maintained, YAML library: [goccy/go-yaml](https://github.com/goccy/go-yaml)

Some quick manual testing showed that goccy/go-yaml resolves #245, but
there is more validation needed to decide if switching to a new
dependency is viable:

* goccy/go-yaml is highly likely to marshal resources differently. While
  some degree of change is *probably* acceptable, I currently don't know
  how different marshalled resources are.
* there isn't any unit test covering the issue, I will add one.
@malcolmholmes
Copy link
Collaborator

The immediate workaround for this issue is to use JSON instead, so use -f json to avoid the use of YAML.

Grizzly depends upon Golang YAML parsers, and every YAML parser I've played with has some issues with Grafana dashboards, which tend to do some odd things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants