Skip to content

Commit 5daaca9

Browse files
authored
Merge pull request #14 from ahanselka/enable-custom-gitlab
allow usage of a custom GitLab URL
2 parents 8b60712 + 1754edc commit 5daaca9

File tree

8 files changed

+29
-6
lines changed

8 files changed

+29
-6
lines changed

CHANGELOG.markdown

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 0.2.1
2+
3+
- Add custom GitLab URL setting
4+
15
# 0.2.0
26

37
- #8 - Fully automated! Use new gitlab API for the last step

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ gitlab-letsencrypt:
6767
delay_time: 15 # How long to wait between each check once it starts looking for the file
6868

6969
# Optional settings you probably don't need:
70+
gitlab_url: 'https://someurl' # Set if you need to use a self-hosted GitLab instance
7071
endpoint: 'https://somewhere' # if you're doing the ACME thing outside of letsencrypt
7172
branch: 'master' # Defaults to master, but you can use a different branch
7273
layout: 'null' # Layout to use for challenge file - defaults to null, but you can change if needed

lib/jekyll/gitlab/letsencrypt/configuration.rb

+5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class Configuration
1212
DEFAULT_INITIAL_DELAY = 120
1313
DEFAULT_DELAY_TIME = 15
1414
DEFAULT_SCHEME = 'http'
15+
DEFAULT_GITLAB_URL = 'https://gitlab.com'
1516

1617
REQUIRED_KEYS = %w{gitlab_repo email domain}
1718

@@ -25,6 +26,10 @@ def endpoint
2526
jekyll_config['endpoint'] || DEFAULT_ENDPOINT
2627
end
2728

29+
def gitlab_url
30+
jekyll_config['gitlab_url'] || DEFAULT_GITLAB_URL
31+
end
32+
2833
def gitlab_repo
2934
jekyll_config['gitlab_repo']
3035
end

lib/jekyll/gitlab/letsencrypt/gitlab_client.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class GitlabClient
77

88
attr_accessor :content
99

10-
delegate :filename, :personal_access_token, :gitlab_repo, :branch, :domain, to: Configuration
10+
delegate :filename, :personal_access_token, :gitlab_url, :gitlab_repo, :branch, :domain, to: Configuration
1111

1212
def commit!(content)
1313
@content = content
@@ -49,7 +49,7 @@ def commit_file!
4949
content: content
5050
}.to_json
5151
end
52-
Jekyll.logger.info "Done Commiting! Check https://gitlab.com/#{gitlab_repo}/commits/#{branch}"
52+
Jekyll.logger.info "Done Commiting! Check #{gitlab_url}/#{gitlab_repo}/commits/#{branch}"
5353
end
5454

5555
private
@@ -73,7 +73,7 @@ def repo_id
7373
end
7474

7575
def connection
76-
@connection ||= Faraday.new(url: 'https://gitlab.com/api/v3/') do |faraday|
76+
@connection ||= Faraday.new(url: "#{gitlab_url}/api/v3/") do |faraday|
7777
faraday.adapter Faraday.default_adapter
7878
faraday.headers['Content-Type'] = 'application/json'
7979
faraday.headers['PRIVATE-TOKEN'] = personal_access_token

lib/jekyll/gitlab/letsencrypt/process.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def self.process!
1212
self.new(client).process!
1313
end
1414

15-
delegate :base_path, :gitlab_repo, :pretty_url?, :layout, :domain, :initial_delay, :delay_time, :scheme, to: Configuration
15+
delegate :base_path, :gitlab_url, :gitlab_repo, :pretty_url?, :layout, :domain, :initial_delay, :delay_time, :scheme, to: Configuration
1616

1717
def initialize(client)
1818
@client = client
@@ -86,7 +86,7 @@ def update_gitlab_pages
8686

8787
def display_certificate
8888
Jekyll.logger.info "Certifcate retrieved!"
89-
Jekyll.logger.info "Go to https://gitlab.com/#{gitlab_repo}/pages"
89+
Jekyll.logger.info "Go to #{gitlab_url}/#{gitlab_repo}/pages"
9090
Jekyll.logger.info " - If you already have an existing entry for #{domain}, remove it"
9191
Jekyll.logger.info " - Then click + New Domain and enter the following:"
9292
Jekyll.logger.info ""
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Jekyll
22
module Gitlab
33
module Letsencrypt
4-
VERSION = "0.2.0"
4+
VERSION = "0.2.1"
55
end
66
end
77
end

spec/lib/jekyll/gitlab/letsencrypt/configuration_spec.rb

+12
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,16 @@
5959
it { should eq 'https://foo/'}
6060
end
6161
end
62+
63+
describe '#gitlab_url' do
64+
subject { described_class.gitlab_url }
65+
context "with no gitlab_url" do
66+
it { should eq 'https://gitlab.com'}
67+
end
68+
69+
context "with an gitlab_url" do
70+
let(:plugin_config) { {'gitlab_url' => "https://gitlab"} }
71+
it { should eq 'https://gitlab'}
72+
end
73+
end
6274
end

spec/lib/jekyll/gitlab/letsencrypt/gitlab_client_spec.rb

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
let(:filename) { 'test_file.html' }
88
let(:personal_access_token) { 'SECRET_TOKEN' }
9+
let(:gitlab_url) { 'https://gitlab.com'}
910
let(:gitlab_repo) { 'gitlab_user/gitlab_repo' }
1011
let(:branch) { 'test_branch' }
1112
let(:domain) { 'example.com' }

0 commit comments

Comments
 (0)