credman 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/gemfiles/activesupport_6.gemfile.lock +1 -1
- data/gemfiles/activesupport_6_1.gemfile.lock +1 -1
- data/gemfiles/activesupport_7.gemfile.lock +1 -1
- data/gemfiles/activesupport_master.gemfile.lock +1 -1
- data/lib/credman/commands.rb +14 -0
- data/lib/credman/init.rb +49 -0
- data/lib/credman/version.rb +1 -1
- data/lib/credman.rb +2 -0
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c74165bc022e5e8e8d0db40be010d9baf8933bb62156aa6ac35ea6ac3f1256a5
|
4
|
+
data.tar.gz: 3dafb6835263b103cce2382446107276c88286b66518055b17867b95db71cb2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d78cf276672cf343575c884177181dffac89e06ccde37d27955f21186c500e70037cfbad3968e7b889cc5b4cc0cf533fd65100baa666dd114af9e0ff0a1e0fe
|
7
|
+
data.tar.gz: 620b1c2d8dd5695b02e4713c3ff66cfa33d0832d00766340e3fa31b39bb3a540202a479e456d10461fba7fbd23965e71ac440eea85a3e4847c7c5f0b2ac079a5
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/lib/credman/commands.rb
CHANGED
@@ -1,6 +1,20 @@
|
|
1
1
|
module Credman
|
2
2
|
module CLI
|
3
3
|
module Commands
|
4
|
+
class Init < Dry::CLI::Command
|
5
|
+
desc "Create initial config for credman"
|
6
|
+
|
7
|
+
option :force_rewrite,
|
8
|
+
aliases: ["f"],
|
9
|
+
type: :boolean,
|
10
|
+
default: false,
|
11
|
+
desc: "rewrite existing config"
|
12
|
+
|
13
|
+
def call(force_rewrite:, **)
|
14
|
+
Credman::Init.new.perform(force_rewrite)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
4
18
|
class Get < Dry::CLI::Command
|
5
19
|
desc "Find keys in credentials files for each environment"
|
6
20
|
|
data/lib/credman/init.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require "tty-command"
|
2
|
+
|
3
|
+
module Credman
|
4
|
+
class Init
|
5
|
+
attr_reader :config_path
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@config_path = "config/credman.yml"
|
9
|
+
end
|
10
|
+
|
11
|
+
def perform(force_rewrite)
|
12
|
+
if config_exists? && !force_rewrite
|
13
|
+
abort "[SKIPPED] config/credman.yml already exist. You can run with `--force-rewrite` option to rewrite it"
|
14
|
+
end
|
15
|
+
|
16
|
+
save_config(available_environments: available_environments, default_diff_branch: default_diff_branch)
|
17
|
+
puts "[CREATED] config/credman.yml"
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def config_exists?
|
23
|
+
File.exist?(config_path)
|
24
|
+
end
|
25
|
+
|
26
|
+
def save_config(**options)
|
27
|
+
File.write(config_path, config_file_content(**options))
|
28
|
+
end
|
29
|
+
|
30
|
+
def config_file_content(available_environments:, default_diff_branch:)
|
31
|
+
<<~YML
|
32
|
+
default_diff_branch: #{default_diff_branch}
|
33
|
+
available_environments:
|
34
|
+
#{available_environments.map { |env| " - " + env }.join("\n")}
|
35
|
+
YML
|
36
|
+
end
|
37
|
+
|
38
|
+
def default_diff_branch
|
39
|
+
cmd = TTY::Command.new(pty: true, printer: :null)
|
40
|
+
base_branch = cmd.run!("git remote show origin | sed -n '/HEAD branch/s/.*: //p'").out.strip
|
41
|
+
base_branch = "main" if base_branch.blank?
|
42
|
+
"origin/#{base_branch}"
|
43
|
+
end
|
44
|
+
|
45
|
+
def available_environments
|
46
|
+
Dir.glob("./config/credentials/*.yml.enc").map { |filepath| File.basename(filepath, ".yml.enc") }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/credman/version.rb
CHANGED
data/lib/credman.rb
CHANGED
@@ -5,6 +5,7 @@ require "dry/cli"
|
|
5
5
|
require "pastel"
|
6
6
|
require "hash_diff"
|
7
7
|
|
8
|
+
require_relative "credman/init"
|
8
9
|
require_relative "credman/configuration"
|
9
10
|
module Credman
|
10
11
|
def self.configuration
|
@@ -29,6 +30,7 @@ module Credman
|
|
29
30
|
module Commands
|
30
31
|
extend Dry::CLI::Registry
|
31
32
|
|
33
|
+
register "init", Init
|
32
34
|
register "get", Get
|
33
35
|
register "list", List
|
34
36
|
register "set", Set
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: credman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergey Andronov
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -177,6 +177,7 @@ files:
|
|
177
177
|
- lib/credman/delete.rb
|
178
178
|
- lib/credman/diff.rb
|
179
179
|
- lib/credman/get.rb
|
180
|
+
- lib/credman/init.rb
|
180
181
|
- lib/credman/list.rb
|
181
182
|
- lib/credman/set.rb
|
182
183
|
- lib/credman/version.rb
|
@@ -187,7 +188,7 @@ metadata:
|
|
187
188
|
homepage_uri: https://github.com/Uscreen-video/credman
|
188
189
|
source_code_uri: https://github.com/Uscreen-video/credman
|
189
190
|
changelog_uri: https://github.com/Uscreen-video/credman/blob/main/CHANGELOG.md
|
190
|
-
post_install_message:
|
191
|
+
post_install_message:
|
191
192
|
rdoc_options: []
|
192
193
|
require_paths:
|
193
194
|
- lib
|
@@ -203,7 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
203
204
|
version: '0'
|
204
205
|
requirements: []
|
205
206
|
rubygems_version: 3.1.6
|
206
|
-
signing_key:
|
207
|
+
signing_key:
|
207
208
|
specification_version: 4
|
208
209
|
summary: The tool what you miss for managing Rails credentials
|
209
210
|
test_files: []
|