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

Document config file labels #703

Open
SmithSamuelM opened this issue Mar 6, 2024 · 1 comment
Open

Document config file labels #703

SmithSamuelM opened this issue Mar 6, 2024 · 1 comment

Comments

@SmithSamuelM
Copy link
Collaborator

The keripy config file has well known labels for config data but these are not documented anywhere:

Suggest label definition in the doc strings of keri.app.configing
and documented labels with examples in a markdown doc in scripts/keri/cf

reserved labels:
dt
curls
iurls
durls
wurls

Hab name labels: "nel"

Not used in config file?
murls

{'dt': '2021-01-01T00:00:00.000000+00:00',
                                   'nel': {
                                       'dt': '2021-01-01T00:00:00.000000+00:00',
                                       'curls': ['tcp://localhost:5621/'],
                                   },
                                   'iurls': ['tcp://localhost:5620/?role=peer&name=tam']}

Habery. reconfigure

def reconfigure(self):
        """Apply configuration from config file managed by .cf. to this Habery
        Process any oobis or endpoints

        conf
        {
          dt: "isodatetime",
          curls: ["tcp://localhost:5620/"],
          iurls: ["tcp://localhost:5621/?name=eve"],
        }

        Config file is meant to be read only at init not changed by app at
        run time. Any dynamic app changes must go in database not config file
        that way we don't have to worry about multiple writers of cf.
        Use config file to preload database not as a database. Config file may
        have named sections for Habery or individual Habs as needed.

        """
        conf = self.cf.get()
        if "dt" in conf:  # datetime of config file
            dt = help.fromIso8601(conf["dt"])  # raises error if not convert
            if "iurls" in conf:  # process OOBI URLs
                for oobi in conf["iurls"]:
                    obr = basing.OobiRecord(date=help.toIso8601(dt))
                    self.db.oobis.put(keys=(oobi,), val=obr)
            if "durls" in conf:  # process OOBI URLs
                for oobi in conf["durls"]:
                    obr = basing.OobiRecord(date=help.toIso8601(dt))
                    self.db.oobis.put(keys=(oobi,), val=obr)
            if "wurls" in conf:  # well known OOBI URLs for MFA
                for oobi in conf["wurls"]:
                    obr = basing.OobiRecord(date=help.toIso8601(dt))
                    self.db.woobi.put(keys=(oobi,), val=obr)

BaseHab.reconfigure

    def reconfigure(self):
        """Apply configuration from config file managed by .cf. to this Hab.
        Assumes that .pre and signing keys have been setup in order to create
        own endpoint auth when provided in .cf.

        conf
        {
          dt: "isodatetime",
          curls: ["tcp://localhost:5620/"],
          iurls: ["tcp://localhost:5621/?name=eve"]
        }

        Config file is meant to be read only at init not changed by app at
        run time. Any dynamic app changes must go in database not config file
        that way we don't have to worry about multiple writers of cf.
        Use config file to preload database not as a database. Config file may
        have named sections for Habery or individual Habs as needed.
        """

        conf = self.cf.get()
        if self.name not in conf:
            return

        conf = conf[self.name]
        if "dt" in conf:  # datetime of config file
            dt = help.fromIso8601(conf["dt"])  # raises error if not convert
            msgs = bytearray()
            msgs.extend(self.makeEndRole(eid=self.pre,
                                         role=kering.Roles.controller,
                                         stamp=help.toIso8601(dt=dt)))
            if "curls" in conf:
                curls = conf["curls"]
                for url in curls:
                    splits = urlsplit(url)
                    scheme = (splits.scheme if splits.scheme in kering.Schemes
                              else kering.Schemes.http)
                    msgs.extend(self.makeLocScheme(url=url,
                                                   scheme=scheme,
                                                   stamp=help.toIso8601(dt=dt)))
            self.psr.parse(ims=msgs)
@SmithSamuelM
Copy link
Collaborator Author

SmithSamuelM commented Mar 6, 2024

Full example file

{
    "dt": "2021-01-01T00:00:00.000000+00:00",
     "nel":
      {
        "dt": "2021-01-01T00:00:00.000000+00:00",
        "curls":
        [
          "tcp://localhost:5621/"
        ]
      },
      "iurls":
      [
        "tcp://localhost:5620/?role=peer&name=tam"
      ],
      "durls":
      [
        "http://127.0.0.1:7723/oobi/EBNaNu-M9P5cgrnfl2Fvymy4E_jvxxyjb70PRtiANlJy",
        "http://127.0.0.1:7723/oobi/EMhvwOlyEJ9kN4PrwCpr9Jsv7TxPhiYveZ0oP3lJzdEi",
      ],
      "wurls":
      [
        "http://127.0.0.1:5644/.well-known/keri/oobi/EBNaNu-M9P5cgrnfl2Fvymy4E_jvxxyjb70PRtiANlJy?name=Root"
      ]
}

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

1 participant