Class: Covalence::SopsCli
- Inherits:
-
Object
- Object
- Covalence::SopsCli
- Defined in:
- lib/covalence/core/cli_wrappers/sops_cli.rb
Constant Summary collapse
- DIRECTION =
{ encrypt: { sops_option: "--encrypt", file_search_suffix: "-decrypted", file_replace_suffix: "-encrypted" }, decrypt: { sops_option: "--decrypt", file_search_suffix: "-encrypted", file_replace_suffix: "-decrypted" } }
Class Method Summary collapse
-
.clean_decrypt_path(path, extension = "*", dry_run: false, verbose: true) ⇒ Object
Clean targets all extensions by default, sounds like a more secure way to avoid commiting something accidentally.
- .decrypt_path(path = default_data_dir, extension = ".yaml") ⇒ Object
- .default_data_dir ⇒ Object
- .encrypt_path(path = default_data_dir, extension = ".yaml") ⇒ Object
Class Method Details
.clean_decrypt_path(path, extension = "*", dry_run: false, verbose: true) ⇒ Object
Clean targets all extensions by default, sounds like a more secure way to avoid commiting something accidentally
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/covalence/core/cli_wrappers/sops_cli.rb', line 34 def self.clean_decrypt_path(path, extension="*", dry_run: false, verbose: true) file_path = File.(path) if File.file?(file_path) files = [file_path] else files = Dir.glob(File.join(file_path, "**" , "*#{DIRECTION[:decrypt][:file_replace_suffix]}#{extension}")) end unless files.blank? FileUtils.rm_f(files, { noop: dry_run, verbose: verbose }) end end |
.decrypt_path(path = default_data_dir, extension = ".yaml") ⇒ Object
29 30 31 |
# File 'lib/covalence/core/cli_wrappers/sops_cli.rb', line 29 def self.decrypt_path(path=default_data_dir, extension=".yaml") modify_files(DIRECTION[:decrypt], path, extension) end |
.default_data_dir ⇒ Object
51 52 53 |
# File 'lib/covalence/core/cli_wrappers/sops_cli.rb', line 51 def self.default_data_dir @default_data_dir ||= File.join(WORKSPACE, YAML.load_file(CONFIG).fetch(:yaml, {}).fetch(:datadir, "")) end |
.encrypt_path(path = default_data_dir, extension = ".yaml") ⇒ Object
25 26 27 |
# File 'lib/covalence/core/cli_wrappers/sops_cli.rb', line 25 def self.encrypt_path(path=default_data_dir, extension=".yaml") modify_files(DIRECTION[:encrypt], path, extension) end |