-
-
Couldn't load subscription status.
- Fork 12
Added Timebomb functionality to Features #21
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
8ccf2ff
Added new Columns to Features Table
AidanLaycock 6bfe873
Added Timebomb Feature
AidanLaycock fc0728b
Resolved failing test
AidanLaycock dfe2596
Added Time bomb Environments to prevent affecting production
AidanLaycock 6325b1f
Refactored exception check for whether a feature has expired.
AidanLaycock 48602d0
Refactored nested conditionals into intermediate variables for checki…
AidanLaycock a7c1e6e
Readded test to check that no Exception is thrown when time bombs are…
AidanLaycock 907fbce
Added Pest Plugins
AidanLaycock df3a22c
Removed unneeded comment. And minor refactor to simplify null check.
AidanLaycock 5566232
Implemented missing return types.
AidanLaycock f4b2fdb
Updated ReadMe to include how to use Timebombs functionality
AidanLaycock File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
database/migrations/2022_04_27_090000_add_feature_flag_expiry.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| <?php | ||
|
|
||
| use Illuminate\Database\Migrations\Migration; | ||
| use Illuminate\Database\Schema\Blueprint; | ||
| use Illuminate\Support\Facades\Schema; | ||
|
|
||
| return new class extends Migration | ||
| { | ||
| public function up() | ||
| { | ||
| if (Schema::hasTable('features')) { | ||
| Schema::table('features', function (Blueprint $table) { | ||
| $table->datetime('expires_at')->nullable(); | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| public function down() | ||
| { | ||
| if (Schema::hasTable('features')) { | ||
| Schema::table('features', function (Blueprint $table) { | ||
| $table->dropColumn('expires_at'); | ||
| }); | ||
| } | ||
| } | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace JustSteveKing\Laravel\FeatureFlags\Console; | ||
|
|
||
| use Illuminate\Console\Command; | ||
| use JustSteveKing\Laravel\FeatureFlags\Models\Feature; | ||
|
|
||
| class ExtendFeature extends Command | ||
| { | ||
| protected $signature = 'feature-flags:extend-feature'; | ||
|
|
||
| protected $description = 'Extend a features expiry date'; | ||
|
|
||
| public function handle(): int | ||
| { | ||
| if(! config('feature-flags.enable_time_bombs')) $this->info("Time bombs are not enabled!"); | ||
|
|
||
| $featureName = $this->ask('Feature Name to Extend'); | ||
| $feature = Feature::name($featureName)->first(); | ||
|
|
||
| $extendBy = $this->ask('When do you want your feature to expire? (Number of Days)', 0); | ||
|
|
||
| $feature->expires_at = $feature->expires_at->addDays($extendBy); | ||
| $feature->save(); | ||
|
|
||
| $this->info("Updated '{$featureName}' feature expiry date"); | ||
|
|
||
| return 0; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,7 @@ | |
| class User extends AuthUser | ||
| { | ||
| use HasFeatures; | ||
|
|
||
| public $guarded = []; | ||
|
|
||
| public $table = 'users'; | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find the name
time_bomb_environmentsa little counter-intuitive. Without reading the comment, I would have assumed that these are the environments in which the time bombs are active, not the other way around.Another thing is that my first instinct have would be to have the time bombs be deactivated in every environment and to explicitly activate them for certain environments. I think this would reduce the chance of accidentally activating it in production because of a typo or something similar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to agree here, time bomb feature should be enabled per environment and off by default - not something you would typically have in staging/qa
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ksassnowski @JustSteveKing - Thank you for the feedback. Do you think if the 'enable_time_bombs' had an environment variable this would resolve this? As that value governs whether the feature is on/off at all.
We're using trunk based development which is why I considered having an exclude rather than include list, as we'd want it to be on all of the time except for production rather than having to specify on for dev, testing, qa, staging.