crossing 0.0.2 → 0.0.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.
Files changed (4) hide show
  1. checksums.yaml +8 -8
  2. data/bin/crossing +2 -1
  3. data/lib/crossing.rb +15 -3
  4. metadata +14 -6
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NGQxM2NmNTU1ODNkNTI2N2ExMTk5M2MyNTQ1MGRkMDI3MjgxYWE4MQ==
4
+ YWJiNDNlMTAyNDZkMDA2NDcyY2E2N2Y1OGRkZTgzMzE1ZTEwZmNmMw==
5
5
  data.tar.gz: !binary |-
6
- ZGY4YjFjNzBhMDVhZjdkYmE5OTAxZjdiODNhOTE5YzdiODdmZmVmYg==
6
+ ZGJmOWM4NTNlZGQwYTQ5ZDdjYmRlM2E1ZTk2MDAwOWJiN2RhNjdiOQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NGI0Yjc1YWRmZDJiYjYwOTkyMGI5NmZhM2E3MDVhNjJlZTU2MTQ0MzkxMzEx
10
- YTZiYWEzNTI3NGQ3ZmE3MjYyMTUxYjY3MWIwMzc2ZmI5YWUwNGExYTYyYjU3
11
- NjVlYmVkZTcxMDkxZmNmZmJkMTk0ZTQ5NGMwM2VmNzA2OWY5MjA=
9
+ ZWQ2YjI4YzYzNzIyNDg2OWY0OWRlMzJhYzYwMWU4YzBkYzU3MDAwOTM5OGU4
10
+ MzI4Zjc4Y2Q3NmJiOTVjZDgxY2I3YzZjZWNhNDk4OTY3MWI3MDE2NjBiY2Fm
11
+ ODZkZjRhOGI1ZTI4NGNkMTIxNmQyYjhhMTQyYjFmYzllMzBmNTc=
12
12
  data.tar.gz: !binary |-
13
- NmJmY2NiMTQ0ZDg5YmE2Y2U5ODhhZDJmYmE4NGFjOGM4MGMzOTg2OTIyMTEx
14
- YmMxZjdjNDgzNjQ5NjVlZGU5NzNmMjk2MWRhMWI5ZjcyZmMxYzQzYmRkNDk3
15
- NzE0NmNlYjQwOWJlY2E2NjM0YjAwMGE3MTA3ZjdhZTI0NmM2OGU=
13
+ NmI0ZWYwMzBlMzgzZjczYWU5ZTU2OWI2YmE0NjdmMmJiZTA3NzFlZjU3ZmNk
14
+ MTgyYzk3ODI1NTdhMTI1ZWMxNjlmMGMyNDg5NDk0YmFjNmE0ZmEzYjQ0OTBk
15
+ YmU3NWNlNGE3YTE4ZWRhOTgwMDNmN2I1YjlmMmY5MGJkYWI1NTg=
@@ -30,12 +30,13 @@ cmd_opts =
30
30
  Trollop.options do
31
31
  opt :file, 'the name of the file to retrieve', required: true, type: String
32
32
  opt :bucket, 'the bucket the file is stored in', required: true, type: String
33
- opt :kmskeyid, 'the kms key id of the master KMS key', required: true, type: String
33
+ opt :kmskeyid, 'the kms key id of the master KMS key', required: false, type: String
34
34
  end
35
35
  else
36
36
  Trollop.die 'usage: crossing [get|put] [parameters]'
37
37
  end
38
38
 
39
+ cmd_opts[:kmskeyid] ||= '_nokey_decrypt_'
39
40
  kms = Aws::KMS::Client.new region: global_opts[:region]
40
41
  s3 = Aws::S3::Encryption::Client.new(
41
42
  kms_key_id: cmd_opts[:kmskeyid],
@@ -3,7 +3,8 @@ require 'aws-sdk'
3
3
  # Documentation incoming
4
4
  class Crossing
5
5
  def initialize(s3_client)
6
- raise 'You did not pass in an S3 client...aborting' if s3_client.nil?
6
+ raise CrossingMisconfigurationException if s3_client.nil?
7
+ raise CrossingMisconfigurationException unless s3_client.is_a? Aws::S3::Encryption::Client
7
8
  @s3_client = s3_client
8
9
  end
9
10
 
@@ -14,7 +15,11 @@ class Crossing
14
15
  raise CrossingFileNotFoundException, "File not found: #{filename}"
15
16
  end
16
17
 
17
- @s3_client.put_object(bucket: bucket, key: filename.split('/').last, body: file.read)
18
+ put_content(bucket, filename.split('/').last, file.read)
19
+ end
20
+
21
+ def put_content(bucket, filename, content)
22
+ @s3_client.put_object(bucket: bucket, key: filename.split('/').last, body: content)
18
23
  end
19
24
 
20
25
  def get(filesystem, bucket, file)
@@ -22,14 +27,21 @@ class Crossing
22
27
  raise CrossingFileExistsException, "File #{file} already exists, will not overwrite."
23
28
  end
24
29
 
25
- content = @s3_client.get_object(bucket: bucket, key: file).body.read
30
+ content = get_content(bucket, file)
26
31
  filesystem.write(file, content)
27
32
  end
33
+
34
+ def get_content(bucket, file)
35
+ @s3_client.get_object(bucket: bucket, key: file).body.read
36
+ end
28
37
  end
29
38
 
30
39
  class CrossingError < StandardError
31
40
  end
32
41
 
42
+ class CrossingMisconfigurationException < CrossingError
43
+ end
44
+
33
45
  class CrossingFileNotFoundException < CrossingError
34
46
  end
35
47
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crossing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Ulick
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-02-03 00:00:00.000000000 Z
13
+ date: 2017-02-26 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: aws-sdk
@@ -40,10 +40,18 @@ dependencies:
40
40
  - - '='
41
41
  - !ruby/object:Gem::Version
42
42
  version: 2.1.2
43
- description: The native AWS command line does not have an easy way to upload encrypted
44
- files to S3. The Ruby SDK has a way to do this, but not everyone wants to use it.
45
- This utility allows you to do client side encrypted uploads to S3 from the command
46
- line, which is useful for uploads from your CI system to docker containers.
43
+ description: ! 'The native AWS command line does not have an easy way to upload encrypted
44
+ files
45
+
46
+ to S3. The Ruby SDK has a way to do this, but not everyone wants to use it.
47
+
48
+ This utility allows you to do client side encrypted uploads to S3 from the
49
+
50
+ command line, which is useful for uploads from your CI system to docker
51
+
52
+ containers.
53
+
54
+ '
47
55
  email: info@stelligent.com
48
56
  executables:
49
57
  - crossing