Skip to content

Commit

Permalink
chore(plugins): tweak names in config-file format (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tieske committed Jul 12, 2023
1 parent c8250aa commit f36b02d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions plugins/plugin-file.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ _format_version: "1.0"

# plugins is an array of plugin operations, to be applied in order
# for now only "add" is supported
plugins:
add-plugins:
- selectors: # defaults to ["$"]
- "$.services[*]"
overwrite: false # defaults to false
add-plugins:
plugins:
- name: key-auth
config:
key_names: [api_key, apikey]
Expand Down
10 changes: 5 additions & 5 deletions plugins/pluginfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ func (patch *AddPluginPatch) Parse(patchData map[string]interface{}, source stri
return fmt.Errorf("%s.selectors: %w", source, err)
}

patch.Plugins, err = jsonbasics.GetObjectArrayField(patchData, "add-plugins")
patch.Plugins, err = jsonbasics.GetObjectArrayField(patchData, "plugins")
if err != nil {
return fmt.Errorf("%s.add-plugins is not an array; %w", source, err)
return fmt.Errorf("%s.plugins is not an array; %w", source, err)
}

patch.Overwrite = false
Expand Down Expand Up @@ -99,14 +99,14 @@ func (pluginFile *DeckPluginFile) ParseFile(filename string) error {
logbasics.Debug("parsed unversioned plugin-file", "file", filename)
}

patchesRead, err := jsonbasics.GetObjectArrayField(data, "plugins")
patchesRead, err := jsonbasics.GetObjectArrayField(data, "add-plugins")
if err != nil {
return fmt.Errorf("%s: field 'plugins' is not an array; %w", filename, err)
return fmt.Errorf("%s: field 'add-plugins' is not an array; %w", filename, err)
}

for i, patch := range patchesRead {
var addPluginPatch AddPluginPatch
err := addPluginPatch.Parse(patch, fmt.Sprintf("%s: plugins[%d]", filename, i))
err := addPluginPatch.Parse(patch, fmt.Sprintf("%s: add-plugins[%d]", filename, i))
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions plugins/pluginfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var _ = Describe("plugin files", func() {
"$.services[*]"
],
"overwrite": true,
"add-plugins": [{
"plugins": [{
"name": "my-plugin"
}]
}`))
Expand Down Expand Up @@ -75,7 +75,7 @@ var _ = Describe("plugin files", func() {
{
"selectors": ["$.services[*]"],
"overwrite": true,
"add-plugins": [{
"plugins": [{
"name": "my-other-plugin"
}]
}`)), "test")
Expand Down

0 comments on commit f36b02d

Please sign in to comment.