ccs 1.0.1 → 2.0.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 +4 -4
- data/README.md +52 -0
- data/exe/ccs +58 -44
- data/lib/ccs.rb +2 -2
- data/lib/ccs/commands/copy.rb +36 -0
- data/lib/ccs/{configuration_file.rb → document.rb} +1 -1
- data/lib/ccs/version.rb +1 -1
- metadata +4 -4
- data/lib/ccs/application.rb +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60d859bd2a81a6b31a609481cd0e1d0c04a2a4721084c044c65089f434ba0028
|
4
|
+
data.tar.gz: 499c070bcab5c966055de84266ffc4bfd474dc55e5051f82cc6c25dac5ceb992
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be0fd271a7d744a143bb3a11b55bbde8a5da7ae569eb360f642160bf6fe04ddbbdb66a0f866f1999223c863b0b653dd234b54f56edd69820dab8ae50463e1088
|
7
|
+
data.tar.gz: cfcd265804deb742dc684cdd63aaef3d35e76cb9be048e0ddccec01ba28bbe7ab3eaa7523c96d0096d61636bcc71cb45b705d3760565eab70ddee047cfc1be10
|
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# CCS
|
2
2
|
|
3
|
+
Configuration control system
|
3
4
|
|
4
5
|
## Installation
|
5
6
|
|
@@ -19,8 +20,59 @@ Or install it yourself as:
|
|
19
20
|
|
20
21
|
## Usage
|
21
22
|
|
23
|
+
ccs cp [OPTIONS] <(LocalPath|STDIN)|(CCSUri|Uri)> <(CCSUri|Uri)|(LocalPath|STDOUT)>
|
24
|
+
|
25
|
+
Options:
|
26
|
+
-a CCS_ACCESS_TOKEN, CCS Access Token
|
27
|
+
--access-token
|
28
|
+
-s CCS_SECRET_TOKEN, CCS Secret Token
|
29
|
+
--secret-token
|
30
|
+
|
31
|
+
|
22
32
|
## Example
|
23
33
|
|
34
|
+
Download to STDOUT
|
35
|
+
|
36
|
+
ccs cp ccs://workspace-name/0.1.0/path/to/file.yml -
|
37
|
+
ccs cp http://host.tld:9292/workspace-name/0.1.0/path/to/file.yml -
|
38
|
+
ccs cp https://host.tld/workspace-name/0.1.0/path/to/file.yml -
|
39
|
+
|
40
|
+
Download to local file
|
41
|
+
|
42
|
+
ccs cp ccs://workspace-name/0.1.0/path/to/file.yml /local/path/to/file.yml
|
43
|
+
|
44
|
+
Upload local file
|
45
|
+
|
46
|
+
ccs cp /local/path/to/file.yml ccs://workspace-name/0.1.0/path/to/file.yml
|
47
|
+
|
48
|
+
Upload content from STDIN
|
49
|
+
|
50
|
+
echo "{ a: 1 }" | ccs cp - ccs://workspace-name/0.1.0/path/to/file.yml
|
51
|
+
cat /local/path/to/file.yml | ccs cp - ccs://workspace-name/0.1.0/path/to/file.yml
|
52
|
+
|
53
|
+
## API
|
54
|
+
|
55
|
+
Upload
|
56
|
+
|
57
|
+
require 'ccs'
|
58
|
+
|
59
|
+
destination = 'ccs://workspace-name/0.1.0/path/to/file.yml'
|
60
|
+
access_token = ENV.fetch('CCS_ACCESS_TOKEN')
|
61
|
+
secret_token = 'MySecretToken'
|
62
|
+
content = 'RAILS_ENV=production'
|
63
|
+
|
64
|
+
Ccs::Document.new(destination, access_token, secret_token).upload(content)
|
65
|
+
|
66
|
+
Download
|
67
|
+
|
68
|
+
require 'ccs'
|
69
|
+
|
70
|
+
source = 'ccs://workspace-name/0.1.0/path/to/file.yml'
|
71
|
+
access_token = ENV.fetch('CCS_ACCESS_TOKEN')
|
72
|
+
secret_token = 'MySecretToken'
|
73
|
+
|
74
|
+
Ccs::Document.new(source, access_token, secret_token).download
|
75
|
+
|
24
76
|
## Development
|
25
77
|
|
26
78
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/exe/ccs
CHANGED
@@ -12,59 +12,73 @@ options = {
|
|
12
12
|
'secret_token' => ENV['CCS_SECRET_TOKEN']
|
13
13
|
}
|
14
14
|
|
15
|
-
option_parser = OptionParser.new
|
16
|
-
option_parser.banner = 'Usage: ccs [OPTIONS]
|
17
|
-
option_parser.separator ''
|
18
|
-
option_parser.separator 'Configuration Control System (CCS)'
|
19
|
-
option_parser.separator ''
|
20
|
-
option_parser.separator 'Options:'
|
15
|
+
option_parser = OptionParser.new do |option_parser|
|
16
|
+
option_parser.banner = 'Usage: ccs [COMMAND [OPTIONS]]'
|
21
17
|
|
22
|
-
option_parser.
|
23
|
-
|
24
|
-
|
18
|
+
option_parser.separator ''
|
19
|
+
option_parser.separator 'Configuration Control System (CCS)'
|
20
|
+
option_parser.separator ''
|
21
|
+
option_parser.separator 'Commands:'
|
22
|
+
option_parser.separator ' cp Copy'
|
25
23
|
|
26
|
-
option_parser.
|
27
|
-
|
24
|
+
option_parser.separator ''
|
25
|
+
option_parser.separator format('Version: %<version>s', version: Ccs::VERSION)
|
28
26
|
end
|
29
27
|
|
30
|
-
|
31
|
-
|
32
|
-
|
28
|
+
case ARGV.shift
|
29
|
+
when 'cp'
|
30
|
+
option_parser = OptionParser.new do |option_parser|
|
31
|
+
option_parser.banner = 'Usage: ccs cp [OPTIONS] <(LocalPath|STDIN)|(CCSUri|Uri)> <(CCSUri|Uri)|(LocalPath|STDOUT)>'
|
32
|
+
option_parser.separator ''
|
33
|
+
option_parser.separator 'Configuration Control System (CCS) - Copy'
|
34
|
+
option_parser.separator ''
|
35
|
+
option_parser.separator 'Options:'
|
33
36
|
|
34
|
-
option_parser.
|
35
|
-
|
36
|
-
|
37
|
-
option_parser.separator ' CCS_SECRET_TOKEN'
|
37
|
+
option_parser.on('-a CCS_ACCESS_TOKEN', '--access-token CCS_ACCESS_TOKEN', String, 'CCS Access Token') do |v|
|
38
|
+
options['access_token'] = v
|
39
|
+
end
|
38
40
|
|
39
|
-
option_parser.
|
40
|
-
|
41
|
-
|
42
|
-
option_parser.separator ' ccs ccs://workspace-name/0.1.0/path/to/file.yml -'
|
43
|
-
option_parser.separator ' ccs http://host.tld:9292/workspace-name/0.1.0/path/to/file.yml -'
|
44
|
-
option_parser.separator ' ccs https://host.tld/workspace-name/0.1.0/path/to/file.yml -'
|
45
|
-
option_parser.separator ' Download to local file'
|
46
|
-
option_parser.separator ' ccs ccs://workspace-name/0.1.0/path/to/file.yml /local/path/to/file.yml'
|
47
|
-
option_parser.separator ' Upload local file'
|
48
|
-
option_parser.separator ' ccs /local/path/to/file.yml ccs://workspace-name/0.1.0/path/to/file.yml'
|
49
|
-
option_parser.separator ' Upload content from STDIN'
|
50
|
-
option_parser.separator ' echo "{ a: 1 }" | ccs - ccs://workspace-name/0.1.0/path/to/file.yml'
|
51
|
-
option_parser.separator ' cat /local/path/to/file.yml | ccs - ccs://workspace-name/0.1.0/path/to/file.yml'
|
52
|
-
option_parser.separator ''
|
41
|
+
option_parser.on('-s CCS_SECRET_TOKEN', '--secret-token CCS_SECRET_TOKEN', String, 'CCS Secret Token') do |v|
|
42
|
+
options['secret_token'] = v
|
43
|
+
end
|
53
44
|
|
54
|
-
option_parser.separator
|
45
|
+
option_parser.separator ''
|
46
|
+
option_parser.separator 'Configure via environment variables:'
|
47
|
+
option_parser.separator ' CCS_ACCESS_TOKEN'
|
48
|
+
option_parser.separator ' CCS_SECRET_TOKEN'
|
55
49
|
|
56
|
-
|
50
|
+
option_parser.separator ''
|
51
|
+
option_parser.separator 'Examples:'
|
52
|
+
option_parser.separator ' Download to STDOUT'
|
53
|
+
option_parser.separator ' ccs cp ccs://workspace-name/0.1.0/path/to/file.yml -'
|
54
|
+
option_parser.separator ' ccs cp http://host.tld:9292/workspace-name/0.1.0/path/to/file.yml -'
|
55
|
+
option_parser.separator ' ccs cp https://host.tld/workspace-name/0.1.0/path/to/file.yml -'
|
56
|
+
option_parser.separator ' Download to local file'
|
57
|
+
option_parser.separator ' ccs cp ccs://workspace-name/0.1.0/path/to/file.yml /local/path/to/file.yml'
|
58
|
+
option_parser.separator ' Upload local file'
|
59
|
+
option_parser.separator ' ccs cp /local/path/to/file.yml ccs://workspace-name/0.1.0/path/to/file.yml'
|
60
|
+
option_parser.separator ' Upload content from STDIN'
|
61
|
+
option_parser.separator ' echo "{ a: 1 }" | ccs cp - ccs://workspace-name/0.1.0/path/to/file.yml'
|
62
|
+
option_parser.separator ' cat /local/path/to/file.yml | ccs cp - ccs://workspace-name/0.1.0/path/to/file.yml'
|
63
|
+
option_parser.separator ''
|
57
64
|
|
58
|
-
|
59
|
-
|
60
|
-
exit(1)
|
61
|
-
end
|
65
|
+
option_parser.separator format('Version: %<version>s', version: Ccs::VERSION)
|
66
|
+
end
|
62
67
|
|
63
|
-
|
68
|
+
arguments = option_parser.parse!
|
64
69
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
70
|
+
unless options.values.any?
|
71
|
+
puts option_parser
|
72
|
+
exit(1)
|
73
|
+
end
|
69
74
|
|
70
|
-
|
75
|
+
raise OptionParser::MissingArgument, 'access_token' unless options['access_token']
|
76
|
+
raise OptionParser::MissingArgument, 'secret_token' unless options['secret_token']
|
77
|
+
raise OptionParser::MissingArgument, 'source' unless arguments.fetch(0, nil)
|
78
|
+
raise OptionParser::MissingArgument, 'destination' unless arguments.fetch(1, nil)
|
79
|
+
|
80
|
+
exit(1) unless Ccs::Commands::Copy.new(arguments[0], arguments[1], options['access_token'], options['secret_token']).call
|
81
|
+
else
|
82
|
+
puts option_parser
|
83
|
+
exit(1)
|
84
|
+
end
|
data/lib/ccs.rb
CHANGED
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Ccs
|
4
|
+
module Commands
|
5
|
+
class Copy
|
6
|
+
def initialize(source, destination, access_token, secret_token)
|
7
|
+
@source = source
|
8
|
+
@destination = destination
|
9
|
+
@access_token = access_token
|
10
|
+
@secret_token = secret_token
|
11
|
+
end
|
12
|
+
|
13
|
+
def call
|
14
|
+
download? ? download : upload
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def download?
|
20
|
+
@source.match?(%r{\A(ccs|https?):\/\/})
|
21
|
+
end
|
22
|
+
|
23
|
+
def download
|
24
|
+
content = Document.new(@source, @access_token, @secret_token).download
|
25
|
+
return unless content
|
26
|
+
|
27
|
+
(@destination.eql?('-') ? STDOUT : File.new(@destination, 'w')).print content
|
28
|
+
end
|
29
|
+
|
30
|
+
def upload
|
31
|
+
content = @source.eql?('-') ? STDIN.read : File.read(@source)
|
32
|
+
Document.new(@destination, @access_token, @secret_token).upload(content)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/ccs/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ccs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tkowalewski
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: inch
|
@@ -150,9 +150,9 @@ files:
|
|
150
150
|
- README.md
|
151
151
|
- exe/ccs
|
152
152
|
- lib/ccs.rb
|
153
|
-
- lib/ccs/
|
154
|
-
- lib/ccs/configuration_file.rb
|
153
|
+
- lib/ccs/commands/copy.rb
|
155
154
|
- lib/ccs/decrypter.rb
|
155
|
+
- lib/ccs/document.rb
|
156
156
|
- lib/ccs/downloader.rb
|
157
157
|
- lib/ccs/encrypter.rb
|
158
158
|
- lib/ccs/uploader.rb
|
data/lib/ccs/application.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Ccs
|
4
|
-
class Application
|
5
|
-
def initialize(source, destination, access_token, secret_token)
|
6
|
-
@source = source
|
7
|
-
@destination = destination
|
8
|
-
@access_token = access_token
|
9
|
-
@secret_token = secret_token
|
10
|
-
end
|
11
|
-
|
12
|
-
def run
|
13
|
-
download? ? download : upload
|
14
|
-
end
|
15
|
-
|
16
|
-
private
|
17
|
-
|
18
|
-
def download?
|
19
|
-
@source.match?(%r{\A(ccs|https?):\/\/})
|
20
|
-
end
|
21
|
-
|
22
|
-
def download
|
23
|
-
content = ConfigurationFile.new(@source, @access_token, @secret_token).download
|
24
|
-
return unless content
|
25
|
-
|
26
|
-
(@destination.eql?('-') ? STDOUT : File.new(@destination, 'w')).print content
|
27
|
-
end
|
28
|
-
|
29
|
-
def upload
|
30
|
-
content = @source.eql?('-') ? STDIN.read : File.read(@source)
|
31
|
-
ConfigurationFile.new(@destination, @access_token, @secret_token).upload(content)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|