We have updated our Terms of Service, Code of Conduct, and Addendum.

Using variables to select the production or staging redis environment?

:question: - I have two branches. `master` is my production and `staging` is my staging/dev environment. I also have two redis servers for production (`production-redis`) and staging (`non-prod-redis`) Cribl. Now in redis function, how can I use `C.env.CRIBL_GIT_BRANCH` variable to specify either `production-redis` OR `non-prod-redis`?

Answers

  • Jon Rust
    Jon Rust Posts: 475 mod

    the redis URL field is an expression you reference the global vars there ``redis://${C.env.CRIBL_GIT_BRANCH == "master" ? "production-redis" : "non-prod-redis"}:6379``

  • Jon Rust
    Jon Rust Posts: 475 mod

    possibly easier to understand method: 2 redis functions with filters that use the git branch to fire or not eg, redis function one has a filter `C.env.CRIBL_GIT_BRANCH == "master"` and inside references the production-redis url

  • Martin Prado
    Martin Prado Posts: 27 ✭✭

    I liked 2nd approach because my redis credentials are different in production and staging redis

  • Martin Prado
    Martin Prado Posts: 27 ✭✭

    Thank you Jon.