contrib: aws api coverage report script

quick 'n' dirty - might have some bugs, but it'll get us started
This commit is contained in:
Paul Hinze 2015-05-12 14:07:08 -05:00
parent 6835009238
commit 2d1aafd549
1 changed files with 49 additions and 0 deletions

View File

@ -0,0 +1,49 @@
#
# This script generates CSV output reporting on the API Coverage of Terraform's
# AWS Provider.
#
# In addition to Ruby, it depends on a properly configured Go development
# environment with both terraform and aws-sdk-go present.
#
require 'csv'
require 'json'
require 'pathname'
module APIs
module Terraform
def self.path
@path ||= Pathname(`go list -f '{{.Dir}}' github.com/hashicorp/terraform`.chomp)
end
def self.called?(api, op)
`git -C "#{path}" grep "#{api}.*#{op}" -- builtin/providers/aws | wc -l`.chomp.to_i > 0
end
end
module AWS
def self.path
@path ||= Pathname(`go list -f '{{.Dir}}' github.com/awslabs/aws-sdk-go/aws`.chomp).parent
end
def self.api_json_files
Pathname.glob(path.join('**', '*.normal.json'))
end
def self.each
api_json_files.each do |api_json_file|
json = JSON.parse(api_json_file.read)
api = api_json_file.dirname.basename
json["operations"].keys.each do |op|
yield api, op
end
end
end
end
end
csv = CSV.new($stdout)
csv << ["API", "Operation", "Called in Terraform?"]
APIs::AWS.each do |api, op|
csv << [api, op, APIs::Terraform.called?(api, op)]
end