logstash-input-qingstor 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/lib/logstash/inputs/qingstor.rb +9 -2
- data/logstash-input-qingstor.gemspec +3 -3
- data/spec/inputs/qingstor_spec.rb +13 -3
- data/spec/inputs/qs_access_helper.rb +4 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c3ef515c2bf42830ada2c07360ee1444a239470
|
4
|
+
data.tar.gz: 24375bc480c7560c2fb358cd3d6b65635d0b18bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 924eb9d4eb958184a9efa290195a5728fcae475be0f948d71bffa204dfabea6df7bef25dd21124abefa4b0f0276ef490fce0438c88eb027a3cd7bad1e0aaa18f
|
7
|
+
data.tar.gz: fc3332dab20489769f43e5cf0e26939bfdbd4978ebfea9e5e8d10caaf76d012c02489108d0a5899ddce3abee38e2f5913182e662ad281fbb25a9c61d709c5f81
|
data/README.md
CHANGED
@@ -43,6 +43,14 @@ input {
|
|
43
43
|
# 默认: false
|
44
44
|
delete_remote_files => true
|
45
45
|
|
46
|
+
# 重新配置qingstor的地址
|
47
|
+
# 默认: nil
|
48
|
+
host => "new.qingstor.net"
|
49
|
+
|
50
|
+
# 重新配置qingstor地址的端口号
|
51
|
+
# 默认: 443
|
52
|
+
port => 443
|
53
|
+
|
46
54
|
# 如果指定一个本地目录, 那么在处理完之后将文件备份至该位置.
|
47
55
|
# 默认: nil
|
48
56
|
local_dir => 'your/local/directory'
|
@@ -18,11 +18,17 @@ class LogStash::Inputs::Qingstor < LogStash::Inputs::Base
|
|
18
18
|
# The key to access your QingStor
|
19
19
|
config :secret_access_key, :validate => :string, :required => true
|
20
20
|
|
21
|
+
# If specified, it would redirect to this host address.
|
22
|
+
config :host, :validate => :string, :default => nil
|
23
|
+
|
24
|
+
# It specifies the host port, please coordinate with config 'host'.
|
25
|
+
config :port, :validate => :number, :default => 443
|
26
|
+
|
21
27
|
# The name of the qingstor bucket
|
22
28
|
config :bucket, :validate => :string, :required => true
|
23
29
|
|
24
30
|
# The region of the QingStor bucket
|
25
|
-
config :region, :validate =>
|
31
|
+
config :region, :validate => :string, :default => "pek3a"
|
26
32
|
|
27
33
|
# If specified, it would only download the files with the specified prefix.
|
28
34
|
config :prefix, :validate => :string, :default => nil
|
@@ -69,6 +75,7 @@ class LogStash::Inputs::Qingstor < LogStash::Inputs::Base
|
|
69
75
|
@logger.info "Registering QingStor plugin", :bucket => @bucket, :region => @region
|
70
76
|
|
71
77
|
@qs_config = QingStor::SDK::Config.init @access_key_id, @secret_access_key
|
78
|
+
@qs_config.update({ host: @host, port: @port }) unless @host.nil?
|
72
79
|
@qs_service = QingStor::SDK::Service.new @qs_config
|
73
80
|
@qs_bucket = @qs_service.bucket @bucket, @region
|
74
81
|
|
@@ -143,7 +150,7 @@ class LogStash::Inputs::Qingstor < LogStash::Inputs::Base
|
|
143
150
|
|
144
151
|
md5_string = Digest::MD5.file(@tmp_file_path).to_s
|
145
152
|
|
146
|
-
new_key = if @backup_prefix.end_with?('/')
|
153
|
+
new_key = if @backup_prefix.end_with?('/') || @backup_prefix.empty?
|
147
154
|
@backup_prefix + key
|
148
155
|
else
|
149
156
|
@backup_prefix + '/' + key
|
@@ -1,9 +1,9 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-input-qingstor'
|
3
|
-
s.version = '0.1.
|
3
|
+
s.version = '0.1.3'
|
4
4
|
s.licenses = ['Apache License (2.0)']
|
5
5
|
s.summary = 'logstash input plugin for QingStor'
|
6
|
-
s.description = 'Use this plugin to fetch file as
|
6
|
+
s.description = 'Use this plugin to fetch file from Qingstor as the input of logstash'
|
7
7
|
s.homepage = 'https://github.com/Tacinight/logstash-input-qingstor'
|
8
8
|
s.authors = ['Evan Zhao']
|
9
9
|
s.email = 'tacingiht@gmail.com'
|
@@ -24,4 +24,4 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.add_runtime_dependency "qingstor-sdk", ">=1.9.2"
|
25
25
|
|
26
26
|
s.add_development_dependency 'logstash-devutils'
|
27
|
-
end
|
27
|
+
end
|
@@ -29,7 +29,7 @@ describe LogStash::Inputs::Qingstor do
|
|
29
29
|
let(:backup) { "logstash-backup" }
|
30
30
|
let(:local_backup_dir) { File.join(Dir.tmpdir, backup) }
|
31
31
|
|
32
|
-
context "local
|
32
|
+
context "at the local end" do
|
33
33
|
it "backup to local dir" do
|
34
34
|
fetch_events(config.merge({"backup_local_dir" => local_backup_dir }))
|
35
35
|
expect(File.exists?(File.join(local_backup_dir, key1))).to be_truthy
|
@@ -42,15 +42,25 @@ describe LogStash::Inputs::Qingstor do
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
context "remote
|
45
|
+
context "at the remote end " do
|
46
46
|
it "backup to another bucket" do
|
47
47
|
fetch_events(config.merge({"backup_bucket" => backup}))
|
48
48
|
expect(list_remote_file(backup).size).to eq(2)
|
49
49
|
end
|
50
50
|
|
51
51
|
after do
|
52
|
-
|
52
|
+
clean_and_delete_bucket(backup)
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
+
context "advance config" do
|
57
|
+
it "redirect to the specified host without specified port" do
|
58
|
+
expect{fetch_events(config.merge({"host" => "qingstor.dev"}))}.to raise_error(Net::HTTP::Persistent::Error)
|
59
|
+
end
|
60
|
+
|
61
|
+
it "redirect to the specified host without specified port" do
|
62
|
+
expect{fetch_events(config.merge({"host" => "qingstor.dev", "port" => 444}))}.to raise_error(Net::HTTP::Persistent::Error)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
56
66
|
end
|
@@ -37,7 +37,10 @@ def list_remote_file(bucket = ENV['bucket'], region = ENV['region'])
|
|
37
37
|
return bucket.list_objects[:keys]
|
38
38
|
end
|
39
39
|
|
40
|
-
def
|
40
|
+
def clean_and_delete_bucket(bucket)
|
41
41
|
bucket = qs_init_bucket(bucket)
|
42
|
+
bucket.list_objects[:keys].each do |file|
|
43
|
+
bucket.delete_object file[:key]
|
44
|
+
end
|
42
45
|
bucket.delete
|
43
46
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-input-qingstor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evan Zhao
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,7 +86,7 @@ dependencies:
|
|
86
86
|
- - ">="
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: '0'
|
89
|
-
description: Use this plugin to fetch file as
|
89
|
+
description: Use this plugin to fetch file from Qingstor as the input of logstash
|
90
90
|
email: tacingiht@gmail.com
|
91
91
|
executables: []
|
92
92
|
extensions: []
|