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

Support configuration of credentials with a config array #202

Merged
merged 11 commits into from
Oct 5, 2023

Conversation

clemblanco
Copy link
Contributor

@clemblanco clemblanco commented Sep 26, 2023

Description

On our applications, in order to have more granularity in the configuration of the credentials, we had to extend the package to be able to optionally receive the configuration of the credentials via an array instead of a JSON file.

This makes it easier to integrate with our CI/CD pipelines and also gives us the ability to cache the config via Laravel.

This is a change we think could be valuable to others too, especially considering that firebase-php already supports arrays,

Note: we slightly tweaked the expected configuration array for credentials but don't worry this is a non-breaking change.

- 'credentials' => [
-     'file' => 'some_path.json',
- ],
+ 'credentials' => 'some_path.json',

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have added tests that prove my fix is effective or that my feature works
  • I have made corresponding changes to the documentation

@clemblanco clemblanco changed the title feat: support configuration of credentials via config array feat!: support configuration of credentials via config array Sep 26, 2023
@clemblanco clemblanco changed the title feat!: support configuration of credentials via config array feat: support configuration of credentials via config array Sep 26, 2023
Copy link
Member

@jeromegamez jeromegamez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for taking the time to open this PR, this will be a welcome improvement and much appreciated! 🙏🏻

Most of my change request address introduced whitespaces, blank lines and other formatting.

The relevant changes are

  • I would prefer the introduction of Arr in a separate PR so that this PR is only about the added functionality.
  • I would move the checks into the resolveCredentials() method.

Out of curiosity: do you see a way to let users of the package now that using file should be considered deprecated other than adding a comment? Either way, I'm going to just™ remove it in the next major version.

Thanks again!

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
config/firebase.php Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
src/FirebaseProjectManager.php Outdated Show resolved Hide resolved
src/FirebaseProjectManager.php Outdated Show resolved Hide resolved
src/FirebaseProjectManager.php Outdated Show resolved Hide resolved
src/FirebaseProjectManager.php Outdated Show resolved Hide resolved
tests/FirebaseProjectManagerTest.php Outdated Show resolved Hide resolved
@clemblanco
Copy link
Contributor Author

Hi @jeromegamez,

I think it's ready for a second look.

I would move the checks into the resolveCredentials() method.

I renamed this into resolveJsonCredentials() as it's only useful for JSON credentials. If it's an array, there is simply no credentials to resolve, they are already there, ready to be used.

Out of curiosity: do you see a way to let users of the package now that using file should be considered deprecated other than adding a comment? Either way, I'm going to just™ remove it in the next major version.

Either log something with logger()->warn() for example while both are still supported... or don't bother and make it a breaking change in the next major release. Should be fine as long as things are documented properly and the release notes make it clear enough.

✌️

@clemblanco clemblanco requested a review from jeromegamez October 5, 2023 13:45
@jeromegamez
Copy link
Member

Thanks for bearing with me (honestly), even though some requests were inconsistent 😅

There was a problem with the codecov action (codecov/codecov-action#1089) which I fixed in the main branch, could you rebase the PR so that the workflows can run again?

@jeromegamez
Copy link
Member

Uh, nice, I just discovered the Rebase button in the web view of a PR! If this works, I'll merge!

@codecov
Copy link

codecov bot commented Oct 5, 2023

Codecov Report

Merging #202 (6ae431e) into main (10cc86b) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##               main     #202   +/-   ##
=========================================
  Coverage     98.41%   98.41%           
- Complexity       47       48    +1     
=========================================
  Files             3        3           
  Lines           126      126           
=========================================
  Hits            124      124           
  Misses            2        2           
Files Coverage Δ
src/FirebaseProjectManager.php 96.87% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@jeromegamez jeromegamez changed the title feat: support configuration of credentials via config array Support configuration of credentials with a config array Oct 5, 2023
@jeromegamez jeromegamez merged commit 25f3214 into kreait:main Oct 5, 2023
7 checks passed
@jeromegamez
Copy link
Member

Thanks again! 🙏🏻

@jeromegamez
Copy link
Member

I applied your config file blank line changes in and added you as a Co-Author to 5b682a0 - I hope I got them all 🤞🏻

I also changed the Code Style Fixer to Laravel Pint in 8772cc4

@clemblanco
Copy link
Contributor Author

Nice one thanks.

Would you be able to publish a new release please?

@jeromegamez
Copy link
Member

Done ✅

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

Successfully merging this pull request may close these issues.

2 participants