microcluster icon indicating copy to clipboard operation
microcluster copied to clipboard

Investigate replacement for `GetCallerProject`

Open masnax opened this issue 6 months ago • 0 comments

microcluster expects some prepared statements to be defined and run on initial start with RegisterStmt. Projects that import microcluster are also expected to have these calls.

In order to determine which statement fits with which project, we attempt to determine the caller package of RegisterStmt. It is usually one of:

  • /root/parts/{project}/build when built with snapcraft
  • $GOPATH/src/github.com/{account}/{project} for a local build
  • $GOPATH/pkg/mod/github.com/{account}/{project}/{version} when called from an imported package.

We want to register all statements from the current project and microcluster, but ignore all other imported projects as we won't have their schema.

Currently, we do this by parsing the project name out of the above paths, and only using microcluster and the current project. But there may be a cleaner way to handle this.

masnax avatar Aug 02 '24 14:08 masnax