cem_acpt 0.2.2 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1c9526e4b417c867511e5d9c6ffe4ba78d826df1ab62a119c716c51e3ee435c7
4
- data.tar.gz: 1ff8eb2952649b6e8d8543f8387c01d45db742572542116b1fd409a5908c0a9b
3
+ metadata.gz: 7b36c525ca6904813988ad305cc4a89607dff2edcdc8d749e347660047174b37
4
+ data.tar.gz: ed7e418fbcfadd8773f25f026afa0341119ab28c5e3cc91976f46c42e83af5aa
5
5
  SHA512:
6
- metadata.gz: efbce7fcd14347831829087444f9f37968e953dc507720a12d946c2f7bebde8d724b23b658f0274c1ecc392252ed23067d31199715ea01d73beb7b19a021d9ec
7
- data.tar.gz: 329b184d58d4681c19102d4b75514ab60f93e20f95d4b4d3eeee15dcc821a1ca9e13019fca2fe0cf47b4ac2ebf78a64108eacb9999bd7028f4c25b59452117da
6
+ metadata.gz: ee9ccfe1841b755c0f8df1937d66d0e04e62efe29326f16df33af5d9d66fe47441177098a2ffaffd1f843397d19d2f5cf95dcb1b4e536568d0d52cc5848aa052
7
+ data.tar.gz: c1c4f2b3a96134009552f9d464b407b64abef6d37f19df28f99b18b17445a492872a77116e924164c38aa65d1b8a96cb089ae7eff58f7414fbc5d7376f24e5cc
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cem_acpt (0.2.2)
4
+ cem_acpt (0.2.5)
5
5
  concurrent-ruby (~> 1.1.9)
6
6
  deep_merge (~> 1.2.2)
7
7
  net-ssh (~> 7.0.0.beta1)
@@ -337,17 +337,9 @@ module CemAcpt::Platform::Gcp
337
337
 
338
338
  # This function returns the currently authenticated user's name sanitized for use in SSH
339
339
  def authenticated_user_name
340
- uname = nil
341
- begin
342
- uname = local_exec('config get-value account', out_format: nil, project_flag: false)
343
- rescue RuntimeError
344
- auth_json = local_exec('auth list')
345
- uname = auth_json.find { |x| x['status'] == 'ACTIVE' }['account']
346
- end
347
-
348
- raise 'failed to find authenticated user name' unless uname
349
-
350
- uname.gsub(/[^a-zA-Z0-9_]/, '_')
340
+ local_exec('compute os-login describe-profile', project_flag: false)['posixAccounts'][0]['username']
341
+ rescue StandardError => e
342
+ raise "failed to find authenticated user name from os-login profile: #{e.message}"
351
343
  end
352
344
  end
353
345
  end
@@ -82,10 +82,12 @@ module CemAcpt
82
82
  # SSH-related utilities
83
83
  module SSH
84
84
  def self.ssh_keygen
85
- bin_path = `command -v ssh-keygen`.chomp
85
+ bin_path = `#{ENV['SHELL']} -c 'command -v ssh-keygen'`.chomp
86
86
  raise 'Cannot find ssh-keygen! Install it and verify PATH' unless bin_path
87
87
 
88
88
  bin_path
89
+ rescue StandardError => e
90
+ raise "Cannot find ssh-keygen! Install it and verify PATH. Orignal error: #{e}"
89
91
  end
90
92
 
91
93
  def self.default_keydir
@@ -98,7 +100,7 @@ module CemAcpt
98
100
  def self.ephemeral_ssh_key(type: 'rsa', bits: '4096', comment: nil, keydir: default_keydir)
99
101
  raise ArgumentError, 'keydir does not exist' unless ::File.directory?(keydir)
100
102
 
101
- keyfile = ::File.join(keydir, SecureRandom.hex(16))
103
+ keyfile = ::File.join(keydir, 'acpt_test_key')
102
104
  keygen_cmd = [ssh_keygen, "-t #{type}", "-b #{bits}", "-f #{keyfile}", '-N ""']
103
105
  keygen_cmd << "-C \"#{comment}\"" if comment
104
106
  _, stderr, status = Open3.capture3(keygen_cmd.join(' '))
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CemAcpt
4
- VERSION = '0.2.2'
4
+ VERSION = '0.2.5'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cem_acpt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - puppetlabs
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-24 00:00:00.000000000 Z
11
+ date: 2022-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement