right_scraper 5.0.1 → 5.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +2 -2
- data/bin/right_scraper-retrieve +76 -0
- data/bin/right_scraper-scan +82 -0
- data/lib/right_scraper.rb +3 -0
- data/lib/right_scraper/main.rb +104 -55
- data/lib/right_scraper/processes.rb +0 -1
- data/lib/right_scraper/processes/shell.rb +2 -2
- data/lib/right_scraper/processes/ssh_agent.rb +1 -1
- data/lib/right_scraper/repositories/base.rb +1 -0
- data/lib/right_scraper/resources/cookbook.rb +18 -0
- data/lib/right_scraper/retrievers/download.rb +1 -1
- data/lib/right_scraper/scanners.rb +2 -0
- data/lib/right_scraper/scanners/cookbook_filename_scanner.rb +83 -0
- data/lib/right_scraper/scanners/cookbook_metadata.rb +134 -148
- data/lib/right_scraper/scanners/{workflow_metadata.rb → cookbook_metadata_readonly.rb} +32 -31
- data/lib/right_scraper/scrapers/base.rb +1 -1
- data/lib/right_scraper/version.rb +2 -2
- data/right_scraper.gemspec +2 -1
- data/{lib/right_scraper/resources/workflow.rb → scripts/knife_metadata.rb} +17 -29
- data/scripts/stub_ssh_askpass +3 -0
- metadata +11 -9
- data/lib/right_scraper/processes/warden.rb +0 -358
- data/lib/right_scraper/scanners/workflow_manifest.rb +0 -87
- data/lib/right_scraper/scanners/workflow_s3_upload.rb +0 -89
- data/lib/right_scraper/scrapers/workflow.rb +0 -94
@@ -1,87 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright: Copyright (c) 2010-2013 RightScale, Inc.
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
-
# a copy of this software and associated documentation files (the
|
6
|
-
# 'Software'), to deal in the Software without restriction, including
|
7
|
-
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
-
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
-
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
-
# the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be
|
13
|
-
# included in all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
18
|
-
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
19
|
-
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
20
|
-
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
21
|
-
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
#++
|
23
|
-
|
24
|
-
# ancestor
|
25
|
-
require 'right_scraper/scanners'
|
26
|
-
|
27
|
-
require 'digest/sha1'
|
28
|
-
|
29
|
-
module RightScraper::Scanners
|
30
|
-
|
31
|
-
# Build manifests from a filesystem.
|
32
|
-
class WorkflowManifest < ::RightScraper::Scanners::Base
|
33
|
-
# Create a new manifest scanner. Does not accept any new arguments.
|
34
|
-
def initialize(*args)
|
35
|
-
super
|
36
|
-
@manifest = {}
|
37
|
-
end
|
38
|
-
|
39
|
-
# Retrieve relative workflow files positions
|
40
|
-
#
|
41
|
-
# === Parameters
|
42
|
-
# workflow(Resources::Workflow):: Workflow whose manifest is being built
|
43
|
-
def begin(workflow)
|
44
|
-
@workflow = workflow
|
45
|
-
@metadata_filename = File.basename(@workflow.metadata_path)
|
46
|
-
@definition_filename = File.basename(@workflow.definition_path)
|
47
|
-
end
|
48
|
-
|
49
|
-
# Complete a scan for the given resource.
|
50
|
-
#
|
51
|
-
# === Parameters ===
|
52
|
-
# resource(RightScraper::Resources::Base):: resource to scan
|
53
|
-
def end(resource)
|
54
|
-
resource.manifest = @manifest
|
55
|
-
@manifest = {}
|
56
|
-
end
|
57
|
-
|
58
|
-
# Notice a file during scanning.
|
59
|
-
#
|
60
|
-
# === Block ===
|
61
|
-
# Return the data for this file. We use a block because it may
|
62
|
-
# not always be necessary to read the data.
|
63
|
-
#
|
64
|
-
# === Parameters ===
|
65
|
-
# relative_position(String):: relative pathname for file from root of resource
|
66
|
-
def notice(relative_position)
|
67
|
-
if [ @metadata_filename, @definition_filename ].include?(relative_position)
|
68
|
-
@manifest[relative_position] = Digest::SHA1.hexdigest(yield)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
# Notice a directory during scanning. Since the workflow definition and
|
73
|
-
# metadata live in the root directory we don't need to recurse,
|
74
|
-
# but we do need to go into the first directory (identified by
|
75
|
-
# +relative_position+ being +nil+).
|
76
|
-
#
|
77
|
-
# === Parameters
|
78
|
-
# relative_position(String):: relative pathname for the directory from root of workflow
|
79
|
-
#
|
80
|
-
# === Returns
|
81
|
-
# Boolean:: should the scanning recurse into the directory
|
82
|
-
def notice_dir(relative_position)
|
83
|
-
relative_position == nil
|
84
|
-
end
|
85
|
-
|
86
|
-
end
|
87
|
-
end
|
@@ -1,89 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright: Copyright (c) 2010-2013 RightScale, Inc.
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
-
# a copy of this software and associated documentation files (the
|
6
|
-
# 'Software'), to deal in the Software without restriction, including
|
7
|
-
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
-
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
-
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
-
# the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be
|
13
|
-
# included in all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
18
|
-
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
19
|
-
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
20
|
-
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
21
|
-
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
#++
|
23
|
-
|
24
|
-
# ancestor
|
25
|
-
require 'right_scraper/scanners'
|
26
|
-
|
27
|
-
require 'right_aws'
|
28
|
-
require 'json'
|
29
|
-
|
30
|
-
module RightScraper::Scanners
|
31
|
-
|
32
|
-
# Upload workflow definition and metadata to an S3 bucket.
|
33
|
-
class WorkflowS3Upload < ::RightScraper::Scanners::Base
|
34
|
-
|
35
|
-
# Create a new S3Upload. In addition to the options recognized
|
36
|
-
# by Scanner, this class recognizes <tt>:s3_key</tt>,
|
37
|
-
# <tt>:s3_secret</tt>, and <tt>:s3_bucket</tt> and requires all
|
38
|
-
# of those.
|
39
|
-
#
|
40
|
-
# === Options
|
41
|
-
# <tt>:s3_key</tt>:: Required. S3 access key.
|
42
|
-
# <tt>:s3_secret</tt>:: Required. S3 secret key.
|
43
|
-
# <tt>:s3_bucket</tt>:: Required. Bucket to upload workflows to.
|
44
|
-
#
|
45
|
-
# === Parameters
|
46
|
-
# options(Hash):: scanner options
|
47
|
-
def initialize(options={})
|
48
|
-
super
|
49
|
-
s3_key = options.fetch(:s3_key)
|
50
|
-
s3_secret = options.fetch(:s3_secret)
|
51
|
-
s3 = RightAws::S3.new(aws_access_key_id=s3_key,
|
52
|
-
aws_secret_access_key=s3_secret,
|
53
|
-
:logger => @logger)
|
54
|
-
@bucket = s3.bucket(options.fetch(:s3_bucket))
|
55
|
-
raise "Need an actual, existing S3 bucket!" if @bucket.nil?
|
56
|
-
end
|
57
|
-
|
58
|
-
# Upon ending a scan for a workflows, upload the workflows
|
59
|
-
# contents to S3.
|
60
|
-
#
|
61
|
-
# === Parameters
|
62
|
-
# workflows(RightScraper::Workflows):: Workflow to scan
|
63
|
-
def end(workflow)
|
64
|
-
@bucket.put(File.join('Workflows', workflow.resource_hash),
|
65
|
-
{
|
66
|
-
:metadata => workflow.metadata,
|
67
|
-
:manifest => workflow.manifest
|
68
|
-
}.to_json)
|
69
|
-
end
|
70
|
-
|
71
|
-
# Upload a file during scanning.
|
72
|
-
#
|
73
|
-
# === Block
|
74
|
-
# Return the data for this file. We use a block because it may
|
75
|
-
# not always be necessary to read the data.
|
76
|
-
#
|
77
|
-
# === Parameters
|
78
|
-
# relative_position(String):: relative pathname for file from root of cookbook
|
79
|
-
def notice(relative_position)
|
80
|
-
# TBD: Only uplad definition and metadata, will there be more files?
|
81
|
-
contents = yield
|
82
|
-
name = Digest::SHA1.hexdigest(contents)
|
83
|
-
path = File.join('Files', name)
|
84
|
-
unless @bucket.key(path).exists?
|
85
|
-
@bucket.put(path, contents)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
@@ -1,94 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright: Copyright (c) 2010-2013 RightScale, Inc.
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
-
# a copy of this software and associated documentation files (the
|
6
|
-
# 'Software'), to deal in the Software without restriction, including
|
7
|
-
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
-
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
-
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
-
# the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be
|
13
|
-
# included in all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
18
|
-
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
19
|
-
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
20
|
-
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
21
|
-
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
#++
|
23
|
-
|
24
|
-
require File.expand_path(File.join(File.dirname(__FILE__), 'base'))
|
25
|
-
|
26
|
-
# ancestor
|
27
|
-
require 'right_scraper/scrapers'
|
28
|
-
|
29
|
-
module RightScraper::Scrapers
|
30
|
-
|
31
|
-
# Workflow scraper
|
32
|
-
class Workflow < ::RightScraper::Scrapers::Base
|
33
|
-
|
34
|
-
# Initialize list of known workflows on top of
|
35
|
-
def initialize(options)
|
36
|
-
@known_workflows = []
|
37
|
-
super(options)
|
38
|
-
end
|
39
|
-
|
40
|
-
# Find the next workflows, starting in dir.
|
41
|
-
#
|
42
|
-
# === Parameters
|
43
|
-
# dir(Dir):: directory to begin search in
|
44
|
-
def find_next(dir)
|
45
|
-
@logger.operation(:finding_next_workflow, "in #{dir.path}") do
|
46
|
-
|
47
|
-
# Note: there could be multiple workflow definitions in one directory
|
48
|
-
# so we need to record the current position whether we found a workflow
|
49
|
-
# or not. The next iteration will search again in the current directory
|
50
|
-
# event if we found one. If we don't find one then we call
|
51
|
-
# 'search_dirs' which will recurse in the sub-directories.
|
52
|
-
@stack << dir
|
53
|
-
|
54
|
-
def_ext = RightScraper::Resources::Workflow::DEFINITION_EXT
|
55
|
-
meta_ext = RightScraper::Resources::Workflow::METADATA_EXT
|
56
|
-
potentials = Dir[File.join(dir.path, "*#{def_ext}")]
|
57
|
-
potentials.reject! { |wdef| !File.exists?(wdef.chomp(File.extname(wdef)) + meta_ext) }
|
58
|
-
potentials.reject! { |wdef| @known_workflows.include?(wdef) }
|
59
|
-
unless potentials.empty?
|
60
|
-
wdef = potentials.first
|
61
|
-
relative_def = strip_repo_dir(wdef)
|
62
|
-
@logger.operation(:reading_workflow, "#{relative_def}") do
|
63
|
-
workflow = RightScraper::Resources::Workflow.new(@repository, relative_def)
|
64
|
-
@builder.go(File.dirname(wdef), workflow)
|
65
|
-
@known_workflows << wdef
|
66
|
-
workflow
|
67
|
-
end
|
68
|
-
else
|
69
|
-
search_dirs
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
# List of default scanners for this scaper
|
75
|
-
#
|
76
|
-
# === Return
|
77
|
-
# Array<Scanner>:: Default scanners
|
78
|
-
def default_scanners
|
79
|
-
[RightScraper::Scanners::WorkflowMetadata,
|
80
|
-
RightScraper::Scanners::WorkflowManifest]
|
81
|
-
end
|
82
|
-
|
83
|
-
# List of default builders for this scaper
|
84
|
-
#
|
85
|
-
# === Return
|
86
|
-
# Array<Builder>:: Default builders
|
87
|
-
def default_builders
|
88
|
-
[RightScraper::Builders::Filesystem]
|
89
|
-
end
|
90
|
-
|
91
|
-
# self-register
|
92
|
-
register_self
|
93
|
-
end
|
94
|
-
end
|