occson 4.0.0 → 4.1.0

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: 1547cbef16272584ac354e02dcd7415195ea0a338b84b6fa7d3dfa619c5ddca9
4
+ data.tar.gz: 1030496691b791193a1c371a496a99be32603b98f854703d03bccb9f3217782e
5
5
  SHA512:
6
- metadata.gz: 805566d333b73c0ff8e4796476195e361fcda648360e7a6dba99858f7603fe605fefa263d93b6fa3ac053208e0e4525eb686bd963d5530f36001992b83aee7af
7
- data.tar.gz: 4976e02e9f0810e5dda2e80cb4370b611587d1a17597a1810e1f5f6288b6d81b0701a84e6a294c14f1e1221d76c15cb391c560bffe4894ce61c5af3025cc0ddf
6
+ metadata.gz: ab554b69c2ec02d71a8f665ed0de6102608e1bf21f8863d6d1765793cfdbb044db51fc154b37afd0088cb3f1c3b5c1a180875df5b50782af06d25d6b130be476
7
+ data.tar.gz: ea6e9f5b7ac7a183abdc21e39a64d600ef83e9a4a890635f0565985ac47a27e1818bd94a226aa151d2482ebee23e54ff980c31e0fd07503e0be25519eb0c3446
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## 4.1.0 2022-02-06
2
+
3
+ ### Added
4
+
5
+ - run command
6
+
7
+ [Compare 4.0.0...4.1.0](https://github.com/occson/occson.rb/compare/4.0.0...4.1.0)
8
+
9
+
1
10
  ## 4.0.0 2021-10-06
2
11
 
3
12
  ### 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.0'
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,7 +1,7 @@
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.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - tkowalewski
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2021-10-06 00:00:00.000000000 Z
12
+ date: 2022-02-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: inch
@@ -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