OscarVanL
Repos
42
Followers
16
Following
14

Events

issue comment
podman failed to connect: connection refused

Thanks @Luap99, one annoying thing I noticed is that if I destroy the machine and recreate it, then this will be created again with localhost instead of 127.0.0.1. I had to trawl through my browser history to find this thread again 😅

Created at 1 day ago
issue comment
spanNull seems do not work

I checked and the JSON output for Grafanalib appears to match what Grafana generates when I change this setting ("Connect null values") in the TimeSeries panel UI.

Have you checked if you upload the panel to Grafana, then edit it, is "Connect null values" in the UI set to what you set it to in Grafana? (I.E, if you set it to True in Python does it show True in the Grafana frontend?)

When you change the setting manually in the Grafana frontend for upoaded generated JSON does this feature work differently?

Created at 1 day ago
pull request opened
Expose Now delay option

What does this do?

The Now delay can be applied to a dashboard (via a TimePicker), which will delay the time at which now applies when looking at data on a dashboard.

Why is it a good idea?

This was missing from Grafanalib.

Created at 2 days ago
create branch
OscarVanL create branch feat/timepicker/now-delay
Created at 2 days ago
Mermaid Line Break doesn't seem to work in Diagram

I have a disgusting hack to get this to work!

If you put the escaped symbols for the desired HTML formatting inside the Mermaid diagram definition, then once you apply the metric onto that node, then it'll un-escape the HTML and the HTML will work again.

In your example, you wanted the name to be Post-Initial<br>Page Refresh. If you set this as Post-Initial&ltbr&gtPage Refresh then once you apply the metric it'll render how you wanted.

This falls apart if you have long HTML content, for instance, say you had an image on the node: "&ltimg src='https://www.mywebsite.com/image.png'; width='30';&gtbr NodeName", then Mermaid will end up rendering a reeeeeaally wide node expecting that the HTML tag was actually the text inside the node. So it's only really applicable for cases like yours.

Created at 2 days ago
Mermaid Line Break doesn't seem to work in Diagram

It looks like it strips out all HTML in the node's text, I have some tags which render fine, but when I then add a metric to the node it gets rid of the image.

Created at 2 days ago
issue comment
fix: correctly parse json tag name

Thank you!

Created at 6 days ago
issue comment
fix: correctly parse json tag name

@inhere Is there any possibility you could create a release? I would like to get the English text fixes and this label fix in my project 😃

Created at 6 days ago
pull request opened
fix: correctly parse json tag name

Fix https://github.com/gookit/validate/issues/182 to correctly parse the name from the json tag, or ignore it and use the struct field's name instead if it is not set.

Created at 1 week ago
create branch
OscarVanL create branch fix/json-tag-field-name-parsing
Created at 1 week ago

improvements to english text grammar

Merge pull request #171 from OscarVanL/fix/improve-english-grammar

fix: #172 filtering string slice value failed on struct data.

  • fix rule missing collect on only set filter rules
  • if end withs .*, trim suffix on update value

build(deps): bump github.com/gookit/filter from 1.1.3 to 1.1.4

Bumps github.com/gookit/filter from 1.1.3 to 1.1.4.


updated-dependencies:

  • dependency-name: github.com/gookit/filter dependency-type: direct:production update-type: version-update:semver-patch ...

Signed-off-by: dependabot[bot] support@github.com

Merge pull request #173 from gookit/dependabot/go_modules/github.com/gookit/filter-1.1.4

build(deps): bump github.com/gookit/goutil from 0.5.12 to 0.5.13

Bumps github.com/gookit/goutil from 0.5.12 to 0.5.13.


updated-dependencies:

  • dependency-name: github.com/gookit/goutil dependency-type: direct:production update-type: version-update:semver-patch ...

Signed-off-by: dependabot[bot] support@github.com

feat: enable slices of maps on structs

Right now, the system only allows to use tags.* for slices, but if the slice is a complex type(struct or map) there is no way to validate.

This commits adds a way to test inside slice content if the value is a map:

var data = map[string]interface{}{
  "user": "foo",
  "properties": []map[string]string{{
    "phone": "12001",
    "alias": "foobar",
  }},
}

v := validate.Map(data)

v.ConfigRules(map[string]string{
  "properties.*.admin": "bool",
  "properties.*.alias": "minlen:4",
})

Added tests inside a current test, I thought that makes sense to have in there.

Signed-off-by: Eloy Coto eloy.coto@acalustra.com

Merge pull request #175 from gookit/dependabot/go_modules/github.com/gookit/goutil-0.5.13

Merge pull request #174 from eloycoto/SliceStructFixes

build(deps): bump github.com/gookit/goutil from 0.5.13 to 0.5.15

Bumps github.com/gookit/goutil from 0.5.13 to 0.5.15.


updated-dependencies:

  • dependency-name: github.com/gookit/goutil dependency-type: direct:production update-type: version-update:semver-patch ...

Signed-off-by: dependabot[bot] support@github.com

Merge pull request #176 from gookit/dependabot/go_modules/github.com/gookit/goutil-0.5.15

modify a Initialization of map

Signed-off-by: mariogao ghyang08@163.com

Merge pull request #178 from mariogao/master

build(deps): bump WillAbides/setup-go-faster from 1.7.0 to 1.8.0

Bumps WillAbides/setup-go-faster from 1.7.0 to 1.8.0.


updated-dependencies:

  • dependency-name: WillAbides/setup-go-faster dependency-type: direct:production update-type: version-update:semver-minor ...

Signed-off-by: dependabot[bot] support@github.com

Merge pull request #181 from gookit/dependabot/github_actions/WillAbides/setup-go-faster-1.8.0

Created at 1 week ago
issue comment
Feature request: Override validation rule within a scene

Closing because this is already possible!

Eg:

func (User) ConfigValidation(v *validate.Validation) {
	v.WithScenes(validate.SValues{
		Create:      []string{"ID", "Kind", "Name", "Birthday"},
		Update:     []string{"ID", "Kind", "Name", "Birthday"},
	})

        v.AddRule("ID", "empty").SetScene(Create)
        v.AddRule("ID", "uuid4").SetScene(Update)
}

Created at 1 week ago
closed issue
Feature request: Override validation rule within a scene

I have defined some custom scenes so that I can validate my struct in different ways.

func (User) ConfigValidation(v *validate.Validation) {
	v.WithScenes(validate.SValues{
		Create:      []string{"Kind", "Name", "Birthday"},
		Update:     []string{"ID", "Kind", "Name", "Birthday"},
	})
}

I would love it if I could specify different rules for each of these scene fields.

For example, when I create a user I want to validate that the user has left ID empty. It is not enough to skip validation, I must make sure they have not filled it out.

func (User) ConfigValidation(v *validate.Validation) {
	v.WithScenes(validate.SValues{
		Create:      []string{"ID:'empty'", "Kind", "Name", "Birthday"},
		Update:     []string{"ID", "Kind", "Name", "Birthday"},
	})
}

If no rule is provided inside the SValue, then it should fall back to the rule defined on the struct tags.

Created at 1 week ago
opened issue
Field name incorrectly extracted for comma-separated JSON struct tags

System (please complete the following information):

  • OS: macOS and go playground
  • GO Version: 1.19
  • Pkg Version: 1.4.4

Describe the bug

Field names are incorrectly extracted from struct JSON tags in error messages.

To Reproduce

Reproduced in Go Playground: https://go.dev/play/p/lYq_wF7zBrM

package main

import (
	"fmt"

	"github.com/gookit/validate"
)

func init() { // nolint:gochecknoinits
	validate.Config(func(opt *validate.GlobalOption) {
		opt.StopOnError = false
		opt.SkipOnEmpty = false
	})
}

type Thing struct {
	Field  string `json:"test,omitempty" validate:"email"`
	Field2 string `json:",omitempty" validate:"min_len:10"`
}

func main() {
	thing := Thing{Field: "not email", Field2: "a"}

	if v := validate.Struct(&thing); !v.Validate() {
		fmt.Println(v.Errors)
	}
}

Error Output:

test,omitempty:
 email: test,omitempty value is invalid email address
,omitempty:
 min_len: ,omitempty min length is 10

Expected output:

test:
 email: test value is invalid email address
Field2:
 min_len: Field2 min length is 10

Expected behavior

  • For fields with JSON struct tags that do not include the first value (eg: json:",omitempty"), the struct's field name should be used instead.

  • For fields that have names in the JSON struct tags, text after the comma should be disregarded (eg: json:"test,omitempty"), so the field should be parsed as test.

Created at 1 week ago
Add TTL Policy to Firestore

Thanks for looking at this, I just wanted to point out that this feature was also added to "Firestore in Datastore mode", which is often called Datastore in docs/packaging. See here: https://cloud.google.com/datastore/docs/ttl

As far as I am aware, the two products function very similarly as they are both Firestore, just operating in different modes. (Firestore is more geared to making client apps, Datastore is more geared to backends).

For example, here's the equivalent terraform for defining indexes in Firestore and Datastore. So this feature might need to be duplicated for datastore too.

Created at 1 week ago
issue comment
fix: AlertRulev9 JSON schema is not correct

This looks to be the format that Grafana uses internally, if you open Inspect Element and go to the Alerting tab of Grafana, then search for the request to /api/ruler/grafana/api/v1/rules?subtype=cortex, and look at the response body, you can see the JSON structure. For me (Grafana 9.2.3), it matches the structure that this PR uses.

Out of curiosity, if you find one of the alerts you uploaded using file-based provisioning inside this response, what structure does it use?

Created at 2 weeks ago
issue comment
fix: AlertRulev9 JSON schema is not correct

Interesting, how are you uploading the alerts? By provisioning?

Created at 2 weeks ago

Update README.md

Remove Mega download link as the file has been removed

Created at 2 weeks ago
issue comment
New Grafana unified alerting

New Grafana alerting is now supported, maybe this can be closed?

Created at 2 weeks ago

fix test

Created at 2 weeks ago
pull request opened
fix: AlertRulev9 JSON schems is not correct

There are a couple of mistakes in the Grafana 9 Alerts-As-Code AlertRulev9 JSON output.

Firstly, the absence of grafana_alert means that uploading the output JSON fails with a validation error: {"message":"unexpected backend type (grafana) for payload type (lotex)","traceID":""}, which specifically is this error in Grafana.

Secondly, the fields noDataState and execErrState were renamed to no_data_state and exec_err_state in v9, meaning these settings were not applied correctly.

With these changes my alerts upload successfully and appear to be correct, but if I spot further mistakes I'll make follow-up PRs.

Created at 2 weeks ago
create branch
OscarVanL create branch fix/grafana-v9-alerts
Created at 2 weeks ago
Created at 2 weeks ago
pull request closed
fix: Correctly format BarGauge JSON

What does this do?

I noticed some of my params like min and max were not being applied to my dashboard. I had a look at the grafana structs used to generate/parse the JSON and it looked like a few fields were in the wrong place.

It also removes the label / labels field, because as far as I can tell the described option does not exist.

Why is it a good idea?

Corrects the structure of BarGauge so that its args are used.

Context

Questions

Created at 2 weeks ago
issue comment
Add support for Grafana alerts in v9

Nice work 😃 we just updated to Grafana 9 so this is great timing!

Created at 3 weeks ago
issue comment
Add support for Grafana alerts in v9

(will only get around to trying this next week though)

@OscarVanL if you do have time to test it that would be much apricated as I don't have any Grafana v8 alerts to test with.

I have finished my update to the code and welcome any feedback.

So sorry James, I didn't get around to trying this out, and now I'm on holiday for the next 2.5 weeks 🙈

Created at 1 month ago
issue comment
Add support for Grafana alerts in v9

I can try it out with our existing codebase (expecting that there'd be zero diff in the JSON, or minimal changes), however I'll need need to make what we've got sitting on the side in our repo use upstream grafanalib.

Were you hoping to get this change in before making a new release?

Created at 1 month ago
pull request opened
Improve formatting of getting started document

I thought this would format like markdown, but it didn't so it looked awful.

Created at 1 month ago

Improve formatting of getting started document

I thought this would format like markdown, but it didn't so it looked awful.

Created at 1 month ago
issue comment
Grafana 8.x new Alert Rule

@JamesGibo I've added some documentation to the getting started page.

That's a shame to hear about the schema change in Grafana v9. I've not had a chance to try out Grafana v9 yet.

I've also been quite interested in Grafana provisioning, it would be cool if our dashboards could be generated as code and then provisioned by CI in a way that's well supported by Grafnaa.

Created at 1 month ago