summaryrefslogtreecommitdiff
path: root/provider_base/lib
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2015-08-07 18:08:14 -0700
committerelijah <elijah@riseup.net>2015-08-07 18:08:14 -0700
commite6f6324ebea9fc46d5d617a08c2eb239349d9f90 (patch)
tree76334f2889abd9348cd38aa8600dfc6115e30b4d /provider_base/lib
parentfc082470fa945dd5a394057cbea8ea55831b9fad (diff)
move 'enabled service' calculation to a macro.
Diffstat (limited to 'provider_base/lib')
-rw-r--r--provider_base/lib/macros.rb1
-rw-r--r--provider_base/lib/macros/provider.rb20
2 files changed, 21 insertions, 0 deletions
diff --git a/provider_base/lib/macros.rb b/provider_base/lib/macros.rb
index ecc3e6ba..fdb9a94e 100644
--- a/provider_base/lib/macros.rb
+++ b/provider_base/lib/macros.rb
@@ -13,3 +13,4 @@ require_relative 'macros/keys'
require_relative 'macros/nodes'
require_relative 'macros/secrets'
require_relative 'macros/stunnel'
+require_relative 'macros/provider'
diff --git a/provider_base/lib/macros/provider.rb b/provider_base/lib/macros/provider.rb
new file mode 100644
index 00000000..84c4e1b8
--- /dev/null
+++ b/provider_base/lib/macros/provider.rb
@@ -0,0 +1,20 @@
+#
+# These macros are intended only for use in provider.json, although they are
+# currently loaded in all .json contexts.
+#
+
+module LeapCli
+ module Macro
+
+ #
+ # returns an array of the service names, including only those services that
+ # are enabled for this environment.
+ #
+ def enabled_services
+ manager.env(self.environment).services[:service_type => :user_service].field(:name).select { |service|
+ manager.nodes[:environment => self.environment][:services => service].any?
+ }
+ end
+
+ end
+end