occson 4.0.0 → 4.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b08e08740cea055b6c5a32c1380dd6eb7dfa8c4f75d1fadcb717c6f2f6a7022d
4
- data.tar.gz: 11808e7cb917b8abf9a0f290289cc0353e3522695725cc0055c3ebd4eed0254e
3
+ metadata.gz: 6b458b7d3e92314c70ee9501b770924d0bcdffe39dd45da3fb2fe8bdba6ca23f
4
+ data.tar.gz: b5e2c2cc60ee4188d3918f8e4be356a452945d2cbddc0fd59d02d48db5d96eba
5
5
  SHA512:
6
- metadata.gz: 805566d333b73c0ff8e4796476195e361fcda648360e7a6dba99858f7603fe605fefa263d93b6fa3ac053208e0e4525eb686bd963d5530f36001992b83aee7af
7
- data.tar.gz: 4976e02e9f0810e5dda2e80cb4370b611587d1a17597a1810e1f5f6288b6d81b0701a84e6a294c14f1e1221d76c15cb391c560bffe4894ce61c5af3025cc0ddf
6
+ metadata.gz: 36976362babf2b310468bb96f60aec79e24725d0fd2dd4181b6300ce39096a27b844cbaf68bc9f18cb3e99c682de81ebf7e3c983c289d38f2a181e764385cc91
7
+ data.tar.gz: 105df53bca9702fb58a9c61e338f7c7dd3a35f72c736a9df5b44d7e692a5e132c4a0c8e948d24bf099ab9e81b79dffbf42b1658df1c7987a5a83a2808bdb4572
data/CHANGELOG.md CHANGED
@@ -1,3 +1,27 @@
1
+ ## 4.1.1 2023-02-09
2
+
3
+ ### Upgraded
4
+
5
+ - rubocop
6
+ - reek
7
+ - pry
8
+ - rspec
9
+ - simplecov
10
+ - yard
11
+ - webmock
12
+ - rake
13
+
14
+ [Compare 4.1.0...4.1.1](https://github.com/occson/occson.rb/compare/4.1.0...4.1.1)
15
+
16
+ ## 4.1.0 2022-02-06
17
+
18
+ ### Added
19
+
20
+ - run command
21
+
22
+ [Compare 4.0.0...4.1.0](https://github.com/occson/occson.rb/compare/4.0.0...4.1.0)
23
+
24
+
1
25
  ## 4.0.0 2021-10-06
2
26
 
3
27
  ### Changed
data/README.md CHANGED
@@ -28,6 +28,15 @@ Or install it yourself as:
28
28
  -f, --[no-]force Overwrite remote documents when uploading
29
29
 
30
30
 
31
+ occson run [OPTIONS] <OccsonUri> -- <Command>
32
+
33
+ Options:
34
+ -a OCCSON_ACCESS_TOKEN, Occson access token
35
+ --access-token
36
+ -p OCCSON_PASSPHRASE, Occson passphrase
37
+ --passphrase
38
+
39
+
31
40
  ## Example
32
41
 
33
42
  Download to STDOUT
@@ -54,6 +63,10 @@ Upload content from STDIN
54
63
  echo "{ a: 1 }" | occson cp - occson://0.1.0/path/to/file.yml
55
64
  cat /local/path/to/file.yml | occson cp - occson://0.1.0/path/to/file.yml
56
65
 
66
+ Run command with downloaded environment variables
67
+
68
+ occson run occson://0.1.0/.env -- printenv
69
+
57
70
  ## API
58
71
 
59
72
  Upload
data/exe/occson CHANGED
@@ -20,6 +20,7 @@ option_parser = OptionParser.new do |option_parser|
20
20
  option_parser.separator ''
21
21
  option_parser.separator 'Commands:'
22
22
  option_parser.separator ' cp Copy'
23
+ option_parser.separator ' run Run command'
23
24
 
24
25
  option_parser.separator ''
25
26
  option_parser.separator format('Version: %<version>s', version: Occson::VERSION)
@@ -85,6 +86,49 @@ when 'cp'
85
86
  raise OptionParser::MissingArgument, 'destination' unless arguments.fetch(1, nil)
86
87
 
87
88
  exit(1) unless Occson::Commands::Copy.new(arguments[0], arguments[1], options['access_token'], options['passphrase'], force: options.fetch('force', false)).call
89
+ when 'run'
90
+ option_parser = OptionParser.new do |option_parser|
91
+ option_parser.banner = 'Usage: occson run [OPTIONS] <OccsonUri> -- <Command>'
92
+ option_parser.separator ''
93
+ option_parser.separator 'Store, manage and deploy configuration securely with Occson.'
94
+ option_parser.separator ''
95
+ option_parser.separator 'Options:'
96
+
97
+ option_parser.on('-a OCCSON_ACCESS_TOKEN', '--access-token OCCSON_ACCESS_TOKEN', String, 'Occson access token') do |v|
98
+ options['access_token'] = v
99
+ end
100
+
101
+ option_parser.on('-p OCCSON_PASSPHRASE', '--passphrase OCCSON_PASSPHRASE', String, 'Occson passphrase') do |v|
102
+ options['passphrase'] = v
103
+ end
104
+
105
+ option_parser.separator ''
106
+ option_parser.separator 'Configure via environment variables:'
107
+ option_parser.separator ' OCCSON_ACCESS_TOKEN'
108
+ option_parser.separator ' OCCSON_PASSPHRASE'
109
+
110
+ option_parser.separator ''
111
+ option_parser.separator 'Examples:'
112
+ option_parser.separator ' Run command with downloaded environment variables'
113
+ option_parser.separator ' occson run occson://0.1.0/.env -- printenv'
114
+ option_parser.separator ''
115
+
116
+ option_parser.separator format('Version: %<version>s', version: Occson::VERSION)
117
+ end
118
+
119
+ arguments = option_parser.parse!
120
+
121
+ unless options.values.any?
122
+ puts option_parser
123
+ exit(1)
124
+ end
125
+
126
+ raise OptionParser::MissingArgument, 'access_token' unless options['access_token']
127
+ raise OptionParser::MissingArgument, 'passphrase' unless options['passphrase']
128
+ raise OptionParser::MissingArgument, 'source' unless arguments.fetch(0, nil)
129
+ raise OptionParser::MissingArgument, 'command' unless arguments.fetch(1, nil)
130
+
131
+ exit(1) unless Occson::Commands::Run.new(arguments[0], arguments[1], arguments[2..], options['access_token'], options['passphrase']).call
88
132
  else
89
133
  puts option_parser
90
134
  exit(1)
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Occson
4
+ module Commands
5
+ class Run
6
+ def initialize(source, command, arguments, access_token, passphrase)
7
+ @source = source
8
+ @command = command
9
+ @arguments = arguments
10
+ @access_token = access_token
11
+ @passphrase = passphrase
12
+ end
13
+
14
+ def call
15
+ content = Document.new(@source, @access_token, @passphrase).download
16
+ return unless content
17
+
18
+ parsed_content = content.split("\n").map do |line|
19
+ next if line.start_with?('#')
20
+
21
+ line.split("=", 2) # @TODO handle wrapped values
22
+ end.compact
23
+
24
+ envs = Hash[parsed_content]
25
+
26
+ system(envs, @command, *@arguments)
27
+ end
28
+ end
29
+ end
30
+ end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Occson
4
4
  # Occson gem version definition
5
- VERSION = '4.0.0'
5
+ VERSION = '4.1.1'
6
6
  end
data/lib/occson.rb CHANGED
@@ -14,6 +14,7 @@ require 'occson/downloader'
14
14
  require 'occson/document'
15
15
 
16
16
  require 'occson/commands/copy'
17
+ require 'occson/commands/run'
17
18
 
18
19
  # Top level `Occson` namespace.
19
20
  module Occson; end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: occson
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - tkowalewski
8
8
  - paweljw
9
- autorequire:
9
+ autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2021-10-06 00:00:00.000000000 Z
12
+ date: 2023-02-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: inch
@@ -31,14 +31,14 @@ dependencies:
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: 0.11.3
34
+ version: 0.14.1
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: 0.11.3
41
+ version: 0.14.1
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: rake
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -59,70 +59,70 @@ dependencies:
59
59
  requirements:
60
60
  - - "~>"
61
61
  - !ruby/object:Gem::Version
62
- version: 4.7.3
62
+ version: 6.1.3
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: 4.7.3
69
+ version: 6.1.3
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rspec
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - "~>"
75
75
  - !ruby/object:Gem::Version
76
- version: 3.7.0
76
+ version: 3.12.0
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
81
  - - "~>"
82
82
  - !ruby/object:Gem::Version
83
- version: 3.7.0
83
+ version: 3.12.0
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: rubocop
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
88
  - - "~>"
89
89
  - !ruby/object:Gem::Version
90
- version: 0.52.1
90
+ version: 1.45.1
91
91
  type: :development
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
95
  - - "~>"
96
96
  - !ruby/object:Gem::Version
97
- version: 0.52.1
97
+ version: 1.45.1
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: simplecov
100
100
  requirement: !ruby/object:Gem::Requirement
101
101
  requirements:
102
102
  - - "~>"
103
103
  - !ruby/object:Gem::Version
104
- version: 0.15.1
104
+ version: 0.22.0
105
105
  type: :development
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
109
  - - "~>"
110
110
  - !ruby/object:Gem::Version
111
- version: 0.15.1
111
+ version: 0.22.0
112
112
  - !ruby/object:Gem::Dependency
113
113
  name: webmock
114
114
  requirement: !ruby/object:Gem::Requirement
115
115
  requirements:
116
116
  - - "~>"
117
117
  - !ruby/object:Gem::Version
118
- version: 3.3.0
118
+ version: 3.18.1
119
119
  type: :development
120
120
  prerelease: false
121
121
  version_requirements: !ruby/object:Gem::Requirement
122
122
  requirements:
123
123
  - - "~>"
124
124
  - !ruby/object:Gem::Version
125
- version: 3.3.0
125
+ version: 3.18.1
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: yard
128
128
  requirement: !ruby/object:Gem::Requirement
@@ -137,6 +137,20 @@ dependencies:
137
137
  - - ">="
138
138
  - !ruby/object:Gem::Version
139
139
  version: 0.9.11
140
+ - !ruby/object:Gem::Dependency
141
+ name: rexml
142
+ requirement: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - "~>"
145
+ - !ruby/object:Gem::Version
146
+ version: 3.2.5
147
+ type: :development
148
+ prerelease: false
149
+ version_requirements: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - "~>"
152
+ - !ruby/object:Gem::Version
153
+ version: 3.2.5
140
154
  description: ''
141
155
  email:
142
156
  - me@tkowalewski.pl
@@ -153,6 +167,7 @@ files:
153
167
  - exe/occson
154
168
  - lib/occson.rb
155
169
  - lib/occson/commands/copy.rb
170
+ - lib/occson/commands/run.rb
156
171
  - lib/occson/decrypter.rb
157
172
  - lib/occson/document.rb
158
173
  - lib/occson/downloader.rb
@@ -163,7 +178,7 @@ homepage: https://github.com/occson/occson.rb
163
178
  licenses:
164
179
  - MIT
165
180
  metadata: {}
166
- post_install_message:
181
+ post_install_message:
167
182
  rdoc_options: []
168
183
  require_paths:
169
184
  - lib
@@ -179,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
179
194
  version: '0'
180
195
  requirements: []
181
196
  rubygems_version: 3.0.3
182
- signing_key:
197
+ signing_key:
183
198
  specification_version: 4
184
199
  summary: Store, manage and deploy configuration securely with Occson.
185
200
  test_files: []