Skip to content

Commit

Permalink
Release v0.3.0 (#42)
Browse files Browse the repository at this point in the history
* Release v0.3.0

* Remove support of reading key from ENV variable
* Fix incorrect reading keys from config file

* Add `markdownlint` config file
  • Loading branch information
ShockwaveNN authored Sep 11, 2020
1 parent ebeb527 commit b699b65
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 23 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@ jobs:
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
- name: Build and test with Rake
- name: Initialize configuration
env:
S3_KEY: ${{ secrets.S3_KEY }}
S3_PRIVATE_KEY: ${{ secrets.S3_PRIVATE_KEY }}
run: |
mkdir -pv ~/.s3
echo $S3_KEY > ~/.s3/key
echo $S3_PRIVATE_KEY > ~/.s3/private_key
- name: Build and test with Rake
run: |
gem install bundler
bundle install --jobs 4 --retry 3
Expand Down
3 changes: 3 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"MD024": { "siblings_only": true }
}
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

## master (unreleased)

## 0.3.0 (2020-09-11)

### Changes

* Remove support of reading keys from `ENV`

### Fixes

* Fix incorrect keys read from config files
* Add `markdownlint` config file

## 0.2.0 (2020-09-10)

### New Features
Expand Down
28 changes: 8 additions & 20 deletions lib/onlyoffice_s3_wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,27 +136,15 @@ def delete_file(file_path)
end

# Get S3 key and S3 private key
# @param force_file_read [True, False] force key read from file
# @return [Array <String>] list of keys
def read_keys(force_file_read: false)
return if read_env_keys && !force_file_read

@access_key_id = File.read("#{Dir.home}/.s3/key").strip &&
@secret_access_key = File.read("#{Dir.home}/.s3/private_key").strip
# @param key_location [String] Path to search for key files
# @return [nil]
def read_keys(key_location = "#{Dir.home}/.s3")
@access_key_id = File.read("#{key_location}/key").strip
@secret_access_key = File.read("#{key_location}/private_key").strip
rescue Errno::ENOENT
raise Errno::ENOENT, "No key or private key found in #{Dir.home}/.s3/ "\
"Please create files #{Dir.home}/.s3/key "\
"and #{Dir.home}/.s3/private_key"
end

private

# Read keys from env variables
def read_env_keys
return false unless ENV['S3_KEY'] && ENV['S3_PRIVATE_KEY']

@access_key_id = ENV['S3_KEY']
@secret_access_key = ENV['S3_PRIVATE_KEY']
raise Errno::ENOENT, "No key or private key found in #{key_location} "\
"Please create files #{key_location}/key "\
"and #{key_location}/private_key"
end
end
end
2 changes: 1 addition & 1 deletion lib/onlyoffice_s3_wrapper/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

module OnlyofficeS3Wrapper
# [String] Version of gem
VERSION = '0.2.0'
VERSION = '0.3.0'
end
2 changes: 1 addition & 1 deletion spec/onlyoffice_s3_wrapper/amazon_s3_wrapper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
let(:wrapper) { described_class.new }

it 'AmazonS3Wrapper.read_keys raise correct exception if file not found' do
expect { wrapper.read_keys(force_file_read: true) }
expect { wrapper.read_keys('/tmp') }
.to raise_error(/No key or private key/)
end
end

0 comments on commit b699b65

Please sign in to comment.