Umbrella sub project config issue

I am having a helper module with some functions and macros which I will be using in different apps. Currently I created an umberall app with this command mix new kv_server --module KVServer --sup inside apps directory. But the configs of this new app I want to define in kv app like this

config :kv, KVServer,
key: “value”

(How do I get the configs in sub app or helper app?)

as you can see the same thing has been done in
config :my_app, MyApp.Guardian,
issuer: “my_app”

So I what want is I dont want to put a new app into the apps list and I want to get the configs in the child or sub or helper app(whatever it is called)

You need to include a reference to apps you want to access in your mix.exs


App 1: foo
App 2: bar
App 3: baz

foo wants access bar. bar does not have any dependencies on foo, which would cause a circular dependency issue.

So in foo, reference bar as follows:

      {:bar, in_umbrella: true}

This helper app should be unaware of the app whatever parent app is using this app. So I think {:bar, in_umbrella: true} doesn’t fit in this situation. and how do I get the config in the sub app like
Application.get_env(:parent_app, KVServer)[:secret_key] how do I know the parent app name

If you treat your utility app like a 3rd party library, you can follow the advice here:

If the KVServer should get it’s configuration from another OTP app config, you probably need a mixin module like Ecto.Repo that is used to configure it:

defmodule MyApp.KVServer
  use KVServer, otp_app: :my_app

1 Like