Allow to configure internal wiki provider via environment variables#23903
Allow to configure internal wiki provider via environment variables#23903NobodysNightmare wants to merge 1 commit into
Conversation
8e4ae8b to
8bb9f14
Compare
|
Warning Flaky specs
🤖 Ask Copilot to investigateCopy the prompt below into a new comment on this PR to delegate the investigation to GitHub Copilot. It will look into the flakiness and open a separate pull request with you as reviewer. |
| @@ -43,7 +43,10 @@ def show | |||
|
|
|||
| def update | |||
| provider = Wikis::InternalProvider.first | |||
| provider.update!(enabled: internal_provider_params[:enabled]) | |||
| unless provider.seeded_from_env? | |||
There was a problem hiding this comment.
🔴 wait, does that mean, if we seeded an internal provider with env we cannot disable it anymore?
Edit: confirmed below. Was this a requirement I missed?
There was a problem hiding this comment.
Edit 2: I get it now, this "seeded by ENV" was kind of a red hering for me. It is more "enabled/disabled by ENV".
🟡 The change in the controller is okay, but I ask myself, if we maybe shouldn't touch the controller and just amend the update contract?
There was a problem hiding this comment.
It's not using a contract at all 😅
But yeah, that would be the alternative. I guess a better name would be configured_by_env?
WDYT?
| description: "Overwrite settings of the internal wiki provider through environment variables", | ||
| writable: false, | ||
| default: {}, | ||
| format: :hash |
There was a problem hiding this comment.
🟡 I'm confused by the format. Why a hash? The only thing we actually accept here is { enabled: true|false }. So, a single boolean would do the job just fine, right?
There was a problem hiding this comment.
This is mostly about forward-compatibility.
Essentially we didn't make enabling/disabling the internal provider a Setting so far, but we decided to introduce a Provider object that would carry the configuration. So it would be super confusing (IMO) if we had Setting.internal_provider_enabled?, but it wouldn't decide whether the internal provider was enabled, because we use InternalProvider.first.enabled? for that.
Thus I am configuring the entire internal provider through this hash. Like I configure entire external providers through a hash/array soon as well.
The thing is that right now enabled is the only thing that can be configured, but who knows what the future will hold.
| end | ||
|
|
||
| def applicable? | ||
| !::Wikis::InternalProvider.exists? | ||
| !::Wikis::InternalProvider.exists? || Setting.internal_wiki_provider.present? |
There was a problem hiding this comment.
❓ logic here is now: we seed (force write) the internal provider, if
a) it is not here
b) it is already here, but we have an setting by ENV
Is this usually part of the logic of the seeders? honest question, I have no plan. :D The option b) somehow feels like this shouldn't be handled by a seeder.
There was a problem hiding this comment.
On the other hand I'm very open here for a sensible argument, why the seeder is exactly the correct place.
I just wanted to express, that when I would be searching for this logic, my first thought wouldn't be "seeder".
There was a problem hiding this comment.
When you look at the EnvData::OpenIDConnect::ProviderSeeder you will see that second-half statement there as well.
I think the one thing that's ucommon here, is that we seed something that may be configured through env, but even if it isn't we want to seed it anyways. E.g. the OIDC seeder seeds nothing without env or something with env.
This one here is supposed to either make one initial seeding round or (if a specific configuration is intended) ensure a specific configuration whenever seeding.
There was a problem hiding this comment.
tl; dr: I wouldn't know how to phrase the applicable? better/more logical. I am kinda open between having this a BasicData or an EnvData seeder.
My logic so far was that it's not always based on env data, but the app needs the seeded value to properly function, thus BasicData.
8bb9f14 to
65cfc87
Compare
Ticket
https://community.openproject.org/wp/XWI-44