fastlane/docs

Is it possible to use CredentialsManager::AppfileConfig for OTHER files besides Appfile?

slavdok opened this issue · 2 comments

Fastlane is pushing to have all configuration in various *files, like Appfile, Matchfile, Deliverfile, etc.

However, only the values from Appfile can be retrieved using CredentialsManager::AppfileConfig.try_fetch_value().
This presents a problem as often we need to retrieve a value from configuration before running the action.

And without having ability to fetch values from other files, we are left with an inconsistency problem, where some configs are in Appfile, and others are scattered in ENV vars.

I'm gonna be honest, I didn't even know you could load values from the Appfile like that :) but to your point, you could load ALL configs from env vars if you wanted (and use that as a single source of truth), and reference env vars in your Deliverfile, Appfile, Matchfile, etc... Would that work for you?

Thanks for the suggestion, but if I am maintaining the "source of truth" in ENV vars, then why have Appfile, etc in the first place?

This also introduces inconsistencies:

UI.message "Our package id is: #{CredentialsManager::AppfileConfig.try_fetch_value(:package_name)}"
UI.message "Saving metadata to: #{ENV['SUPPLY_METADATA_PATH']}"

I have to always check if the value I need can be got through CredentialManager or ENV
Another problem is that Appfiles take precedence over ENV vars
If I change the above to:

UI.message "Our package id is: #{ENV['SUPPLY_PACKAGE_NAME']}"
UI.message "Saving metadata to: #{ENV['SUPPLY_METADATA_PATH']}

and Appfile has a different value for package_name, I will be displaying the wrong information.
I hear what you are saying: use package_name ENV['SUPPLY_PACKAGE_NAME'] in Appfile.
But I cannot police what other developers would put into the Appfiles (we have many many projects), so if they put package_name "my app name" instead of ENV, then my code in Fastfile will be displaying the wrong value

With Appfile, Deliverfile, etc taking precedence over ENV vars, they (the files) become the source of truth.
In that case, I should be able to query them to get the truth (but alas right now that only works for Appfile) [that I know of]

I would gladly write:

UI.message "Our package id is: #{CredentialsManager::AppfileConfig.try_fetch_value(:package_name) || ENV['SUPPLY_PACKAGE_NAME']}"

but that only works for the few configs allowed in Appfile, and metadata_path is not in Appfile