You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by se...@apache.org on 2017/06/17 13:56:36 UTC

[whimsy] branch master updated: Extract GitHub get infra-puppet code to public ASF::Git method

This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new 87a4afc  Extract GitHub get infra-puppet code to public ASF::Git method
87a4afc is described below

commit 87a4afc7b4897950cac0ace04f95549ad41ee69b
Author: Sebb <se...@apache.org>
AuthorDate: Sat Jun 17 14:56:34 2017 +0100

    Extract GitHub get infra-puppet code to public ASF::Git method
---
 lib/whimsy/asf/git.rb  | 11 +++++++++++
 lib/whimsy/asf/ldap.rb |  6 ++----
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/lib/whimsy/asf/git.rb b/lib/whimsy/asf/git.rb
index 977e509..86f5ab0 100644
--- a/lib/whimsy/asf/git.rb
+++ b/lib/whimsy/asf/git.rb
@@ -4,6 +4,17 @@ require 'open3'
 module ASF
 
   class Git
+    GITHUB_HOST = 'raw.githubusercontent.com'
+    INFRA_PUPPET = '/apache/infrastructure-puppet/deployment/'
+  
+    def self.infra_puppet(file)
+      # get a file from infrastructure puppet (e.g. 'data/common.yaml')
+      file = INFRA_PUPPET + file
+      http = Net::HTTP.new(GITHUB_HOST, 443)
+      http.use_ssl = true
+      http.request(Net::HTTP::Get.new(file)).body
+    end
+
     @semaphore = Mutex.new
 
     def self.repos
diff --git a/lib/whimsy/asf/ldap.rb b/lib/whimsy/asf/ldap.rb
index ab0d841..40b29a1 100644
--- a/lib/whimsy/asf/ldap.rb
+++ b/lib/whimsy/asf/ldap.rb
@@ -54,12 +54,10 @@ module ASF
     # fetch configuration from apache/infrastructure-puppet
     def self.puppet_config
       return @puppet if @puppet
-      file = '/apache/infrastructure-puppet/deployment/data/common.yaml'
-      http = Net::HTTP.new('raw.githubusercontent.com', 443)
-      http.use_ssl = true
       # the enclosing method is optional, so we only require the gem here
       require 'yaml'
-      @puppet = YAML.load(http.request(Net::HTTP::Get.new(file)).body)
+      require_relative 'git' # just in case
+      @puppet = YAML.load(ASF::Git.infra_puppet('data/common.yaml'))
     end
 
     # extract the ldapcert from the puppet configuration

-- 
To stop receiving notification emails like this one, please contact
['"commits@whimsical.apache.org" <co...@whimsical.apache.org>'].