Giter Club home page Giter Club logo

Comments (7)

qrkourier avatar qrkourier commented on June 19, 2024

Assuming precedence is by lexical/alnum sort descending, I'd expect highest (last) precedence to win when the same directive is given multiple times, not lowest (first) precedence.

from ziti.

qrkourier avatar qrkourier commented on June 19, 2024

You don't want config merging a la Docker Compose? That was my mental model for this until you say no merging. 🙂

from ziti.

qrkourier avatar qrkourier commented on June 19, 2024

In your model, if first is highest precedence then included configs are always additive, and individual, included directives are ignored unless they're the first occurrence, correct? So, the descending sort also has descending precedence, and last is lowest.

from ziti.

emoscardini avatar emoscardini commented on June 19, 2024

Merging is hard to handle & I'd rather have a consistent way to load separate distinct overrides than merge multiple ones.

For the sorting the files, I'm following sudoers example:

 Files are parsed in sorted lexical order.  That is, /etc/sudoers.d/01_first will be parsed before /etc/sudoers.d/10_second.

They use lexical order in ascending for sorting the files.

In my model, you could create a default configuration with the include at the top, before any keys & anything loaded from file would override the default values in the configuration.

from ziti.

qrkourier avatar qrkourier commented on June 19, 2024

I like the admin experience you're going for. I'm still fuzzy on precedence. If lower sorted includes can't cancel/override a config property that's already defined then they're lower precedence by definition, i.e., not "overrides." Did I misunderstand?

from ziti.

emoscardini avatar emoscardini commented on June 19, 2024

Maybe an example would be better.

The default config contains:

v: 3

include: 
  directory: /opt/openziti/config.d
  extension: yml

events:
  jsonLogger:
    subscriptions:  jsonLogger:
    subscriptions:
      - type: fabric.circuits
     ...
        interval: 25s
    handler:
      type: file
      format: json
      path: /tmp/ziti-25s-events.log
...

When the controller starts up, it would find the include key & would read the files in the specified directory. It wouldn't find any files so it would continue to read the default config & load the events key with the 25s interval & something like the following would be in the logs:
[INFO] - found include key but unable to load any files from specified directory.

Someone creates a file called events.yml in the specified directory with the content:

events:
  jsonLogger:
    subscriptions:  jsonLogger:
    subscriptions:
      - type: fabric.circuits
     ...
        interval: 60s
    handler:
      type: file
      format: json
      path: /tmp/ziti-60s-events.log

Sorting in lexical order of files.
events.yml

When the controller restarts, the controller would see the Include before reading events key in the default config & would read the files in the specified directory. It would find events.yml & load the events key with the 60s interval & ignore the default events with the 25s interval & something like the following would be in the logs:
[INFO] - loaded events from /opt/openziti/config.d/events.yml
[ERROR] - found duplicate key events - ignoring

Then someone drops another file called 01-events.yml in the specified directory with the content:

events:
  jsonLogger:
    subscriptions:  jsonLogger:
    subscriptions:
      - type: fabric.circuits
     ...
        interval: 5s
    handler:
      type: file
      format: json
      path: /tmp/ziti-5s-events.log

Sorting in lexical order of files.
01-events.yml
events.yml

When the controller restarted, you would end up with a 5s interval & something like the following would be in the logs:
[INFO] - loaded events from /opt/openziti/config.d/01-events.yml
[ERROR] - found duplicate key events - ignoring
[ERROR] - found duplicate key events - ignoring

from ziti.

qrkourier avatar qrkourier commented on June 19, 2024

I've got it now. The proposed logic is to first seek and find and load any lexically-sorted includes, then load the default configuration. This means the includes have the highest precedence and are always loaded first, and any defaults in the main config.yml are only loaded if not already defined.

from ziti.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.