Class: Jekyll::Gitlab::Letsencrypt::GitlabClient
- Inherits:
-
Object
- Object
- Jekyll::Gitlab::Letsencrypt::GitlabClient
- Defined in:
- lib/jekyll/gitlab/letsencrypt/gitlab_client.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
Instance Method Summary collapse
- #commit!(content) ⇒ Object
- #commit_file! ⇒ Object
- #create_branch! ⇒ Object
- #update_certificate!(certificate, key) ⇒ Object
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
8 9 10 |
# File 'lib/jekyll/gitlab/letsencrypt/gitlab_client.rb', line 8 def content @content end |
Instance Method Details
#commit!(content) ⇒ Object
12 13 14 15 16 |
# File 'lib/jekyll/gitlab/letsencrypt/gitlab_client.rb', line 12 def commit!(content) @content = content create_branch! unless branch_exists? commit_file! end |
#commit_file! ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/jekyll/gitlab/letsencrypt/gitlab_client.rb', line 41 def commit_file! Jekyll.logger.info "Commiting challenge file as #{filename}" connection.run_request(request_method_for_commit, nil, nil, nil) do |req| req.url "projects/#{repo_id}/repository/files/#{enc_filename}" req.body = { commit_message: "Automated Let's Encrypt renewal", branch: branch, content: content }.to_json end Jekyll.logger.info "Done Commiting! Check #{gitlab_url}/#{gitlab_repo}/commits/#{branch}" end |
#create_branch! ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/jekyll/gitlab/letsencrypt/gitlab_client.rb', line 30 def create_branch! Jekyll.logger.info "Creating branch #{branch}.." connection.post do |req| req.url "projects/#{repo_id}/repository/branches" req.body = { branch: branch, ref: 'master' }.to_json end end |
#update_certificate!(certificate, key) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/jekyll/gitlab/letsencrypt/gitlab_client.rb', line 18 def update_certificate!(certificate, key) Jekyll.logger.info "Updating domain #{domain} pages setting with new certificates.." response = connection.put do |req| req.url "projects/#{repo_id}/pages/domains/#{domain}" req.body = { certificate: certificate, key: key }.to_json end response.success? end |