Skip to content

Commit

Permalink
Update syntax per newest rubocop (0.42.0) (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
shortdudey123 authored and sample committed Jul 25, 2016
1 parent b72ec3f commit 5348c76
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
AllCops:
DisplayCopNames: true
Metrics/AbcSize:
Enabled: false
Style/GuardClause:
Expand All @@ -12,3 +14,5 @@ Metrics/ClassLength:
Max: 200
Metrics/ParameterLists:
Enabled: false
Style/NumericLiteralPrefix:
EnforcedOctalStyle: zero_only
31 changes: 17 additions & 14 deletions lib/chef/knife/openvpn.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,18 +141,21 @@ def issue_crl(revoke_info, serial, lastup, nextup, extensions,
crl.version = 1
crl.last_update = lastup
crl.next_update = nextup
revoke_info.each do|rserial, time, reason_code|
revoke_info.each do |rserial, time, reason_code|
revoked = OpenSSL::X509::Revoked.new
if rserial.is_a? OpenSSL::BN
revoked.serial = rserial
else
revoked.serial = OpenSSL::BN.new(rserial)
end
if time.is_a? Time
revoked.time = time
else
revoked.time = Time.parse(time)
end

revoked.serial = if rserial.is_a? OpenSSL::BN
rserial
else
OpenSSL::BN.new(rserial)
end

revoked.time = if time.is_a?
time
else
Time.parse(time)
end

enum = OpenSSL::ASN1::Enumerated(reason_code)
ext = OpenSSL::X509::Extension.new('CRLReason', enum)
revoked.add_extension(ext)
Expand All @@ -163,7 +166,7 @@ def issue_crl(revoke_info, serial, lastup, nextup, extensions,
ef.crl = crl
crlnum = OpenSSL::ASN1::Integer(serial)
crl.add_extension(OpenSSL::X509::Extension.new('crlNumber', crlnum))
extensions.each do|oid, value, critical|
extensions.each do |oid, value, critical|
crl.add_extension(ef.create_extension(oid, value, critical))
end
crl.sign(issuer_key, digest)
Expand Down Expand Up @@ -403,7 +406,7 @@ def generate_client_config(server_name, user_name)
query = "openvpn_server_name:#{server_name}"
query_nodes = Chef::Search::Query.new
search_result = query_nodes.search('node', query)[0]
if search_result.length < 1
if search_result.empty?
fail_with "Cant find vpn server named '#{server_name}', chef search for node with attribute openvpn.server_name:#{server_name} return no result"
end
config_content = ''
Expand All @@ -415,7 +418,7 @@ def generate_client_config(server_name, user_name)
config_content << "proto #{config['proto']}" << newline
search_result.each do |result|
config_content << "remote #{result['openvpn'][server_name]['remote_host']} "
config_content << "#{config['port']}" << newline
config_content << config['port'].to_s << newline
end
config_content << "verb #{config['verb']}" << newline
config_content << 'comp-lzo' << newline
Expand Down

0 comments on commit 5348c76

Please sign in to comment.