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

Ability to handle duplicate sections #85

Closed
Wernervdmerwe opened this issue Nov 25, 2017 · 6 comments
Closed

Ability to handle duplicate sections #85

Wernervdmerwe opened this issue Nov 25, 2017 · 6 comments

Comments

@Wernervdmerwe
Copy link

Agreeably this hurts the head to ponder, but seems it is a valid use case in eg [https://github.com/influxdata/telegraf/tree/master/plugins/inputs/postgresql_extensible]

If duplicates are specified as below, only the last is affected into the final configuration file

    sections       => {
      'postgresql_extensible.query' => {
      'sqlquery'   => 'SELECT * FROM pg_stat_database where datname',
      'version'    => 901,
      'withdbname' => true,
      'tagvalue'   => 'postgres'
      },
      'postgresql_extensible.query' => {
      'sqlquery'   => 'SELECT * FROM pg_stat_bgwriter where datname',
      'version'    => 901,
      'withdbname' => true,
      'tagvalue'   => 'postgres'
      },
    }

@spjmurray
Copy link
Contributor

Sounds like a simple job of allowing a hash or list of hashes under the section key to me. If a hash emit, if a list duplicate the key and emit, winner winner chicken dinner. My 50 cents...

@spjmurray
Copy link
Contributor

dog:
  name: 'scruffy' 
  breed: 'scotty' 
cat:
  - name: 'tiddles' 
    breed: 'siamese'
  - name: 'puss' 
    breed: 'ocelot' 
[dog]
name = scruffy
breed = scotty
[cat]
name = tiddles
breed = siamese
[cat]
name = puss
breed = ocelot

@sparr
Copy link

sparr commented Dec 21, 2017

I would support @spjmurray's solution. I think it is unambiguous.

@sparr
Copy link

sparr commented Dec 21, 2017

Caveat: the behavior for deep merge would need to be documented. If you already have a list and merge a hash, does the hash add to the list or replace it? If you already have a hash and merge a list, same question.

@sparr
Copy link

sparr commented Dec 21, 2017

Oh, this seems to be a duplicate of #42 which has more comments.

@yankcrime
Copy link
Member

Closing this now that #80 has been merged which should address this use case.

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

4 participants