Skip to content

Commit

Permalink
Remove flipper api until we can put it behind auth
Browse files Browse the repository at this point in the history
- Add cap tasks to enable / disable banner
  • Loading branch information
maxkadel committed Jul 22, 2024
1 parent 4cbc233 commit b181045
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 34 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ gem 'bootsnap', require: false
gem 'ddtrace', require: 'ddtrace/auto_instrument'
gem 'dogstatsd-ruby'
gem 'flipper-active_record'
gem 'flipper-api', '~> 1.3'
gem 'honeybadger'
gem 'lograge'
gem 'logstash-event'
Expand Down
4 changes: 0 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,6 @@ GEM
flipper-active_record (1.3.0)
activerecord (>= 4.2, < 8)
flipper (~> 1.3.0)
flipper-api (1.3.0)
flipper (~> 1.3.0)
rack (>= 1.4, < 4)
hashdiff (1.1.0)
honeybadger (5.13.3)
i18n (1.14.5)
Expand Down Expand Up @@ -332,7 +329,6 @@ DEPENDENCIES
dogstatsd-ruby
ed25519
flipper-active_record
flipper-api (~> 1.3)
honeybadger
lograge
logstash-event
Expand Down
35 changes: 8 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,35 +114,16 @@ bundle exec rake banner:update\[$LONG_HTML,'info',false,true\]
```

## Set the banner to visible or not visible
### Via Capistrano
Can be run locally against a remote environment. Must be on VPN.
```zsh
bundle exec cap staging banner:enable
bundle exec cap staging banner:disable
```

### Via the Flipper CLI
Must be done on one of the servers
Must be done on the environment where you want to change it
```bash
bundle exec flipper enable banner
bundle exec flipper disable banner
```

### Via the Flipper API
Can be done from anywhere

The commands below are for the production host, but if you are on VPN you can also do this against allsearch-api-staging.

- To see the current state of the banner flipper
```bash
curl http://allsearch-api/flipper/api/features/banner
```
- To enable the banner
```bash
curl -X POST http://allsearch-api/flipper/api/features/banner/boolean
```
- To disable the banner
```bash
curl -X DELETE http://allsearch-api/flipper/api/features/banner/boolean
```

### Feature Flipper
In order to create a new feature flipper for an environment:
See [Flipper API documentation](https://www.flippercloud.io/docs/api#create-a-new-feature)

```bash
curl -X POST -d "name=banner" https://allsearch-api-staging.princeton.edu/flipper/api/features
```
2 changes: 0 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,4 @@
get '/search/pulmap', to: 'pulmap#show', defaults: { format: 'json' }
get '/search/staff/', to: 'library_staff#show', defaults: { format: 'json' }
get '/search/website', to: 'library_website#show', defaults: { format: 'json' }

mount Flipper::Api.app(Flipper) => '/flipper/api'
end
25 changes: 25 additions & 0 deletions lib/capistrano/tasks/banner.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

require 'flipper'

namespace :banner do
desc 'Enable banner'
task :enable do
on roles(:db) do
within '/opt/allsearch_api/current' do
execute :bundle, :exec, :flipper, :enable, :banner
end
end
run_locally { puts('The banner is now enabled and should display.') }
end

desc 'Disable banner'
task :disable do
on roles(:db) do
within '/opt/allsearch_api/current' do
execute :bundle, :exec, :flipper, :disable, :banner
end
end
run_locally { puts('The banner is now disabled and should not display.') }
end
end

0 comments on commit b181045

Please sign in to comment.