Skip to content
This repository has been archived by the owner on Apr 26, 2021. It is now read-only.

Ruler API modifications #50

Merged
merged 6 commits into from
Apr 14, 2021
Merged

Conversation

papagian
Copy link
Collaborator

@papagian papagian commented Apr 14, 2021

I had to:

  • modify the code for validating the payloads
  • extend model.Duration type to implement the json.Marshaler and json.Unmarshaler interfaces This is finally not required (JSON unmarshalling works without it) so I have revert it.

@@ -186,11 +203,52 @@ func (c *GettableRuleGroupConfig) validate() error {
return nil
}

// ApiDuration extends model.Duration
// for handling JSON serialization/deserialization
type ApiDuration model.Duration
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
type ApiDuration model.Duration
type Duration model.Duration

This ia already part of the api package, I believe it's redundant.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, I don't fully understand; why it's redundant?

}
return GrafanaManagedRule

if n.GrafanaManagedAlert != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this validation belong in Type, is there any particular reason for it? Otherwise, I'd be inclined for following the pattern throughout this file and creating a function called validate that we can use as we unmarshal.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only reason is that Type() and validate() will end up very similar but I will change it.

Copy link
Member

@owen-d owen-d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once you've addressed @gotjosh's feedback, LGTM

@papagian papagian requested a review from gotjosh April 14, 2021 14:57
Copy link
Contributor

@davidmparrott davidmparrott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

Copy link
Contributor

@gotjosh gotjosh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@@ -96,7 +96,8 @@ type NamespaceConfigResponse map[string][]GettableRuleGroupConfig

// swagger:model
type PostableRuleGroupConfig struct {
Name string `yaml:"name" json:"name"`
Name string `yaml:"name" json:"name"`
// Example 1m
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we need these changes here. The same applies for the RuleNode down below.

@papagian papagian merged commit 6625e7a into master Apr 14, 2021
@papagian papagian deleted the papagian/post-rules-unify-fields branch April 14, 2021 16:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants