Chase to main content
  1. Licks, Barks, Howls n Growls from May/

Working With Feature Flags in Gitlab

Remembering How to adjust GitLab Feature Flags

Hello there, my furry friends! You’ve stumbled upon a guide for accessing the GitLab Rails console and adjusting GitLab Feature Flags.

Don’t you just hate it when you keep forgetting those pesky GitLab commands?
Fear not, for I, Atticus Skwirrelbane, am here to help uncover the mysterious medley of GitLab Feature Flags, They’re enigmas

But fear not, my friends, this Savvy Schnauzer is here to help! Then, they’ll be… Enigmas wrapped in Bacon.

RIGHT AFTER I deal with the skwirrelz in the backyard!!

The GitLab Rails Console Exposed #

Take note, fellow code chewers:

For you young pups using Docker-compose: #

This will unlock the GitLab console

docker-compose exec gitlab "gitlab-rails" "console"

For those daring souls driving GitLab directly #

( or from Inside a VM/Container )

gitlab-rails console

Enabling and DisablingFlags #

Once inside the console, a world of possibilities awaits. Just like that bag of treats sitting on that shelf!

To enable or disable a flag, simply bark these pupmands:

Enabling: #

To enable a feature #

Example using feature example_feature

Enabling a fictional feature flag: #

Feature.enable(:<feature flag>)
Feature.enable(:example_feature)

Disabling: #

To Disable a feature: #

Example using feature example_feature

Disabling a fictional feature flag: #

Feature.disable(<feature flag>)
Feature.disable(:example_feature)

Some flags can be enabled just for special pups/projects…

Example: #

Project-scoped feature enablement #

Enable the :example_feature
feature flag for project
1234:

Feature.enable(:<feature flag>, Project.find(<project id>))
Feature.enable(:example_feature, Project.find(1234))
irb(main):001:0> Feature.enable(:example_feature)
=> true

Feature.enable and Feature.disable Always return true.

( Even if the application doesnโ€™t use the flag )

A Dog’s Wisdom #

Now, us dogs know the importance of double-checking our surroundings. I have a few trusty tricks under my collar to verify everything is as it should be:

To sniff out if a flag is enabled or disabled, use Feature.enabled? or Feature.disabled?.

For example, for a feature flag named example_feature that is already enabled:

Feature.enabled?(:example_feature)
=> true
Feature.disabled?(:example_feature)
=> false

View set feature flags #

And when you want to round up all the flags in one go, this command will do the trick

Feature.all
=> [#<Flipper::Feature:198 name="my_feature", state=:on, enabled_gate_names=[:boolean], adapter=:memoizable>]

Nice output #

Feature.all.map {|f| [f.name, f.state]}

Unsetting a feature flag #

But what if you find a flag no longer fits your fancy?
Fear not! You can nuke that skwirrel from orbit with
Feature.remove(:example_feature)
=> true

A Squirrelscape Adventure #

Now, as any dog worth their treats knows, life’s true joys lie in the pursuit of squirrels and naps, not stress or techie tech things. So, this dog…

who’d rather chase tails than debug code…

is trying to help you find the joy of discovery and the thrill of the chase.

‘Cause life is too short for serious tech talk, am I right?

So next time, we’ll sniff out an altogether different kind of treasure - the squirrelly kind!

Stay cool comfy, amigos! ๐Ÿพ๐Ÿ•A