Skip to content

Commit

Permalink
Merge pull request #8 from buildkite/update-doc-comments
Browse files Browse the repository at this point in the history
Update doc comments for Marshal{JSON,YAML}
  • Loading branch information
DrJosh9000 authored Nov 13, 2023
2 parents e5b6218 + ec30b19 commit 7acea64
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,20 @@ type Plugin struct {
Config any
}

// MarshalJSON returns the plugin in "one-key object" form, or "single string"
// form (no config, only plugin source). Plugin sources are marshalled into "full"
// form.
// MarshalJSON returns the plugin in "one-key object" form. Plugin sources are
// marshalled into "full" form. Plugins originally specified as a single string
// (no config, only source) are canonicalised into "one-key object" with config
// null.
func (p *Plugin) MarshalJSON() ([]byte, error) {
// NB: MarshalYAML (as seen below) never returns an error.
o, _ := p.MarshalYAML()
return json.Marshal(o)
}

// MarshalYAML returns the plugin in either "one-item map" form, or "scalar"
// form (no config, only plugin source). Plugin sources are marshalled into "full"
// form.
// MarshalYAML returns the plugin in either "one-item map" form. Plugin sources
// are marshalled into "full" form. Plugins originally specified as a single
// string (no config, only source) are canonicalised into "one-item map" with
// config nil.
func (p *Plugin) MarshalYAML() (any, error) {
return map[string]any{
p.FullSource(): p.Config,
Expand Down

0 comments on commit 7acea64

Please sign in to comment.