Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • R RBM
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 28
    • Issues 28
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 1
    • Merge requests 1
  • Deployments
    • Deployments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Repository
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • The Tor Project
  • Applications
  • RBM
  • Issues
  • #40012
Closed
Open
Issue created Jan 12, 2021 by Matthew Finkel@sysrqb

Add a `safe_c` template subroutine

Currently, we have a c() subroutine for obtaining configuration variables, however if the requested variable is not defined then this subroutine returns "". In many cases, we would prefer a build failure when a requested variable is not set, instead of continuing while using the empty string.

I believe we can define another subroutine that is the same as c() except it sets error_if_undef => 1. As a placeholder name, let's call this new subroutine safe_c. c is nice because it is short, we already have pc defined, as well. Maybe we should call this proposed subroutine sc.

My untested proposed patch is:

diff --git a/lib/RBM.pm b/lib/RBM.pm
index 074e385..bec5a30 100644
--- a/lib/RBM.pm
+++ b/lib/RBM.pm
@@ -652,6 +652,7 @@ sub process_template {
         project    => $project,
         p          => $config->{projects}{$project},
         c          => sub { project_config($project, @_) },
+        safe_c     => sub { project_config($project, @_, { error_if_undef => 1 }) },
         pc         => sub {
             my @args = @_;
             $args[2] = { $_[2] ? %{$_[2]} : (), origin_project => $project };
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking