Skip to content

Commit

Permalink
Merge pull request #250 from glennsarti/mergeup-master
Browse files Browse the repository at this point in the history
(maint) Mergeup master into 1.0
  • Loading branch information
glennsarti authored May 16, 2020
2 parents 277bee3 + 2f6e0fc commit 5088c22
Show file tree
Hide file tree
Showing 12 changed files with 154 additions and 65 deletions.
6 changes: 3 additions & 3 deletions .github/issue_template.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--
<!--
Thanks for taking the time to reach out to us!
Please provide the following information with as much detail as you can.
Expand All @@ -23,6 +23,6 @@ PDK Version (if applicable):

### Output Log

<!--
For information how to capture verbose logs, look [here](https://github.com/lingua-pupuli/puppet-vscode/blob/master/client/README.md#2-capture-verbose-logs-and-send-them-to-us)
<!--
For information how to capture verbose logs, look [here](https://puppet-vscode.github.io/docs/experience-a-problem)
-->
4 changes: 2 additions & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ BEFORE YOU CREATE A PULL REQUEST:
Ensure you have read over
CONTRIBUTING - https://github.com/lingua-pupuli/puppet-editor-services/blob/master/CONTRIBUTING.md
CONTRIBUTING - https://github.com/puppetlabs/puppet-editor-services/blob/master/CONTRIBUTING.md
and
CODE_OF_CONDUCT - https://github.com/lingua-pupuli/puppet-editor-services/blob/master/CODE_OF_CONDUCT.md
CODE_OF_CONDUCT - https://github.com/puppetlabs/puppet-editor-services/blob/master/CODE_OF_CONDUCT.md
We provide defined guidance (as such, we strongly adhere to it).
Expand Down
19 changes: 18 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Style/NumericLiterals:
Enabled: false

# Length is not useful indicator
Metrics/LineLength:
Layout/LineLength:
Enabled: false
Metrics/MethodLength:
Enabled: false
Expand Down Expand Up @@ -95,3 +95,20 @@ Style/SafeNavigation:
# This is not valid on Ruby 2.1
Layout/HeredocIndentation:
Enabled: false

# Rubocop 0.80.0 rules
Style/HashEachMethods:
Enabled: false

Style/HashTransformKeys:
Enabled: true

Style/HashTransformValues:
Enabled: true

# Rubocop 0.80.1 rules
Lint/RaiseException:
Enabled: true

Lint/StructNewOverride:
Enabled: true
125 changes: 69 additions & 56 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ group :development do
gem 'rspec', '>= 3.2', :require => false

if Gem::Version.create(RUBY_VERSION) >= Gem::Version.create('2.3.0')
gem "rubocop", ">= 0.77.0", :require => false, :platforms => [:ruby, :x64_mingw]
gem "rubocop", ">= 0.80.0", :require => false, :platforms => [:ruby, :x64_mingw]
end

if ENV['PUPPET_GEM_VERSION']
Expand Down
21 changes: 21 additions & 0 deletions lib/lsp/lsp_custom.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,27 @@ def from_h!(value)
end
end

# export interface GetPuppetFactResponse {
# data: string;
# error: string;
# }
class PuppetFactResponse < LSPBase
attr_accessor :facts # type: string
attr_accessor :error # type: string

def initialize(initial_hash = nil)
super
@optional_method_names = %i[error]
end

def from_h!(value)
value = {} if value.nil?
self.facts = value['facts']
self.error = value['error']
self
end
end

# export interface GetPuppetResourceResponse {
# data: string;
# error: string;
Expand Down
6 changes: 6 additions & 0 deletions lib/puppet-languageserver/facter_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,11 @@ def self.fact_value(session_state, name)
def self.fact_names(session_state)
session_state.object_cache.object_names_by_section(:fact).map(&:to_s)
end

def self.facts_to_hash(session_state)
fact_hash = {}
session_state.object_cache.objects_by_section(:fact) { |factname, fact| fact_hash[factname.to_s] = fact.value }
fact_hash
end
end
end
5 changes: 5 additions & 0 deletions lib/puppet-languageserver/message_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ def request_puppet_getversion(_, _json_rpc_message)
)
end

def request_puppet_getfacts(_, _json_rpc_message)
results = PuppetLanguageServer::FacterHelper.facts_to_hash(session_state)
LSP::PuppetFactResponse.new('facts' => results)
end

def request_puppet_getresource(_, json_rpc_message)
type_name = json_rpc_message.params['typename']
title = json_rpc_message.params['title']
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet_editor_services/version.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module PuppetEditorServices
PUPPETEDITORSERVICESVERSION = '0.25.0' unless defined? PUPPETEDITORSERVICESVERSION
PUPPETEDITORSERVICESVERSION = '0.26.0' unless defined? PUPPETEDITORSERVICESVERSION

# @api public
#
Expand Down
18 changes: 18 additions & 0 deletions spec/languageserver/acceptance/end_to_end_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# Diagnostics response | X | | |
# Hover (Class) | X | | |
# Puppet resource | X | | |
# Puppet facts | X | | |
# Node graph preview | X | | |
# Completion (Typing) | X | - | - |
# Completion (Invoked) | X | - | - |
Expand Down Expand Up @@ -127,6 +128,23 @@ def path_to_uri(path)
expect(result['result']['contents']).not_to be_nil
expect(result['result']['contents']).not_to be_empty

# Puppet Facts request
@client.clear_messages!
@client.send_data(@client.puppet_getfacts_request(@client.next_seq_id))
expect(@client).to receive_message_with_request_id_within_timeout([@client.current_seq_id, 15])
result = @client.data_from_request_seq_id(@client.current_seq_id)
# Expect there to be some facts
expect(result['result']['facts']).not_to be_nil
expect(result['result']['facts']).not_to be_empty
# Expect core facts. Ref https://puppet.com/docs/facter/latest/core_facts.html
%w[facterversion kernel os system_uptime].each do |factname|
expect(result['result']['facts'][factname]).not_to be_nil
expect(result['result']['facts'][factname]).not_to be_empty
end
# Expect nested core facts. Ref https://puppet.com/docs/facter/latest/core_facts.html
expect(result['result']['facts']['os']['release']).not_to be_nil
expect(result['result']['facts']['os']['release']).not_to be_empty

# Puppet Resource request
@client.clear_messages!
@client.send_data(@client.puppet_getresource_request(@client.next_seq_id, 'user'))
Expand Down
9 changes: 9 additions & 0 deletions spec/languageserver/spec_editor_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,15 @@ def puppet_getversion_request(seq_id)
})
end

def puppet_getfacts_request(seq_id)
::JSON.generate({
'jsonrpc' => '2.0',
'id' => seq_id,
'method' => 'puppet/getFacts',
'params' => {}
})
end

def puppet_getresource_request(seq_id, type_name)
::JSON.generate({
'jsonrpc' => '2.0',
Expand Down
2 changes: 1 addition & 1 deletion tools/upload_release.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ Update-GitHubRelease -versionNumber $releaseVersion `
-preRelease $false `
-releaseNotes (Get-ReleaseNotes -Version $releaseVersion) `
-artifactOutputDirectory 'output' `
-gitHubUsername 'lingua-pupuli' `
-gitHubUsername 'puppetlabs' `
-gitHubRepository 'puppet-editor-services' `
-gitHubApiUsername $GitHubUsername `
-gitHubApiKey $GitHubToken

0 comments on commit 5088c22

Please sign in to comment.