Class: Rancher::ConfigGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Rancher::ConfigGenerator
- Defined in:
- lib/generators/rancher/config/config_generator.rb
Instance Method Summary collapse
- #create_ranche_compose ⇒ Object
- #create_rancher_config ⇒ Object
- #create_rancher_task ⇒ Object
- #create_rancher_wrapper ⇒ Object
- #ignore_rancher_config ⇒ Object
- #setup ⇒ Object
Instance Method Details
#create_ranche_compose ⇒ Object
29 30 31 |
# File 'lib/generators/rancher/config/config_generator.rb', line 29 def create_ranche_compose template 'rancher-compose.yml', 'rancher/rancher-compose.yml' end |
#create_rancher_config ⇒ Object
19 20 21 |
# File 'lib/generators/rancher/config/config_generator.rb', line 19 def create_rancher_config template 'rancherconfig.json', 'rancher/rancherconfig.json' end |
#create_rancher_task ⇒ Object
38 39 40 |
# File 'lib/generators/rancher/config/config_generator.rb', line 38 def create_rancher_task template 'rancher.rake', 'lib/tasks/rancher.rake' end |
#create_rancher_wrapper ⇒ Object
33 34 35 36 |
# File 'lib/generators/rancher/config/config_generator.rb', line 33 def create_rancher_wrapper template 'rancher', 'bin/rancher' run('chmod +x bin/rancher') end |
#ignore_rancher_config ⇒ Object
23 24 25 26 27 |
# File 'lib/generators/rancher/config/config_generator.rb', line 23 def ignore_rancher_config ignore('.gitignore', 'rancher/rancherconfig.json') ignore('.dockerignore', 'lib/tasks/rancher.rake') ignore('.dockerignore', 'rancher/') end |
#setup ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/generators/rancher/config/config_generator.rb', line 4 def setup config = file?('rancher/rancherconfig.json') ? load_json_file('rancher/rancherconfig.json') : {} docker_config = file?('docker/dockerconfig.json') ? load_json_file('docker/dockerconfig.json') : {} @docker_compose_config = YAML.load_file(docker_config['prod_yml']) @services = @docker_compose_config['services'].each_with_object([]) { |(key, _value), r| r << key; } @url = ask_with_default('Rancher URL:[example:http://<server_ip>:8080]', config['url'] || '') @access_key = ask_with_default('ACCESS KEY:', config['accessKey']) @secret_key = ask_with_default('SECRET KEY:', config['secretKey']) @environment = ask_with_default('Enviroment Id Or Name:', config['environment']) @stack = ask_with_default('stack name:', config['stack'] || File.basename(Dir.getwd)) @debug = false end |