Class: DexSync::UpdateKubeConfigService
- Inherits:
-
Object
- Object
- DexSync::UpdateKubeConfigService
- Defined in:
- lib/dex_sync.rb
Instance Method Summary collapse
-
#initialize(config) ⇒ UpdateKubeConfigService
constructor
A new instance of UpdateKubeConfigService.
- #perform ⇒ Object
Constructor Details
#initialize(config) ⇒ UpdateKubeConfigService
Returns a new instance of UpdateKubeConfigService.
44 45 46 |
# File 'lib/dex_sync.rb', line 44 def initialize(config) @config = config end |
Instance Method Details
#perform ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/dex_sync.rb', line 48 def perform @config.clusters.each do |cluster| login_params = { cross_client: cluster, offline_access: 'yes' } puts("Logging into dex app...#{cluster}") response = connection.post('login', login_params) puts('Wait for it...') doc = Nokogiri::HTML(response.body) refresh_token = doc.css('form > input[name=refresh_token]').first['value'] id_token = doc.css('form > input[name=id_token]').first['value'] @config.namespaces.each do |namespace| puts("Dowloading config for #{cluster}:#{namespace}") download_params = { refresh_token: refresh_token, id_token: id_token, namespace: namespace, internal: true } response = connection.post('download', download_params) downloaded_config = YAML.safe_load(response.body) = File.(@config.download_path + "/#{cluster}-#{namespace}-internal") File.open(, 'w') { |f| f.write(downloaded_config.to_yaml) } end end end |