Class: Fastlane::Flint::Encrypt
- Inherits:
-
Object
- Object
- Fastlane::Flint::Encrypt
- Defined in:
- lib/fastlane/plugin/flint/helper/encrypt.rb
Instance Method Summary collapse
- #clear_password(git_url) ⇒ Object
- #decrypt_repo(path: nil, git_url: nil, manual_password: nil) ⇒ Object
- #encrypt_repo(path: nil, git_url: nil) ⇒ Object
-
#initialize ⇒ Encrypt
constructor
A new instance of Encrypt.
- #password(git_url) ⇒ Object
- #server_name(git_url) ⇒ Object
- #store_password(git_url, password) ⇒ Object
Constructor Details
#initialize ⇒ Encrypt
Returns a new instance of Encrypt.
11 12 13 14 |
# File 'lib/fastlane/plugin/flint/helper/encrypt.rb', line 11 def initialize() # Keep the password in the memory so we can reuse it later on @tmp_password = nil end |
Instance Method Details
#clear_password(git_url) ⇒ Object
48 49 50 |
# File 'lib/fastlane/plugin/flint/helper/encrypt.rb', line 48 def clear_password(git_url) @tmp_password = "" end |
#decrypt_repo(path: nil, git_url: nil, manual_password: nil) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/fastlane/plugin/flint/helper/encrypt.rb', line 61 def decrypt_repo(path: nil, git_url: nil, manual_password: nil) iterate(path) do |current| begin decrypt(path: current, password: manual_password || password(git_url)) rescue UI.error("Couldn't decrypt the repo, please make sure you enter the right password! %s" % manual_password || password(git_url)) UI.user_error!("Invalid password passed via 'FLINT_PASSWORD'") if ENV["FLINT_PASSWORD"] clear_password(git_url) password(git_url) decrypt_repo(path: path, git_url: git_url) return end UI.success("🔓 Decrypted '#{File.basename(current)}'") if FastlaneCore::Globals.verbose? end UI.success("🔓 Successfully decrypted keystores repo") end |
#encrypt_repo(path: nil, git_url: nil) ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/fastlane/plugin/flint/helper/encrypt.rb', line 52 def encrypt_repo(path: nil, git_url: nil) iterate(path) do |current| encrypt(path: current, password: password(git_url)) UI.success("🔒 Encrypted '#{File.basename(current)}'") if FastlaneCore::Globals.verbose? end UI.success("🔒 Successfully encrypted keystores repo") end |
#password(git_url) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/fastlane/plugin/flint/helper/encrypt.rb', line 20 def password(git_url) password = ENV["FLINT_PASSWORD"] unless password if @tmp_password password = @tmp_password end end unless password && password != '' if !UI.interactive? UI.error("The FLINT_PASSWORD environment variable did not contain a password.") UI.error("Bailing out instead of asking for a password, since this is non-interactive mode.") UI.user_error!("Try setting the FLINT_PASSWORD environment variable, or temporarily enable interactive mode to store a password.") else UI.important("Enter the passphrase that should be used to encrypt/decrypt your keystores") UI.important("Make sure to remember the password, as you'll need it when you run flint again") password = ChangePassword.ask_password(confirm: true) store_password(git_url, password) end end return password end |
#server_name(git_url) ⇒ Object
16 17 18 |
# File 'lib/fastlane/plugin/flint/helper/encrypt.rb', line 16 def server_name(git_url) ["flint", git_url].join("_") end |
#store_password(git_url, password) ⇒ Object
44 45 46 |
# File 'lib/fastlane/plugin/flint/helper/encrypt.rb', line 44 def store_password(git_url, password) @tmp_password = password end |