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

yaml format for configuration #70

Closed
paulvollmer opened this issue Nov 11, 2017 · 3 comments
Closed

yaml format for configuration #70

paulvollmer opened this issue Nov 11, 2017 · 3 comments

Comments

@paulvollmer
Copy link

if the config can be written in yaml, it's possible to write comments or comment out some parts of the configuration.

do you accept a pull request for that?

@mholt
Copy link
Collaborator

mholt commented Dec 5, 2017

How much complexity will it add? If it's not an intrusive change, I think we're open to it.

@paulvollmer
Copy link
Author

At first we need to check the file extension and adding a switch/case for it. if it is a .yaml or .yml we need to call the yaml.Unmarshal to set the checkup.Checkup variable.

I think it's not a big thing to implement.
this need to go to the following function:

checkup/cmd/root.go

Lines 74 to 87 in 6526149

func loadCheckup() checkup.Checkup {
configBytes, err := ioutil.ReadFile(configFile)
if err != nil {
log.Fatal(err)
}
var c checkup.Checkup
err = json.Unmarshal(configBytes, &c)
if err != nil {
log.Fatal(err)
}
return c
}

For the encoding need only to add some yaml keys. These keys you still defined for json. for example...

checkup/checkup.go

Lines 21 to 48 in 01dd92f

type Checkup struct {
// Checkers is the list of Checkers to use with
// which to perform checks.
Checkers []Checker `json:"checkers,omitempty"`
// ConcurrentChecks is how many checks, at most, to
// perform concurrently. Default is
// DefaultConcurrentChecks.
ConcurrentChecks int `json:"concurrent_checks,omitempty"`
// Timestamp is the timestamp to force for all checks.
// Useful if wanting to perform distributed check
// "at the same time" even if they might actually
// be a few milliseconds or seconds apart.
Timestamp time.Time `json:"timestamp,omitempty"`
// Storage is the storage mechanism for saving the
// results of checks. Required if calling Store().
// If Storage is also a Maintainer, its Maintain()
// method will be called by c.CheckAndStore().
Storage Storage `json:"storage,omitempty"`
// Notifier is a notifier that will be passed the
// results after checks from all checkers have
// completed. Notifier may evaluate and choose to
// send a notification of potential problems.
Notifier Notifier `json:"notifier,omitempty"`
}

i can start implementing this feature...

@titpetric
Copy link
Contributor

I'm closing this issue because it isn't feasible. Checkup relies on json.RawMessage to pass parts of the configuration without schema to it's plugins (storage, check and notifier). Yaml decoding doesn't have the concept of a rawMessage, or a standard library parser for it.

Upstream issue: go-yaml/yaml#13

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

No branches or pull requests

3 participants