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)
expanded_path = File.expand_path(@config.download_path + "/#{cluster}-#{namespace}-internal")
File.open(expanded_path, 'w') { |f| f.write(downloaded_config.to_yaml) }
end
end
end
|